From cb5e4aada7f044fc029dd64b31411a23bb09c287 Mon Sep 17 00:00:00 2001 From: Siddhesh Poyarekar Date: Sat, 29 Mar 2014 09:37:44 +0530 Subject: Make bench.out in json format This patch changes the output format of the main benchmark output file (bench.out) to an extensible format. I chose JSON over XML because in addition to being extensible, it is also not too verbose. Additionally it has good support in python. The significant change I have made in terms of functionality is to put timing information as an attribute in JSON instead of a string and to do that, there is a separate program that prints out a JSON snippet mentioning the type of timing (hp_timing or clock_gettime). The mean timing has now changed from iterations per unit to actual timing per iteration. --- benchtests/Makefile | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) (limited to 'benchtests/Makefile') diff --git a/benchtests/Makefile b/benchtests/Makefile index b331d1a579..be1170851d 100644 --- a/benchtests/Makefile +++ b/benchtests/Makefile @@ -98,11 +98,14 @@ run-bench = $(test-wrapper-env) \ GCONV_PATH=$(common-objpfx)iconvdata LC_ALL=C \ $($*-ENV) $(rtld-prefix) $${run} +timing-type := $(objpfx)bench-timing-type + bench-clean: rm -f $(binaries-bench) $(addsuffix .o,$(binaries-bench)) rm -f $(binaries-benchset) $(addsuffix .o,$(binaries-benchset)) + rm -f $(timing-type) $(addsuffix .o,$(timing-type)) -bench: bench-set bench-func +bench: $(timing-type) bench-set bench-func bench-set: $(binaries-benchset) for run in $^; do \ @@ -110,17 +113,29 @@ bench-set: $(binaries-benchset) $(run-bench) > $${run}.out; \ done +# Build and execute the benchmark functions. This target generates JSON +# formatted bench.out. Each of the programs produce independent JSON output, +# so one could even execute them individually and process it using any JSON +# capable language or tool. bench-func: $(binaries-bench) - { for run in $^; do \ + { echo "{"; \ + $(timing-type); \ + echo " ,\"functions\": {"; \ + for run in $^; do \ + if ! [ "x$${run}" = "x$<" ]; then \ + echo ","; \ + fi; \ echo "Running $${run}" >&2; \ $(run-bench); \ - done; } > $(objpfx)bench.out-tmp; \ + done; \ + 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 -$(binaries-bench) $(binaries-benchset): %: %.o \ +$(timing-type) $(binaries-bench) $(binaries-benchset): %: %.o \ $(sort $(filter $(common-objpfx)lib%,$(link-libc))) \ $(addprefix $(csu-objpfx),start.o) $(+preinit) $(+postinit) $(+link) -- cgit 1.4.1