Files
mercury/tools/file_name_translation_stats
Zoltan Somogyi 9adcbd9840 Improve infrastructure for file name translations.
compiler/file_names.m:
    Document the meaning of the maybe_create_dirs and maybe_search types.

    Delete long-obsolete references to .il files.

compiler/make.util.m:
    Rename make_remove_target_file to remove_make_target_file, since this
    predicate removes target files in Makefiles, and does not "make" anything.
    Rename several other predicates in a similar manner, for the same reason.

    Add an extra argument to get_file_name and some related predicates
    that will allow future conditionally-enabled trace goals in the compiler
    to track where the requests for file name translations come from.

compiler/write_deps_file.m:
    Factor out some code.

compiler/make.dependencies.m:
compiler/make.module_dep_file.m:
compiler/make.module_target.m:
compiler/make.program_target.m:
    Conform to the changes above.

tools/file_name_translation_stats:
    Allow for large numbers of file name translations.
2023-05-31 10:14:31 +02:00

53 lines
1.8 KiB
Awk
Executable File

#!/usr/bin/awk -f
# vim: ft=awk ts=4 sw=4 et
$1 == "overall_stats" {
num_invocations += 1;
overall_count += $2;
overall_sum += $3;
}
$1 == "ext" {
ext = $4;
ext_count[ext] += $2;
ext_sum[ext] += $3;
}
$1 == "ext_sch_dir" {
esd = $4;
esd_count[esd] += $2;
esd_sum[esd] += $3;
}
END {
printf "number of compiler invocations: %10d\n", num_invocations;
printf "number of file name lookups: %10d\n", overall_sum;
printf "number of file name unique results: %10d\n", overall_count;
printf "number of lookups per unique result: %10.4f\n\n",
(overall_sum + 0.0) / overall_count;
printf "----------------------------------------------------------\n\n";
num_exts = asorti(ext_count, ext_sort_keys);
for (i = 1; i <= num_exts; i++) {
e = ext_sort_keys[i];
printf "ext %-32s lookups: %8d\n",
e, ext_sum[e];
printf "ext %-32s unique results: %8d\n",
e, ext_count[e];
printf "ext %-32s lookups per unique result: %8.2f\n\n",
e, (ext_sum[e] + 0.0) / ext_count[e];
}
printf "----------------------------------------------------------\n\n";
num_esds = asorti(esd_count, esd_sort_keys);
for (i = 1; i <= num_esds; i++) {
e = esd_sort_keys[i];
printf "esd %-32s lookups: %8d\n",
e, esd_sum[e];
printf "esd %-32s unique results: %8d\n",
e, esd_count[e];
printf "esd %-32s lookups per unique result: %8.2f\n\n",
e, (esd_sum[e] + 0.0) / esd_count[e];
}
}