about summary refs log tree commit diff
path: root/benchtests/Makefile
diff options
context:
space:
mode:
authorWill Newton <will.newton@linaro.org>2014-04-08 10:18:16 +0100
committerWill Newton <will.newton@linaro.org>2014-04-11 16:05:03 +0100
commit970c602aa60bb29845c445c18d7b20f7c4552b78 (patch)
tree734a1f22c1c51cf3cd9d8c94e42a0f0e4a41ab5a /benchtests/Makefile
parent36875b06e0ed7f137190b9228bef553adfc338ba (diff)
downloadglibc-970c602aa60bb29845c445c18d7b20f7c4552b78.tar.gz
glibc-970c602aa60bb29845c445c18d7b20f7c4552b78.tar.xz
glibc-970c602aa60bb29845c445c18d7b20f7c4552b78.zip
benchtests: Improve readability of JSON output
Add a small library to print JSON values and use it to improve the
readability of the benchmark output and the readability of the
benchmark code.

ChangeLog:

2014-04-11  Will Newton  <will.newton@linaro.org>

	* benchtests/Makefile (extra-objs): Add json-lib.o.
	(bench-func): Tidy up JSON output.
	* benchtests/bench-skeleton.c: Include json-lib.h.
	(main): Use JSON library functions to do output of
	benchmark results.
	* benchtests/bench-timing-type.c (main): Output the
	timing type simply, leaving formatting to the user.
	* benchtests/json-lib.c: New file.
	* benchtests/json-lib.h: Likewise.
Diffstat (limited to 'benchtests/Makefile')
-rw-r--r--benchtests/Makefile13
1 files changed, 8 insertions, 5 deletions
diff --git a/benchtests/Makefile b/benchtests/Makefile
index 6e3f86bbe8..4989794026 100644
--- a/benchtests/Makefile
+++ b/benchtests/Makefile
@@ -101,6 +101,8 @@ cpp-srcs-left := $(binaries-benchset:=.c) $(binaries-bench:=.c)
 lib := nonlib
 include $(patsubst %,$(..)cppflags-iterator.mk,$(cpp-srcs-left))
 
+extra-objs += json-lib.o
+
 bench-deps := bench-skeleton.c bench-timing.h Makefile
 
 run-bench = $(test-wrapper-env) \
@@ -127,9 +129,9 @@ bench-set: $(binaries-benchset)
 # so one could even execute them individually and process it using any JSON
 # capable language or tool.
 bench-func: $(binaries-bench)
-	{ echo "{"; \
-	$(timing-type); \
-	echo "  ,\"functions\": {"; \
+	{ timing_type=$$($(timing-type)); \
+	echo "{\"timing_type\": \"$${timing_type}\","; \
+	echo " \"functions\": {"; \
 	for run in $^; do \
 	  if ! [ "x$${run}" = "x$<" ]; then \
 	    echo ","; \
@@ -137,14 +139,15 @@ bench-func: $(binaries-bench)
 	  echo "Running $${run}" >&2; \
 	  $(run-bench) $(DETAILED_OPT); \
 	done; \
-	echo "  }"; \
+	echo; \
+	echo " }"; \
 	echo "}"; } > $(objpfx)bench.out-tmp; \
 	if [ -f $(objpfx)bench.out ]; then \
 	  mv -f $(objpfx)bench.out $(objpfx)bench.out.old; \
 	fi; \
 	mv -f $(objpfx)bench.out-tmp $(objpfx)bench.out
 
-$(timing-type) $(binaries-bench) $(binaries-benchset): %: %.o \
+$(timing-type) $(binaries-bench) $(binaries-benchset): %: %.o $(objpfx)json-lib.o \
   $(sort $(filter $(common-objpfx)lib%,$(link-libc))) \
   $(addprefix $(csu-objpfx),start.o) $(+preinit) $(+postinit)
 	$(+link)