about summary refs log tree commit diff
path: root/benchtests/Makefile
diff options
context:
space:
mode:
authorWill Newton <will.newton@linaro.org>2013-09-11 15:47:12 +0100
committerWill Newton <will.newton@linaro.org>2014-11-05 14:13:00 +0000
commitb01ee67cb5860d70e5a88af3c25b44d1ecaf0579 (patch)
treed321a77c0c5f62eb965785a608622d6149edf9fb /benchtests/Makefile
parentbe9d4ccc7fe62751db1a5fdcb31958561dbbda9a (diff)
downloadglibc-b01ee67cb5860d70e5a88af3c25b44d1ecaf0579.tar.gz
glibc-b01ee67cb5860d70e5a88af3c25b44d1ecaf0579.tar.xz
glibc-b01ee67cb5860d70e5a88af3c25b44d1ecaf0579.zip
benchtests: Add malloc microbenchmark
Add a microbenchmark for measuring malloc and free performance with
varying numbers of threads. The benchmark allocates and frees buffers
of random sizes in a random order and measures the overall execution
time and RSS. Variants of the benchmark are run with 1, 8, 16 and
32 threads.

The random block sizes used follow an inverse square distribution
which is intended to mimic the behaviour of real applications which
tend to allocate many more small blocks than large ones.

ChangeLog:

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

	* benchtests/Makefile: (bench-malloc): Add malloc thread
	scalability benchmark.
	* benchtests/bench-malloc-threads.c: New file.
Diffstat (limited to 'benchtests/Makefile')
-rw-r--r--benchtests/Makefile20
1 files changed, 17 insertions, 3 deletions
diff --git a/benchtests/Makefile b/benchtests/Makefile
index fd3036db93..78fd48f14a 100644
--- a/benchtests/Makefile
+++ b/benchtests/Makefile
@@ -44,8 +44,11 @@ benchset := $(string-bench-all) $(stdlib-bench)
 CFLAGS-bench-ffs.c += -fno-builtin
 CFLAGS-bench-ffsll.c += -fno-builtin
 
+bench-malloc := malloc-thread
+
 $(addprefix $(objpfx)bench-,$(bench-math)): $(libm)
 $(addprefix $(objpfx)bench-,$(bench-pthread)): $(shared-thread-library)
+$(objpfx)bench-malloc-thread: $(shared-thread-library)
 
 
 
@@ -60,6 +63,7 @@ include ../Rules
 
 binaries-bench := $(addprefix $(objpfx)bench-,$(bench))
 binaries-benchset := $(addprefix $(objpfx)bench-,$(benchset))
+binaries-bench-malloc := $(addprefix $(objpfx)bench-,$(bench-malloc))
 
 # The default duration: 10 seconds.
 ifndef BENCH_DURATION
@@ -82,7 +86,8 @@ endif
 
 # This makes sure CPPFLAGS-nonlib and CFLAGS-nonlib are passed
 # for all these modules.
-cpp-srcs-left := $(binaries-benchset:=.c) $(binaries-bench:=.c)
+cpp-srcs-left := $(binaries-benchset:=.c) $(binaries-bench:=.c) \
+		 $(binaries-bench-malloc:=.c)
 lib := nonlib
 include $(patsubst %,$(..)cppflags-iterator.mk,$(cpp-srcs-left))
 
@@ -99,9 +104,10 @@ 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 $(binaries-bench-malloc) $(addsuffix .o,$(binaries-bench-malloc))
 	rm -f $(timing-type) $(addsuffix .o,$(timing-type))
 
-bench: $(timing-type) bench-set bench-func
+bench: $(timing-type) bench-set bench-func bench-malloc
 
 bench-set: $(binaries-benchset)
 	for run in $^; do \
@@ -109,6 +115,13 @@ bench-set: $(binaries-benchset)
 	  $(run-bench) > $${run}.out; \
 	done
 
+bench-malloc: $(binaries-bench-malloc)
+	run=$(objpfx)bench-malloc-thread; \
+	for thr in 1 8 16 32; do \
+	  echo "Running $${run} $${thr}"; \
+	  $(run-bench) $${thr} > $${run}-$${thr}.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
@@ -134,7 +147,8 @@ bench-func: $(binaries-bench)
 	scripts/validate_benchout.py $(objpfx)bench.out \
 		scripts/benchout.schema.json
 
-$(timing-type) $(binaries-bench) $(binaries-benchset): %: %.o $(objpfx)json-lib.o \
+$(timing-type) $(binaries-bench) $(binaries-benchset) \
+	$(binaries-bench-malloc): %: %.o $(objpfx)json-lib.o \
   $(sort $(filter $(common-objpfx)lib%,$(link-libc))) \
   $(addprefix $(csu-objpfx),start.o) $(+preinit) $(+postinit)
 	$(+link)