From cb5e4aada7f044fc029dd64b31411a23bb09c287 Mon Sep 17 00:00:00 2001 From: Siddhesh Poyarekar Date: Sat, 29 Mar 2014 09:37:44 +0530 Subject: Make bench.out in json format This patch changes the output format of the main benchmark output file (bench.out) to an extensible format. I chose JSON over XML because in addition to being extensible, it is also not too verbose. Additionally it has good support in python. The significant change I have made in terms of functionality is to put timing information as an attribute in JSON instead of a string and to do that, there is a separate program that prints out a JSON snippet mentioning the type of timing (hp_timing or clock_gettime). The mean timing has now changed from iterations per unit to actual timing per iteration. --- benchtests/bench-skeleton.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) (limited to 'benchtests/bench-skeleton.c') diff --git a/benchtests/bench-skeleton.c b/benchtests/bench-skeleton.c index 4290e76..faef7eb 100644 --- a/benchtests/bench-skeleton.c +++ b/benchtests/bench-skeleton.c @@ -59,8 +59,13 @@ main (int argc, char **argv) iters = 1000 * res; + /* Begin function. */ + printf ("\"%s\": {\n", FUNCNAME); + for (int v = 0; v < NUM_VARIANTS; v++) { + if (v) + putc (',', stdout); /* Run for approximately DURATION seconds. */ clock_gettime (CLOCK_MONOTONIC_RAW, &runtime); runtime.tv_sec += DURATION; @@ -86,7 +91,6 @@ main (int argc, char **argv) min = cur; TIMING_ACCUM (total, cur); - d_total_i += iters; } struct timespec curtime; @@ -104,9 +108,17 @@ main (int argc, char **argv) d_total_s = total; d_iters = iters; - TIMING_PRINT_STATS (VARIANT (v), d_total_s, d_iters, d_total_i, max, - min); + printf ("\"%s\": {\n", VARIANT (v)); + printf ("\"duration\": %g, \"iterations\": %g, " + "\"max\": %g, \"min\": %g, \"mean\": %g\n", + d_total_s, d_total_i, max / d_iters, min / d_iters, + d_total_s / d_total_i); + + puts ("}"); } + /* End function. */ + puts ("}"); + return 0; } -- cgit v1.1