diff options
author | Sergey Poznyakoff <gray@gnu.org> | 2020-03-14 12:02:33 +0200 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org> | 2020-03-15 09:27:25 +0200 |
commit | 87279b57516dfd891ef03858dac1d644df758b4c (patch) | |
tree | cd45ffc5d34e94749a77987975555996c22188c9 | |
download | cache-benchmarks-87279b57516dfd891ef03858dac1d644df758b4c.tar.gz cache-benchmarks-87279b57516dfd891ef03858dac1d644df758b4c.tar.bz2 |
Initial commit
-rw-r--r-- | .gitignore | 39 | ||||
-rw-r--r-- | .gitmodules | 7 | ||||
-rw-r--r-- | Makefile.am | 22 | ||||
-rw-r--r-- | bootstrap | 8 | ||||
-rw-r--r-- | configure.ac | 18 | ||||
m--------- | gdbm/master | 0 | ||||
m--------- | gdbm/newcache | 0 | ||||
-rw-r--r-- | src/.gitignore | 3 | ||||
-rw-r--r-- | src/Makefile.am | 2 | ||||
-rw-r--r-- | src/benchmark.mk.in | 50 | ||||
-rw-r--r-- | src/dropcache.c | 24 | ||||
-rw-r--r-- | src/fetchkeys.c | 320 | ||||
-rw-r--r-- | src/gnuplot.m4 | 13 | ||||
-rw-r--r-- | src/master/Makefile.am | 5 | ||||
-rw-r--r-- | src/newcache/Makefile.am | 5 | ||||
-rwxr-xr-x | src/runtest | 97 |
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 | ||
17 | ABOUT-NLS | ||
18 | ChangeLog | ||
19 | INSTALL | ||
20 | Makefile | ||
21 | Makefile.in | ||
22 | TAGS | ||
23 | aclocal.m4 | ||
24 | autoconf.h | ||
25 | autoconf.h.in | ||
26 | autom4te.cache | ||
27 | build-aux | ||
28 | config.log | ||
29 | config.status | ||
30 | configure | ||
31 | configure.ac | ||
32 | core | ||
33 | gmon.out | ||
34 | libltdl | ||
35 | libtool | ||
36 | m4 | ||
37 | stamp-h1 | ||
38 | tmp/ | ||
39 | benchmarks | ||
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 @@ | |||
1 | ACLOCAL_AMFLAGS = -I m4 | ||
2 | SUBDIRS = gdbm/master gdbm/newcache src | ||
3 | BENCHMARKDIR=benchmarks | ||
4 | benchmark: | ||
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 | ||
2 | set e | ||
3 | test -d m4 || mkdir m4 | ||
4 | test -d gdbm || mkdir gdbm | ||
5 | git submodule init | ||
6 | git submodule update | ||
7 | git submodule foreach ./bootstrap | ||
8 | autoreconf -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 @@ | |||
1 | AC_PREREQ([2.69]) | ||
2 | AC_INIT([gdbm-benchmarks],[0.1],[gray@gnu.org], | ||
3 | [gdbm-benchmarks], | ||
4 | [https://puszcza.gnu.org.ua/projects/gdbm]) | ||
5 | AC_CONFIG_SRCDIR([src/fetchkeys.c]) | ||
6 | AC_CONFIG_AUX_DIR([build-aux]) | ||
7 | AM_INIT_AUTOMAKE([-Wall -Werror 1.11.5 foreign tar-ustar silent-rules]) | ||
8 | |||
9 | # Checks for programs. | ||
10 | AC_PROG_CC | ||
11 | |||
12 | AC_CONFIG_SUBDIRS(gdbm/master gdbm/newcache) | ||
13 | AC_CONFIG_FILES([Makefile | ||
14 | src/Makefile | ||
15 | src/master/Makefile | ||
16 | src/newcache/Makefile | ||
17 | src/benchmark.mk]) | ||
18 | AC_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 @@ | |||
1 | dropcache | ||
2 | fetchkeys | ||
3 | benchmark.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 @@ | |||
1 | SUBDIRS=newcache master | ||
2 | EXTRA_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 @@ | |||
1 | AM_DEFAULT_VERBOSITY=0 | ||
2 | AM_V_P = $(am__v_P_@AM_V@) | ||
3 | am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) | ||
4 | am__v_P_0 = false | ||
5 | am__v_P_1 = : | ||
6 | AM_V_GEN = $(am__v_GEN_@AM_V@) | ||
7 | am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) | ||
8 | am__v_GEN_0 = @echo " GEN " $@; | ||
9 | am__v_GEN_1 = | ||
10 | AM_V_at = $(am__v_at_@AM_V@) | ||
11 | am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) | ||
12 | am__v_at_0 = @ | ||
13 | am__v_at_1 = | ||
14 | |||
15 | abs_top_srcdir = @abs_top_srcdir@ | ||
16 | abs_top_builddir = @abs_top_builddir@ | ||
17 | |||
18 | MASTERDIR=$(abs_top_builddir)/gdbm/master | ||
19 | GDBMTOOL=$(MASTERDIR)/src/gdbmtool | ||
20 | TESTDIR=$(MASTERDIR)/tests | ||
21 | |||
22 | all: test | ||
23 | test: 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 | ||
34 | clean: | ||
35 | rm -f master.log newcache.log | ||
36 | allclean: clean | ||
37 | rm -f keys.txt a.gdbm | ||
38 | keys.txt: | ||
39 | @$(MAKE) -C $(TESTDIR) num2word | ||
40 | $(AM_V_GEN)$(TESTDIR)/num2word 1:$(NRECS) | \ | ||
41 | cut -f1 | shuf | head -n $(NKEYS) > keys.txt | ||
42 | a.gdbm: | ||
43 | @$(MAKE) -C $(TESTDIR) num2word gtload | ||
44 | $(AM_V_GEN)$(TESTDIR)/num2word 1:$(NRECS) | $(TESTDIR)/gtload -clear a.gdbm | ||
45 | benchmark.gnuplot: $(abs_top_srcdir)/src/gnuplot.m4 | ||
46 | m4 -DNRECS=$(NRECS) -DNKEYS=$(NKEYS) \ | ||
47 | $(abs_top_srcdir)/src/gnuplot.m4 > benchmark.gnuplot | ||
48 | plot: 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 | |||
5 | char const drop_caches[] = "/proc/sys/vm/drop_caches"; | ||
6 | |||
7 | int | ||
8 | main(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 | |||
13 | static unsigned long | ||
14 | get_size (char const *str) | ||
15 | { | ||
16 | char *p; | ||
17 | unsigned long n, m; | ||
18 | |||