aboutsummaryrefslogtreecommitdiff
path: root/benchtests/json-lib.c
diff options
context:
space:
mode:
authorSiddhesh Poyarekar <siddhesh@sourceware.org>2017-06-22 23:44:12 +0530
committerSiddhesh Poyarekar <siddhesh@sourceware.org>2017-06-22 23:44:12 +0530
commit738a9914a066a31750925543a8c6d2661bd61345 (patch)
tree9f4f46ad9eaa092269ebb3a94b4a87a54bfeaf64 /benchtests/json-lib.c
parent5070551cbf0ba8f69e15e1a19f8989b812b6a651 (diff)
downloadglibc-738a9914a066a31750925543a8c6d2661bd61345.zip
glibc-738a9914a066a31750925543a8c6d2661bd61345.tar.gz
glibc-738a9914a066a31750925543a8c6d2661bd61345.tar.bz2
benchtests: Print string array elements, int and uint in json
Enhance the json module in benchtests to print signed and unsigned integers and string array elements. * benchtests/json-lib.h: Include inttypes.h. (json_attr_int, json_attr_int, json_element_string, json_element_int, json_element_uint): New functions. * benchtests/json-lib.c: (json_attr_int, json_attr_int, json_element_string, json_element_int, json_element_uint): New functions.
Diffstat (limited to 'benchtests/json-lib.c')
-rw-r--r--benchtests/json-lib.c62
1 files changed, 62 insertions, 0 deletions
diff --git a/benchtests/json-lib.c b/benchtests/json-lib.c
index 61573c5..9743506 100644
--- a/benchtests/json-lib.c
+++ b/benchtests/json-lib.c
@@ -101,6 +101,32 @@ json_attr_string (json_ctx_t *ctx, const char *name, const char *s)
}
void
+json_attr_uint (json_ctx_t *ctx, const char *name, uint64_t d)
+{
+ if (!ctx->first_element)
+ fprintf (ctx->fp, ",\n");
+ else
+ ctx->first_element = false;
+
+ do_indent (ctx);
+
+ fprintf (ctx->fp, "\"%s\": %" PRIu64 , name, d);
+}
+
+void
+json_attr_int (json_ctx_t *ctx, const char *name, int64_t d)
+{
+ if (!ctx->first_element)
+ fprintf (ctx->fp, ",\n");
+ else
+ ctx->first_element = false;
+
+ do_indent (ctx);
+
+ fprintf (ctx->fp, "\"%s\": %" PRId64 , name, d);
+}
+
+void
json_attr_double (json_ctx_t *ctx, const char *name, double d)
{
if (!ctx->first_element)
@@ -137,6 +163,42 @@ json_array_end (json_ctx_t *ctx)
}
void
+json_element_string (json_ctx_t *ctx, const char *s)
+{
+ if (!ctx->first_element)
+ fprintf (ctx->fp, ", \"%s\"", s);
+ else
+ {
+ fprintf (ctx->fp, "\"%s\"", s);
+ ctx->first_element = false;
+ }
+}
+
+void
+json_element_uint (json_ctx_t *ctx, uint64_t d)
+{
+ if (!ctx->first_element)
+ fprintf (ctx->fp, ", %" PRIu64, d);
+ else
+ {
+ fprintf (ctx->fp, "%" PRIu64, d);
+ ctx->first_element = false;
+ }
+}
+
+void
+json_element_int (json_ctx_t *ctx, int64_t d)
+{
+ if (!ctx->first_element)
+ fprintf (ctx->fp, ", %" PRId64, d);
+ else
+ {
+ fprintf (ctx->fp, "%" PRId64, d);
+ ctx->first_element = false;
+ }
+}
+
+void
json_element_double (json_ctx_t *ctx, double d)
{
if (!ctx->first_element)