diff options
author | Siddhesh Poyarekar <siddhesh@redhat.com> | 2014-03-29 09:40:19 +0530 |
---|---|---|
committer | Siddhesh Poyarekar <siddhesh@redhat.com> | 2014-03-29 09:40:19 +0530 |
commit | 56737508002f1759da8d4d9944a8e98e58dce917 (patch) | |
tree | 25105d29ef08035127c492424c545a3b3c04634f /benchtests/bench-skeleton.c | |
parent | cb5e4aada7f044fc029dd64b31411a23bb09c287 (diff) | |
download | glibc-56737508002f1759da8d4d9944a8e98e58dce917.tar.gz glibc-56737508002f1759da8d4d9944a8e98e58dce917.tar.xz glibc-56737508002f1759da8d4d9944a8e98e58dce917.zip |
Detailed benchmark outputs for functions
This patch adds an option to get detailed benchmark output for functions. Invoking the benchmark with 'make DETAILED=1 bench' causes each benchmark program to store a mean execution time for each input it works on. This is useful to give a more comprehensive picture of performance of functions compared to just the single mean figure.
Diffstat (limited to 'benchtests/bench-skeleton.c')
-rw-r--r-- | benchtests/bench-skeleton.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/benchtests/bench-skeleton.c b/benchtests/bench-skeleton.c index faef7ebf9a..0c7d7440cc 100644 --- a/benchtests/bench-skeleton.c +++ b/benchtests/bench-skeleton.c @@ -18,6 +18,7 @@ #include <string.h> #include <stdint.h> +#include <stdbool.h> #include <stdio.h> #include <time.h> #include <inttypes.h> @@ -48,6 +49,10 @@ main (int argc, char **argv) unsigned long i, k; struct timespec runtime; timing_t start, end; + bool detailed = false; + + if (argc == 2 && !strcmp (argv[1], "-d")) + detailed = true; startup(); @@ -72,6 +77,7 @@ main (int argc, char **argv) double d_total_i = 0; timing_t total = 0, max = 0, min = 0x7fffffffffffffff; + int64_t c = 0; while (1) { for (i = 0; i < NUM_SAMPLES (v); i++) @@ -91,8 +97,13 @@ main (int argc, char **argv) min = cur; TIMING_ACCUM (total, cur); + /* Accumulate timings for the value. In the end we will divide + by the total iterations. */ + RESULT_ACCUM (cur, v, i, c * iters, (c + 1) * iters); + d_total_i += iters; } + c++; struct timespec curtime; memset (&curtime, 0, sizeof (curtime)); @@ -114,6 +125,17 @@ main (int argc, char **argv) d_total_s, d_total_i, max / d_iters, min / d_iters, d_total_s / d_total_i); + if (detailed) + { + printf (",\n\"timings\": ["); + for (int i = 0; i < NUM_SAMPLES (v); i++) + { + if (i > 0) + putc (',', stdout); + printf ("%g", RESULT (v, i)); + } + puts ("]"); + } puts ("}"); } |