on master help sign in
RTS stats: fix case then elapsed time is zero.
b029400Sam T
rts/idris_stats.c+19−4
@@ -9,8 +9,23 @@ void print_stats(const Stats * stats) {
9 clock_t total = clock() - stats->start_time;
9 clock_t total = clock() - stats->start_time;
10 clock_t mut = total - stats->init_time - stats->gc_time - stats->exit_time;
10 clock_t mut = total - stats->init_time - stats->gc_time - stats->exit_time;
11 double mut_sec = (double)mut / CLOCKS_PER_SEC;
11 double mut_sec = (double)mut / CLOCKS_PER_SEC;
12+
13+ int avg_chunk = 0;
14+ if (stats->alloc_count > 0) {
12− int avg_chunk = (int)((double)stats->allocations / (double)stats->alloc_count);
15+ avg_chunk = (int)((double)stats->allocations / (double)stats->alloc_count);
16+ }
17+
18+ int alloc_rate = 0;
19+ if (mut > 0) {
13− int alloc_rate = (int)((double)(stats->allocations) / mut_sec);
20+ alloc_rate = (int)((double)(stats->allocations) / mut_sec);
21+ }
22+
23+ double gc_percent = 0.0d;
24+ double productivity = 0.0d;
25+ if (total > 0) {
26+ gc_percent = 100 * (double)stats->gc_time / (double)total;
27+ productivity = 100 * ((double)mut / (double)total);
28+ }
14
29
15 setlocale(LC_NUMERIC, "");
30 setlocale(LC_NUMERIC, "");
16 printf("\n");
31 printf("\n");
@@ -28,11 +43,11 @@ void print_stats(const Stats * stats) {
28 printf("EXIT time: %8.3fs\n", (double)stats->exit_time / CLOCKS_PER_SEC);
43 printf("EXIT time: %8.3fs\n", (double)stats->exit_time / CLOCKS_PER_SEC);
29 printf("TOTAL time: %8.3fs\n\n", (double)total / CLOCKS_PER_SEC);
44 printf("TOTAL time: %8.3fs\n\n", (double)total / CLOCKS_PER_SEC);
30
45
31− printf("%%GC time: %.2f%%\n\n", 100 * (double)stats->gc_time / (double)total);
46+ printf("%%GC time: %.2f%%\n\n", gc_percent);
32
47
33 printf("Alloc rate %'d bytes per MUT sec\n\n", alloc_rate);
48 printf("Alloc rate %'d bytes per MUT sec\n\n", alloc_rate);
34
49
35− printf("Productivity %.2f%%\n", 100 * ((double)mut / (double)total));
50+ printf("Productivity %.2f%%\n", productivity);
36}
51}
37
52
38void aggregate_stats(Stats * stats1, const Stats * stats2) {
53void aggregate_stats(Stats * stats1, const Stats * stats2) {