mirror of
https://github.com/Mercury-Language/mercury.git
synced 2025-12-06 07:49:02 +00:00
compiler/options.m:
Add --inst-statistics as a developer-only option.
compiler/hlds_statistics.m:
Add code to gather and write out statistics about how frequently
each function symbol of the mer_inst type occurs in (a) the instmaps
of procedures' goals, and (b) in the automatically generated inst
tables.
compiler/mercury_compile_front_end.m:
Invoke the new code if the new option is specified.
(The code to do so is a near-copy of the nearby code for invoking
the other functionality in hlds_statistics.m.)
tools/inst_stats:
Add this tool for summarizing the statistics generated by the new option.
54 lines
1.4 KiB
Awk
Executable File
54 lines
1.4 KiB
Awk
Executable File
#!/usr/bin/awk -f
|
|
# vim: ts=4 sw=4 et ft=awk
|
|
#
|
|
# Given input containing only lines of the form
|
|
#
|
|
# category count
|
|
#
|
|
# this script computes and prints the total count for each category.
|
|
|
|
$1 == "INST_STATS" {
|
|
next;
|
|
}
|
|
$1 == "proc" {
|
|
if (NF == 3) {
|
|
proc[$2] += $3;
|
|
} else {
|
|
printf("unexpected line: <%s>\n", $0);
|
|
}
|
|
next;
|
|
}
|
|
$1 == "table" {
|
|
if (NF == 3) {
|
|
table[$2] += $3;
|
|
} else {
|
|
printf("unexpected line: <%s>\n", $0);
|
|
}
|
|
next;
|
|
}
|
|
{
|
|
printf("unexpected line: <%s>\n", $0);
|
|
}
|
|
END {
|
|
proc_total = 0;
|
|
for (i in proc) {
|
|
proc_total += proc[i];
|
|
}
|
|
|
|
table_total = 0;
|
|
for (i in table) {
|
|
table_total += table[i];
|
|
}
|
|
|
|
for (i in proc) {
|
|
printf("proc %-15s %20d %20.2f%%\n",
|
|
i, proc[i], (100 * proc[i]) / proc_total);
|
|
}
|
|
|
|
printf("\n");
|
|
for (i in table) {
|
|
printf("table %-15s %20d %20.2f%%\n",
|
|
i, table[i], (100 * table[i]) / table_total);
|
|
}
|
|
}
|