diff options
author | Sergey Poznyakoff <gray@gnu.org> | 2020-03-15 15:42:34 +0200 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org> | 2020-03-15 15:42:34 +0200 |
commit | a39bd26c6d6d5638407e57caaa3187aeb52517b1 (patch) | |
tree | 9a99b49c98b0a9be7bbb3a4d42930476731f4915 | |
parent | 87279b57516dfd891ef03858dac1d644df758b4c (diff) | |
download | cache-benchmarks-a39bd26c6d6d5638407e57caaa3187aeb52517b1.tar.gz cache-benchmarks-a39bd26c6d6d5638407e57caaa3187aeb52517b1.tar.bz2 |
Improve data collection and the gnuplot script.
-rw-r--r-- | Makefile.am | 3 | ||||
-rw-r--r-- | configure.ac | 4 | ||||
-rw-r--r-- | src/benchmark.mk.in | 4 | ||||
-rw-r--r-- | src/gnuplot.m4 | 28 | ||||
-rwxr-xr-x | src/runtest | 33 |
5 files changed, 52 insertions, 20 deletions
diff --git a/Makefile.am b/Makefile.am index a7c97e1..3baad54 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,6 +1,7 @@ ACLOCAL_AMFLAGS = -I m4 SUBDIRS = gdbm/master gdbm/newcache src BENCHMARKDIR=benchmarks +NUMSAMPLES=5 benchmark: @if test -z "$(NRECS)"; then \ echo "Please set NRECS"; \ @@ -16,6 +17,8 @@ benchmark: (echo "NRECS=$(NRECS)"; \ echo "NKEYS=$(NKEYS)"; \ echo "MAXCACHE=$(MAXCACHE)"; \ + echo "NUMSAMPLES=$(NUMSAMPLES)"; \ + echo "RUNTESTOPT=$(RUNTESTOPT)"; \ echo "include @abs_top_builddir@/src/benchmark.mk") > $$DIRNAME/Makefile; \ fi; \ $(MAKE) -C $$DIRNAME diff --git a/configure.ac b/configure.ac index 5abd4ff..84f1957 100644 --- a/configure.ac +++ b/configure.ac @@ -1,6 +1,6 @@ AC_PREREQ([2.69]) -AC_INIT([gdbm-benchmarks],[0.1],[gray@gnu.org], - [gdbm-benchmarks], +AC_INIT([cache-benchmarks],[0.1],[gray@gnu.org], + [cache-benchmarks], [https://puszcza.gnu.org.ua/projects/gdbm]) AC_CONFIG_SRCDIR([src/fetchkeys.c]) AC_CONFIG_AUX_DIR([build-aux]) diff --git a/src/benchmark.mk.in b/src/benchmark.mk.in index c576cd6..9d8adff 100644 --- a/src/benchmark.mk.in +++ b/src/benchmark.mk.in @@ -23,7 +23,7 @@ all: test test: master.log newcache.log %.log: keys.txt a.gdbm $(AM_V_GEN)MAXCACHE=$(MAXCACHE); \ - $(abs_top_srcdir)/src/runtest -d \ + $(abs_top_srcdir)/src/runtest -n $(NUMSAMPLES) $(RUNTESTOPT) \ --final $${MAXCACHE:-$$(($$($(GDBMTOOL) a.gdbm dir |\ sed -n -e '2{' \ -e 's/.*Buckets = //' \ @@ -43,7 +43,7 @@ a.gdbm: @$(MAKE) -C $(TESTDIR) num2word gtload $(AM_V_GEN)$(TESTDIR)/num2word 1:$(NRECS) | $(TESTDIR)/gtload -clear a.gdbm benchmark.gnuplot: $(abs_top_srcdir)/src/gnuplot.m4 - m4 -DNRECS=$(NRECS) -DNKEYS=$(NKEYS) \ + m4 -DNRECS=$(NRECS) -DNKEYS=$(NKEYS) -DNUMSAMPLES=$(NUMSAMPLES) \ $(abs_top_srcdir)/src/gnuplot.m4 > benchmark.gnuplot plot: test benchmark.gnuplot gnuplot -p benchmark.gnuplot diff --git a/src/gnuplot.m4 b/src/gnuplot.m4 index 7ea1a79..29126f5 100644 --- a/src/gnuplot.m4 +++ b/src/gnuplot.m4 @@ -1,13 +1,25 @@ divert(-1) changequote([.]) divert(0)dnl -set title 'Execution time as function of cache size. Database size NRECS entries. Key set size NKEYS' -show title +set title "Execution time as function of cache size.\n\ +Database size NRECS entries. Key set size NKEYS.\n\ +Each measurement averages NUMSAMPLES samples." set xlabel 'Cache entries' set ylabel 'Runtime (seconds)' -plot 'master.log' \ - using 1:4 smooth bezier \ - title 'GDBM 1.18.1', \ - 'newcache.log' \ - using 1:4 smooth bezier \ - title 'GDBM newcache' +set style line 1 linecolor rgb "dark-red" linewidth 1.000 dashtype solid pointtype 1 pointsize default pointinterval 0 +set style line 2 linecolor rgb "#e69f00" linewidth 1.000 dashtype solid pointtype 1 pointsize default pointinterval 0 +set style line 3 linecolor rgb "blue" linewidth 1.000 dashtype solid pointtype 1 pointsize default pointinterval 0 +set style line 4 linecolor rgb "#0072b2" linewidth 1.000 dashtype solid pointtype 1 pointsize default pointinterval 0 + +plot "master.log" \ + using 1:4:7 \ + title "GDBM 1.18.1" with errorbars ls 1, \ + "" using 1:4 \ + notitle \ + smooth csplines ls 2, \ + "newcache.log" \ + using 1:4:7 \ + title "GDBM newcache" with errorbars ls 3, \ + "" using 1:4 \ + notitle \ + smooth csplines ls 4 diff --git a/src/runtest b/src/runtest index 33322b1..7c8885c 100755 --- a/src/runtest +++ b/src/runtest @@ -17,7 +17,13 @@ my $drop_caches; # Drop system disk caches before each run. my $log_file; # Name of the log file. sub runtest { - my ($t_total, $t_open, $t_loop) = (0,0,0); + use constant { + TOTAL => 0, + OPEN => 1, + LOOP => 2 + }; + my @times = (0,0,0); + my @stddev = (0,0,0); my $n; for ($n = 0; $n < $nsamples; $n++) { @@ -40,9 +46,13 @@ sub runtest { close PH; if (@inbuf == 3) { - $t_total += $inbuf[0]; - $t_open += $inbuf[1]; - $t_loop += $inbuf[2]; + $times[TOTAL] += $inbuf[TOTAL]; + $times[OPEN] += $inbuf[OPEN]; + $times[LOOP] += $inbuf[LOOP]; + + $stddev[TOTAL] += $inbuf[TOTAL] ** 2; + $stddev[OPEN] += $inbuf[OPEN] ** 2; + $stddev[LOOP] += $inbuf[LOOP] ** 2; } else { while (my $s = shift(@inbuf)) { print "$s\n"; @@ -50,7 +60,11 @@ sub runtest { die "no timing info\n"; } } - return ($t_total/$nsamples, $t_open/$nsamples, $t_loop/$nsamples) + for (my $i = 0; $i < @times; $i++) { + $times[$i] /= $nsamples; + $stddev[$i] = sqrt($stddev[$i] / $nsamples - $times[$i] ** 2); + } + return (@times, @stddev); } GetOptions( @@ -63,7 +77,7 @@ GetOptions( unless (-x $drop_caches) { print STDERR <<EOT; $0: the option --drop-caches (-d) requires that the program $drop_caches -be built, be owned by root, and have the setuid bit set (or the tests be +be built, owned by root, and have the setuid bit set (or the tests be run as root). Please, make sure that this is the case and rerun the runtest utility. EOT @@ -90,8 +104,11 @@ if ($log_file) { } for (my $c = $c_init; $c <= $c_final; $c += $c_step) { - my ($t_total, $t_open, $t_loop) = runtest(@ARGV, '-c', $c); - printf LOG "%d %.6f %.6f %.6f\n", $c, $t_total, $t_open, $t_loop; + printf LOG "%d ", $c; + foreach my $t (runtest(@ARGV, '-c', $c)) { + printf LOG " %.6f", $t; + } + print LOG "\n"; } |