mirror of
https://github.com/Mercury-Language/mercury.git
synced 2026-04-15 01:13:30 +00:00
compiler/switch_detection.m:
Add conditionally-enabled code to gather statistics about
what happens when a switch candidate has disjuncts left over,
and we test whether these leftovers form a switch on another variable.
(The results show that after 99.91% of switch candidates,
there are *no* disjuncts left over.)
compiler/mercury_compile_main.m:
Invoke the predicate that writes out any statistics we gathered.
tools/switch_depth:
This new summarizes the results.
37 lines
991 B
Awk
Executable File
37 lines
991 B
Awk
Executable File
#!/usr/bin/awk -f
|
|
# vim: ft=awk ts=4 sw=4 et
|
|
#
|
|
# This script summarizes the contents of the SWITCH_DEPTH_RESULTS files
|
|
# generated by the conditionally-enabled statistics-gathering code
|
|
# in switch_detection.m.
|
|
#
|
|
|
|
NF == 6 && $1 == "depth" {
|
|
depth = $2;
|
|
hit = $4;
|
|
miss = $6;
|
|
hits[depth] += hit;
|
|
hit_and_miss = hit + miss;
|
|
trials[depth] += hit_and_miss;
|
|
}
|
|
END {
|
|
max_depth = 0;
|
|
for (depth in trials) {
|
|
if (depth > max_depth) {
|
|
max_depth = depth;
|
|
}
|
|
|
|
hit_rate[depth] = (100 * hits[depth]) / trials[depth];
|
|
printf "depth %d: %5d trials, %5d hits, hit rate = %5.2f%%\n",
|
|
depth, trials[depth], hits[depth], hit_rate[depth];
|
|
}
|
|
|
|
i = 1;
|
|
while (i <= max_depth) {
|
|
leak_rate = (100 * trials[i]) / trials[i - 1];
|
|
printf "leak rate to depth %d: %5.2f%%\n", i, leak_rate;
|
|
i = i + 1;
|
|
}
|
|
}
|
|
|