diff options
author | Sergey Poznyakoff <gray@gnu.org> | 2020-10-29 22:58:39 +0200 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org> | 2020-10-29 22:58:39 +0200 |
commit | 20f9c8e05b7516b70c8428365ccab25f9fa27856 (patch) | |
tree | 8fe68267d2a4e0ea6f5168ece03dc2dcfaa3bdd4 | |
parent | c206691cd621378a03ba4c255699b14b2cef82d6 (diff) | |
download | cache-benchmarks-20f9c8e05b7516b70c8428365ccab25f9fa27856.tar.gz cache-benchmarks-20f9c8e05b7516b70c8428365ccab25f9fa27856.tar.bz2 |
Minor changes
* Makefile.am (benchmark): New variable FETCHKEYSOPT.
* gdbm/newcache: Upgrade.
* src/dropcache.c: Call sync before dropping caches.
* src/fetchkeys.c: Use CPU user and system times, instead of
measuring real execution time.
Don't count gdbm_close in the totals.
* src/gnuplot.m4: Use bezier instead of csplines.
-rw-r--r-- | Makefile.am | 1 | ||||
m--------- | gdbm/newcache | 0 | ||||
-rw-r--r-- | src/dropcache.c | 1 | ||||
-rw-r--r-- | src/fetchkeys.c | 21 | ||||
-rw-r--r-- | src/gnuplot.m4 | 4 |
5 files changed, 20 insertions, 7 deletions
diff --git a/Makefile.am b/Makefile.am index 3baad54..2020e06 100644 --- a/Makefile.am +++ b/Makefile.am @@ -19,6 +19,7 @@ benchmark: echo "MAXCACHE=$(MAXCACHE)"; \ echo "NUMSAMPLES=$(NUMSAMPLES)"; \ echo "RUNTESTOPT=$(RUNTESTOPT)"; \ + echo "FETCHKEYSOPT=$(FETCHKEYSOPT)"; \ echo "include @abs_top_builddir@/src/benchmark.mk") > $$DIRNAME/Makefile; \ fi; \ $(MAKE) -C $$DIRNAME diff --git a/gdbm/newcache b/gdbm/newcache -Subproject 02bc2dc9bee96c0e7d93d23c6f0b7a24d0e1756 +Subproject 274985d77bf2e69dec8d7eb90bd3f752f115f6e diff --git a/src/dropcache.c b/src/dropcache.c index 659f00a..ced103c 100644 --- a/src/dropcache.c +++ b/src/dropcache.c @@ -14,6 +14,7 @@ main(int argc, char **argv) perror(drop_caches); return 1; } + sync(); if (write(fd, "3\n", 2) != 2) { perror(drop_caches); diff --git a/src/fetchkeys.c b/src/fetchkeys.c index a655a0d..694f4d9 100644 --- a/src/fetchkeys.c +++ b/src/fetchkeys.c @@ -9,6 +9,7 @@ #include <assert.h> #include <sys/time.h> #include <sys/stat.h> +#include <sys/resource.h> #include "gdbmdefs.h" static unsigned long @@ -173,6 +174,16 @@ readkeys (char const *name) } } +static struct timeval +get_cpu_time (void) +{ + struct rusage usage; + struct timeval res; + assert (getrusage (RUSAGE_SELF, &usage) == 0); + timeradd (&usage.ru_utime, &usage.ru_stime, &res); + return res; +} + int main (int argc, char **argv) { @@ -245,10 +256,10 @@ main (int argc, char **argv) signal (SIGUSR1, sighan); #endif - gettimeofday (&t_start, NULL); + t_start = get_cpu_time (); dbf = gdbm_open (dbname, 0, GDBM_READER | flags, 00664, NULL); assert (dbf != NULL); - gettimeofday (&t_open, NULL); + t_open = get_cpu_time (); if (maxsize) { @@ -269,7 +280,7 @@ main (int argc, char **argv) if (verbose) { unsigned long long k = (unsigned long long) i * 100 / nkeys; - gettimeofday (&t_now, NULL); + t_now = get_cpu_time (); timersub (&t_now, &t_start, &td); printf ("%8u %6zu / %6zu % 2d%%\r", td.tv_sec, i, nkeys, k); fflush (stdout); @@ -323,12 +334,11 @@ main (int argc, char **argv) } } } - gdbm_close (dbf); if (verbose) putchar ('\n'); if (time_verbose) { - gettimeofday (&t_now, NULL); + t_now = get_cpu_time (); timersub (&t_now, &t_start, &td); printf ("%lu.%06lu\n", td.tv_sec, td.tv_usec); timersub (&t_open, &t_start, &td); @@ -336,6 +346,7 @@ main (int argc, char **argv) timersub (&t_now, &t_open, &td); printf ("%lu.%06lu\n", td.tv_sec, td.tv_usec); } + gdbm_close (dbf); return status; } diff --git a/src/gnuplot.m4 b/src/gnuplot.m4 index 392eb94..edee22e 100644 --- a/src/gnuplot.m4 +++ b/src/gnuplot.m4 @@ -16,10 +16,10 @@ plot "master.log" \ title "GDBM 1.18.1" with errorbars ls 1, \ "" using 1:8 \ notitle \ - smooth csplines ls 2, \ + smooth bezier ls 2, \ "newcache.log" \ using 1:8:9:10 \ title "GDBM newcache" with errorbars ls 3, \ "" using 1:8 \ notitle \ - smooth csplines ls 4 + smooth bezier ls 4 |