[m-dev.] for review: proc_stats
Zoltan Somogyi
zs at cs.mu.OZ.AU
Wed Jan 10 16:41:58 AEDT 2001
Add a proc_stats command to mdb.
trace/mercury_trace_tables.[ch]:
Add a function for printing statistics about procedure layout
structures.
Print out percentages both for proc_stats and for the old label_stats
command.
trace/mercury_trace_internal.c:
Add code to recognize the proc_stats command.
doc/user_guide.texi:
Document the proc_stats command.
doc/mdb_categories:
Include the proc_stats command in the list of developer commands.
Zoltan.
cvs diff: Diffing doc
Index: doc/mdb_categories
===================================================================
RCS file: /home/mercury1/repository/mercury/doc/mdb_categories,v
retrieving revision 1.9
diff -u -b -r1.9 mdb_categories
--- doc/mdb_categories 2001/01/09 04:09:23 1.9
+++ doc/mdb_categories 2001/01/10 05:29:53
@@ -56,8 +56,8 @@
document_category 900 developer
developer - Commands that are intended to be of use only to developers
of the Mercury implementation. The developer commands are
- `nondet_stack', `stack_regs', `all_regs', `table_io' and
- `label_stats'.
+ `nondet_stack', `stack_regs', `all_regs', `table_io',
+ `proc_stats' and `label_stats'.
end
document_category 1000 misc
Index: doc/user_guide.texi
===================================================================
RCS file: /home/mercury1/repository/mercury/doc/user_guide.texi,v
retrieving revision 1.231
diff -u -b -r1.231 user_guide.texi
--- doc/user_guide.texi 2001/01/09 04:09:23 1.231
+++ doc/user_guide.texi 2001/01/09 12:18:58
@@ -2441,6 +2441,13 @@
@item table_io end
Tells the debugger to stop tabling I/O actions.
@sp 1
+ at item proc_stats
+Prints statistics about proc layout structures in the program.
+ at sp 1
+ at item proc_stats @var{filename}
+Prints statistics about proc layout structures in the program
+to the file @var{filename}.
+ at sp 1
@item label_stats
Prints statistics about label layout structures in the program.
@sp 1
cvs diff: Diffing trace
Index: trace/mercury_trace_internal.c
===================================================================
RCS file: /home/mercury1/repository/mercury/trace/mercury_trace_internal.c,v
retrieving revision 1.92
diff -u -b -r1.92 mercury_trace_internal.c
--- trace/mercury_trace_internal.c 2001/01/09 04:10:03 1.92
+++ trace/mercury_trace_internal.c 2001/01/09 12:18:22
@@ -1958,6 +1958,26 @@
} else {
MR_trace_usage("developer", "label_stats");
}
+ } else if (streq(words[0], "proc_stats")) {
+ if (word_count == 1) {
+ MR_proc_layout_stats(MR_mdb_out);
+ } else if (word_count == 2) {
+ FILE *fp;
+
+ fp = fopen(words[1], "w");
+ if (fp == NULL) {
+ fflush(MR_mdb_out);
+ fprintf(MR_mdb_err,
+ "mdb: error opening `%s': %s.\n",
+ words[1], strerror(errno));
+ return KEEP_INTERACTING;
+ }
+
+ MR_proc_layout_stats(fp);
+ (void) fclose(fp);
+ } else {
+ MR_trace_usage("developer", "label_stats");
+ }
} else if (streq(words[0], "source")) {
bool ignore_errors;
@@ -3054,6 +3074,7 @@
{ "developer", "stack_regs" },
{ "developer", "all_regs" },
{ "developer", "table_io" },
+ { "developer", "proc_stats" },
{ "developer", "label_stats" },
{ "misc", "source" },
{ "misc", "save" },
Index: trace/mercury_trace_tables.c
===================================================================
RCS file: /home/mercury1/repository/mercury/trace/mercury_trace_tables.c,v
retrieving revision 1.13
diff -u -b -r1.13 mercury_trace_tables.c
--- trace/mercury_trace_tables.c 2001/01/09 04:10:04 1.13
+++ trace/mercury_trace_tables.c 2001/01/10 01:14:03
@@ -14,6 +14,7 @@
#include "mercury_imp.h"
#include "mercury_label.h"
#include "mercury_array_macros.h"
+#include "mercury_stack_trace.h"
#include "mercury_trace_tables.h"
#include "mercury_trace.h"
@@ -438,6 +439,50 @@
}
void
+MR_proc_layout_stats(FILE *fp)
+{
+ const MR_Module_Layout *module_layout;
+ const MR_Stack_Layout_Entry *proc_layout;
+ int module_num, proc_num;
+ MR_Determinism detism;
+ int total;
+ int histogram[MR_DETISM_MAX + 1];
+
+ total = 0;
+ for (detism = 0; detism <= MR_DETISM_MAX; detism++) {
+ histogram[detism] = 0;
+ }
+
+ for (module_num = 0; module_num < MR_module_info_next; module_num++) {
+ module_layout = MR_module_infos[module_num];
+
+ for (proc_num = 0;
+ proc_num < module_layout->MR_ml_proc_count;
+ proc_num++)
+ {
+ proc_layout = module_layout->MR_ml_procs[proc_num];
+
+ total++;
+ if (0 <= proc_layout->MR_sle_detism &&
+ proc_layout->MR_sle_detism <= MR_DETISM_MAX)
+ {
+ histogram[proc_layout->MR_sle_detism]++;
+ }
+ }
+ }
+
+ for (detism = 0; detism <= MR_DETISM_MAX; detism++) {
+ if (histogram[detism] > 0) {
+ fprintf(fp, "%-10s %10d (%5.2f%%)\n",
+ MR_detism_names[detism],
+ histogram[detism],
+ ((float) 100 * histogram[detism]) / total);
+ }
+ }
+ fprintf(fp, "%-10s %10d\n", "all ", total);
+}
+
+void
MR_label_layout_stats(FILE *fp)
{
const MR_Module_Layout *module_layout;
@@ -482,9 +527,10 @@
}
for (port = 0; port < MR_PORT_NUM_PORTS; port++) {
- fprintf(fp, "%4s %10d\n",
+ fprintf(fp, "%4s %10d (%5.2f%%)\n",
MR_port_names[port],
- histogram[port]);
+ histogram[port],
+ ((float) 100 * histogram[port]) / total);
}
fprintf(fp, "%s %10d\n", "all ", total);
}
Index: trace/mercury_trace_tables.h
===================================================================
RCS file: /home/mercury1/repository/mercury/trace/mercury_trace_tables.h,v
retrieving revision 1.8
diff -u -b -r1.8 mercury_trace_tables.h
--- trace/mercury_trace_tables.h 2001/01/09 04:10:04 1.8
+++ trace/mercury_trace_tables.h 2001/01/09 12:15:06
@@ -147,6 +147,13 @@
const MR_Stack_Layout_Entry *entry);
/*
+** MR_proc_layout_stats(fp):
+** Prints statistics about the proc layout structures of the program.
+*/
+
+extern void MR_proc_layout_stats(FILE *fp);
+
+/*
** MR_label_layout_stats(fp):
** Prints statistics about the label layout structures of the program.
*/
--------------------------------------------------------------------------
mercury-developers mailing list
Post messages to: mercury-developers at cs.mu.oz.au
Administrative Queries: owner-mercury-developers at cs.mu.oz.au
Subscriptions: mercury-developers-request at cs.mu.oz.au
--------------------------------------------------------------------------
More information about the developers
mailing list