diff options
author | Matheus Castanho <msc@linux.ibm.com> | 2021-05-12 11:27:16 -0300 |
---|---|---|
committer | Matheus Castanho <msc@linux.ibm.com> | 2021-05-17 11:10:19 -0300 |
commit | f4605e611a93891b1fdf8d0f48b3fba0d572f1ad (patch) | |
tree | e39cd08d02cd54e4b0daf3cbcf14de372d39b6b7 /benchtests | |
parent | 1a594aa986ffe28657a03baa5c53c0a0e7dc2ecd (diff) | |
download | glibc-f4605e611a93891b1fdf8d0f48b3fba0d572f1ad.tar.gz glibc-f4605e611a93891b1fdf8d0f48b3fba0d572f1ad.tar.xz glibc-f4605e611a93891b1fdf8d0f48b3fba0d572f1ad.zip |
benchtests: Use JSON for bench-rawmemchr output
Convert the output of benchtests/bench-rawmemchr to JSON like other string benchmarks. This makes the output more parseable and allows usage of compare_strings.py, for example. Reviewed-by: Lucas A. M. Magalhaes <lamm@linux.ibm.com>
Diffstat (limited to 'benchtests')
-rw-r--r-- | benchtests/bench-rawmemchr.c | 54 |
1 files changed, 39 insertions, 15 deletions
diff --git a/benchtests/bench-rawmemchr.c b/benchtests/bench-rawmemchr.c index 93b4a1ea38..80286b04b0 100644 --- a/benchtests/bench-rawmemchr.c +++ b/benchtests/bench-rawmemchr.c @@ -23,6 +23,8 @@ #define TEST_NAME "rawmemchr" #include "bench-string.h" +#include "json-lib.h" + typedef char *(*proto_t) (const char *, int); char * @@ -37,7 +39,7 @@ IMPL (rawmemchr, 1) IMPL (generic_rawmemchr, 0) static void -do_one_test (impl_t *impl, const char *s, int c, char *exp_res) +do_one_test (json_ctx_t *json_ctx, impl_t *impl, const char *s, int c, char *exp_res) { size_t i, iters = INNER_LOOP_ITERS_LARGE * 4; timing_t start, stop, cur; @@ -59,11 +61,11 @@ do_one_test (impl_t *impl, const char *s, int c, char *exp_res) TIMING_DIFF (cur, start, stop); - TIMING_PRINT_MEAN ((double) cur, (double) iters); + json_element_double (json_ctx, (double) cur / (double) iters); } static void -do_test (size_t align, size_t pos, size_t len, int seek_char) +do_test (json_ctx_t *json_ctx, size_t align, size_t pos, size_t len, int seek_char) { size_t i; char *result; @@ -86,39 +88,61 @@ do_test (size_t align, size_t pos, size_t len, int seek_char) buf1[align + len] = -seek_char; result = (char *) (buf1 + align + pos); - printf ("Length %4zd, alignment %2zd:", pos, align); + json_element_object_begin (json_ctx); + json_attr_uint (json_ctx, "length", pos); + json_attr_uint (json_ctx, "alignment", align); + json_attr_uint (json_ctx, "char", seek_char); + json_array_begin (json_ctx, "timings"); FOR_EACH_IMPL (impl, 0) - do_one_test (impl, (char *) (buf1 + align), seek_char, result); + do_one_test (json_ctx, impl, (char *) (buf1 + align), seek_char, result); - putchar ('\n'); + json_array_end (json_ctx); + json_element_object_end (json_ctx); } int test_main (void) { + json_ctx_t json_ctx; size_t i; test_init (); - printf ("%20s", ""); + json_init (&json_ctx, 0, stdout); + + json_document_begin (&json_ctx); + json_attr_string (&json_ctx, "timing_type", TIMING_TYPE); + + json_attr_object_begin (&json_ctx, "functions"); + json_attr_object_begin (&json_ctx, TEST_NAME); + json_attr_string (&json_ctx, "bench-variant", ""); + + json_array_begin (&json_ctx, "ifuncs"); FOR_EACH_IMPL (impl, 0) - printf ("\t%s", impl->name); - putchar ('\n'); + json_element_string (&json_ctx, impl->name); + json_array_end (&json_ctx); + + json_array_begin (&json_ctx, "results"); for (i = 1; i < 7; ++i) { - do_test (0, 16 << i, 2048, 23); - do_test (i, 64, 256, 23); - do_test (0, 16 << i, 2048, 0); - do_test (i, 64, 256, 0); + do_test (&json_ctx, 0, 16 << i, 2048, 23); + do_test (&json_ctx, i, 64, 256, 23); + do_test (&json_ctx, 0, 16 << i, 2048, 0); + do_test (&json_ctx, i, 64, 256, 0); } for (i = 1; i < 32; ++i) { - do_test (0, i, i + 1, 23); - do_test (0, i, i + 1, 0); + do_test (&json_ctx, 0, i, i + 1, 23); + do_test (&json_ctx, 0, i, i + 1, 0); } + json_array_end (&json_ctx); + json_attr_object_end (&json_ctx); + json_attr_object_end (&json_ctx); + json_document_end (&json_ctx); + return ret; } |