/************************************************************************/ /* */ /* Produces a nice formatted summary of execution times gathered by */ /* the account() routine. */ /* */ /* Inputs: t_acc Array of structures with times */ /* nseg # of program segments in t_acc */ /* buf tms struct from times() call */ /* real elapsed real time to this point */ /* time_unit 10 millisec on HP735 */ /* */ /* Output: Screen output summary of times used */ /* */ /* Created January 13 1994 by CJL */ /* */ /************************************************************************/ #include #include #include #include "account.h" #include "math.h" #include "mk4_util.h" static double wall_clock = 0.0; void report_wallclock(int npass, int totpass) { msg ("Wallclock %g on %d passes %d total", 3, wall_clock, npass, totpass); msg ("Estimate %g seconds for total processing time", 3, (double)(totpass) * wall_clock / (double)npass); } int report_times(struct time_account *t_acc, int nseg, struct tms *buf, int real, double time_unit) { size_t max_len, i, j, total_calls, len; char line[101]; double total_real, total_user, total_system; double acc_user, acc_system, acc_real; static int called = FALSE; wall_clock = 0.0; /* Should be called only once */ if (called) { msg ("Tried to do accounting report multiple times", 3); return (1); } /* Find longest string */ max_len = 15; /* title */ for (i = 0; i < nseg; i++) if (t_acc[i].namlen > max_len) max_len = t_acc[i].namlen; /* Do title */ msg ("", 3); msg ("Time usage summary (all times are in seconds)", 3); for (j=0; jtms_utime * time_unit - total_user; acc_system = buf->tms_stime * time_unit - total_system; acc_real = real * time_unit - total_real; for (j=0; jtms_utime * time_unit, buf->tms_stime * time_unit, wall_clock); msg ("%s", 3, line); msg ("", 3); called = TRUE; return (0); }