public inbox for glibc-cvs@sourceware.org
help / color / mirror / Atom feed
* [glibc] benchtests: Use JSON for bench-rawmemchr output
@ 2021-05-17 14:16 Matheus Castanho
0 siblings, 0 replies; only message in thread
From: Matheus Castanho @ 2021-05-17 14:16 UTC (permalink / raw)
To: glibc-cvs
https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=f4605e611a93891b1fdf8d0f48b3fba0d572f1ad
commit f4605e611a93891b1fdf8d0f48b3fba0d572f1ad
Author: Matheus Castanho <msc@linux.ibm.com>
Date: Wed May 12 11:27:16 2021 -0300
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>
Diff:
---
benchtests/bench-rawmemchr.c | 54 ++++++++++++++++++++++++++++++++------------
1 file 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;
}
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2021-05-17 14:16 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-17 14:16 [glibc] benchtests: Use JSON for bench-rawmemchr output Matheus Castanho
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).