aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org>2020-03-14 12:02:33 +0200
committerSergey Poznyakoff <gray@gnu.org>2020-03-15 09:27:25 +0200
commit87279b57516dfd891ef03858dac1d644df758b4c (patch)
treecd45ffc5d34e94749a77987975555996c22188c9
downloadcache-benchmarks-87279b57516dfd891ef03858dac1d644df758b4c.tar.gz
cache-benchmarks-87279b57516dfd891ef03858dac1d644df758b4c.tar.bz2
Initial commit
-rw-r--r--.gitignore39
-rw-r--r--.gitmodules7
-rw-r--r--Makefile.am22
-rw-r--r--bootstrap8
-rw-r--r--configure.ac18
m---------gdbm/master0
m---------gdbm/newcache0
-rw-r--r--src/.gitignore3
-rw-r--r--src/Makefile.am2
-rw-r--r--src/benchmark.mk.in50
-rw-r--r--src/dropcache.c24
-rw-r--r--src/fetchkeys.c320
-rw-r--r--src/gnuplot.m413
-rw-r--r--src/master/Makefile.am5
-rw-r--r--src/newcache/Makefile.am5
-rwxr-xr-xsrc/runtest97
16 files changed, 613 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..b2a687e
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,39 @@
1*.a
2*.la
3*.lo
4*.o
5*.orig
6*.pyc
7*.rej
8*.tar.bz2
9*.tar.gz
10*.tar.xz
11*~
12*.gdbm
13*.cflow
14.deps
15.emacs*
16.libs
17ABOUT-NLS
18ChangeLog
19INSTALL
20Makefile
21Makefile.in
22TAGS
23aclocal.m4
24autoconf.h
25autoconf.h.in
26autom4te.cache
27build-aux
28config.log
29config.status
30configure
31configure.ac
32core
33gmon.out
34libltdl
35libtool
36m4
37stamp-h1
38tmp/
39benchmarks
diff --git a/.gitmodules b/.gitmodules
new file mode 100644
index 0000000..a4fd957
--- /dev/null
+++ b/.gitmodules
@@ -0,0 +1,7 @@
1[submodule "gdbm/newcache"]
2 path = gdbm/newcache
3 url = git://git.gnu.org.ua/gdbm.git
4 branch = newcache
5[submodule "gdbm/master"]
6 path = gdbm/master
7 url = git://git.gnu.org.ua/gdbm.git
diff --git a/Makefile.am b/Makefile.am
new file mode 100644
index 0000000..a7c97e1
--- /dev/null
+++ b/Makefile.am
@@ -0,0 +1,22 @@
1ACLOCAL_AMFLAGS = -I m4
2SUBDIRS = gdbm/master gdbm/newcache src
3BENCHMARKDIR=benchmarks
4benchmark:
5 @if test -z "$(NRECS)"; then \
6 echo "Please set NRECS"; \
7 exit 1; \
8 fi; \
9 if test -z "$(NKEYS)"; then \
10 echo "Please set NKEYS"; \
11 exit 1; \
12 fi; \
13 DIRNAME="$(BENCHMARKDIR)/$(NRECS)-$(NKEYS)"; \
14 if ! test -d "$$DIRNAME"; then \
15 mkdir -p $$DIRNAME; \
16 (echo "NRECS=$(NRECS)"; \
17 echo "NKEYS=$(NKEYS)"; \
18 echo "MAXCACHE=$(MAXCACHE)"; \
19 echo "include @abs_top_builddir@/src/benchmark.mk") > $$DIRNAME/Makefile; \
20 fi; \
21 $(MAKE) -C $$DIRNAME
22
diff --git a/bootstrap b/bootstrap
new file mode 100644
index 0000000..1726aea
--- /dev/null
+++ b/bootstrap
@@ -0,0 +1,8 @@
1#!/bin/sh
2set e
3test -d m4 || mkdir m4
4test -d gdbm || mkdir gdbm
5git submodule init
6git submodule update
7git submodule foreach ./bootstrap
8autoreconf -f -i -s
diff --git a/configure.ac b/configure.ac
new file mode 100644
index 0000000..5abd4ff
--- /dev/null
+++ b/configure.ac
@@ -0,0 +1,18 @@
1AC_PREREQ([2.69])
2AC_INIT([gdbm-benchmarks],[0.1],[gray@gnu.org],
3 [gdbm-benchmarks],
4 [https://puszcza.gnu.org.ua/projects/gdbm])
5AC_CONFIG_SRCDIR([src/fetchkeys.c])
6AC_CONFIG_AUX_DIR([build-aux])
7AM_INIT_AUTOMAKE([-Wall -Werror 1.11.5 foreign tar-ustar silent-rules])
8
9# Checks for programs.
10AC_PROG_CC
11
12AC_CONFIG_SUBDIRS(gdbm/master gdbm/newcache)
13AC_CONFIG_FILES([Makefile
14 src/Makefile
15 src/master/Makefile
16 src/newcache/Makefile
17 src/benchmark.mk])
18AC_OUTPUT
diff --git a/gdbm/master b/gdbm/master
new file mode 160000
Subproject 4fb2326a4ac0e6f45c21f7651b1c87317567fd8
diff --git a/gdbm/newcache b/gdbm/newcache
new file mode 160000
Subproject 1f94a81a9f3a9955ca74dff07b7909595a85048
diff --git a/src/.gitignore b/src/.gitignore
new file mode 100644
index 0000000..ef23521
--- /dev/null
+++ b/src/.gitignore
@@ -0,0 +1,3 @@
1dropcache
2fetchkeys
3benchmark.mk
diff --git a/src/Makefile.am b/src/Makefile.am
new file mode 100644
index 0000000..c019df3
--- /dev/null
+++ b/src/Makefile.am
@@ -0,0 +1,2 @@
1SUBDIRS=newcache master
2EXTRA_DIST=fechkeys.c runtest gnuplot.m4 benchmark.mk.in
diff --git a/src/benchmark.mk.in b/src/benchmark.mk.in
new file mode 100644
index 0000000..c576cd6
--- /dev/null
+++ b/src/benchmark.mk.in
@@ -0,0 +1,50 @@
1AM_DEFAULT_VERBOSITY=0
2AM_V_P = $(am__v_P_@AM_V@)
3am__v_P_ = $(am__v_P_@AM_DEFAULT_V@)
4am__v_P_0 = false
5am__v_P_1 = :
6AM_V_GEN = $(am__v_GEN_@AM_V@)
7am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@)
8am__v_GEN_0 = @echo " GEN " $@;
9am__v_GEN_1 =
10AM_V_at = $(am__v_at_@AM_V@)
11am__v_at_ = $(am__v_at_@AM_DEFAULT_V@)
12am__v_at_0 = @
13am__v_at_1 =
14
15abs_top_srcdir = @abs_top_srcdir@
16abs_top_builddir = @abs_top_builddir@
17
18MASTERDIR=$(abs_top_builddir)/gdbm/master
19GDBMTOOL=$(MASTERDIR)/src/gdbmtool
20TESTDIR=$(MASTERDIR)/tests
21
22all: test
23test: master.log newcache.log
24%.log: keys.txt a.gdbm
25 $(AM_V_GEN)MAXCACHE=$(MAXCACHE); \
26 $(abs_top_srcdir)/src/runtest -d \
27 --final $${MAXCACHE:-$$(($$($(GDBMTOOL) a.gdbm dir |\
28 sed -n -e '2{' \
29 -e 's/.*Buckets = //' \
30 -e 's/\.$$//' \
31 -e 'p}') * 2))} \
32 --log-file=$*.log \
33 $(abs_top_builddir)/src/$*/fetchkeys
34clean:
35 rm -f master.log newcache.log
36allclean: clean
37 rm -f keys.txt a.gdbm
38keys.txt:
39 @$(MAKE) -C $(TESTDIR) num2word
40 $(AM_V_GEN)$(TESTDIR)/num2word 1:$(NRECS) | \
41 cut -f1 | shuf | head -n $(NKEYS) > keys.txt
42a.gdbm:
43 @$(MAKE) -C $(TESTDIR) num2word gtload
44 $(AM_V_GEN)$(TESTDIR)/num2word 1:$(NRECS) | $(TESTDIR)/gtload -clear a.gdbm
45benchmark.gnuplot: $(abs_top_srcdir)/src/gnuplot.m4
46 m4 -DNRECS=$(NRECS) -DNKEYS=$(NKEYS) \
47 $(abs_top_srcdir)/src/gnuplot.m4 > benchmark.gnuplot
48plot: test benchmark.gnuplot
49 gnuplot -p benchmark.gnuplot
50
diff --git a/src/dropcache.c b/src/dropcache.c
new file mode 100644
index 0000000..659f00a
--- /dev/null
+++ b/src/dropcache.c
@@ -0,0 +1,24 @@
1#include <stdio.h>
2#include <unistd.h>
3#include <fcntl.h>
4
5char const drop_caches[] = "/proc/sys/vm/drop_caches";
6
7int
8main(int argc, char **argv)
9{
10 int fd;
11 fd = open(drop_caches, O_WRONLY);
12 if (fd == -1)
13 {
14 perror(drop_caches);
15 return 1;
16 }
17 if (write(fd, "3\n", 2) != 2)
18 {
19 perror(drop_caches);
20 return 1;
21 }
22 close(fd);
23 return 0;
24}
diff --git a/src/fetchkeys.c b/src/fetchkeys.c
new file mode 100644
index 0000000..32f0199
--- /dev/null
+++ b/src/fetchkeys.c
@@ -0,0 +1,320 @@
1#include <stdio.h>
2#include <stdlib.h>
3#include <gdbm.h>
4#include <string.h>
5#include <unistd.h>
6#include <limits.h>
7#include <errno.h>
8#include <signal.h>
9#include <assert.h>
10#include <sys/time.h>
11#include <sys/stat.h>
12
13static unsigned long
14get_size (char const *str)
15{
16 char *p;
17 unsigned long n, m;
18