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: | |||
19 | echo "MAXCACHE=$(MAXCACHE)"; \ | 19 | echo "MAXCACHE=$(MAXCACHE)"; \ |
20 | echo "NUMSAMPLES=$(NUMSAMPLES)"; \ | 20 | echo "NUMSAMPLES=$(NUMSAMPLES)"; \ |
21 | echo "RUNTESTOPT=$(RUNTESTOPT)"; \ | 21 | echo "RUNTESTOPT=$(RUNTESTOPT)"; \ |
22 | echo "FETCHKEYSOPT=$(FETCHKEYSOPT)"; \ | ||
22 | echo "include @abs_top_builddir@/src/benchmark.mk") > $$DIRNAME/Makefile; \ | 23 | echo "include @abs_top_builddir@/src/benchmark.mk") > $$DIRNAME/Makefile; \ |
23 | fi; \ | 24 | fi; \ |
24 | $(MAKE) -C $$DIRNAME | 25 | $(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) | |||
14 | perror(drop_caches); | 14 | perror(drop_caches); |
15 | return 1; | 15 | return 1; |
16 | } | 16 | } |
17 | sync(); | ||
17 | if (write(fd, "3\n", 2) != 2) | 18 | if (write(fd, "3\n", 2) != 2) |
18 | { | 19 | { |
19 | perror(drop_caches); | 20 | 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 @@ | |||
9 | #include <assert.h> | 9 | #include <assert.h> |
10 | #include <sys/time.h> | 10 | #include <sys/time.h> |
11 | #include <sys/stat.h> | 11 | #include <sys/stat.h> |
12 | #include <sys/resource.h> | ||
12 | #include "gdbmdefs.h" | 13 | #include "gdbmdefs.h" |
13 | 14 | ||
14 | static unsigned long | 15 | static unsigned long |
@@ -173,6 +174,16 @@ readkeys (char const *name) | |||
173 | } | 174 | } |
174 | } | 175 | } |
175 | 176 | ||
177 | static struct timeval | ||
178 | get_cpu_time (void) | ||
179 | { | ||
180 | struct rusage usage; | ||
181 | struct timeval res; | ||
182 | assert (getrusage (RUSAGE_SELF, &usage) == 0); | ||
183 | timeradd (&usage.ru_utime, &usage.ru_stime, &res); | ||
184 | return res; | ||
185 | } | ||
186 | |||
176 | int | 187 | int |
177 | main (int argc, char **argv) | 188 | main (int argc, char **argv) |
178 | { | 189 | { |
@@ -245,10 +256,10 @@ main (int argc, char **argv) | |||
245 | signal (SIGUSR1, sighan); | 256 | signal (SIGUSR1, sighan); |
246 | #endif | 257 | #endif |
247 | 258 | ||
248 | gettimeofday (&t_start, NULL); | 259 | t_start = get_cpu_time (); |
249 | dbf = gdbm_open (dbname, 0, GDBM_READER | flags, 00664, NULL); | 260 | dbf = gdbm_open (dbname, 0, GDBM_READER | flags, 00664, NULL); |
250 | assert (dbf != NULL); | 261 | assert (dbf != NULL); |
251 | gettimeofday (&t_open, NULL); | 262 | t_open = get_cpu_time (); |
252 | 263 | ||
253 | if (maxsize) | 264 | if (maxsize) |
254 | { | 265 | { |
@@ -269,7 +280,7 @@ main (int argc, char **argv) | |||
269 | if (verbose) | 280 | if (verbose) |
270 | { | 281 | { |
271 | unsigned long long k = (unsigned long long) i * 100 / nkeys; | 282 | unsigned long long k = (unsigned long long) i * 100 / nkeys; |
272 | gettimeofday (&t_now, NULL); | 283 | t_now = get_cpu_time (); |
273 | timersub (&t_now, &t_start, &td); | 284 | timersub (&t_now, &t_start, &td); |
274 | printf ("%8u %6zu / %6zu % 2d%%\r", td.tv_sec, i, nkeys, k); | 285 | printf ("%8u %6zu / %6zu % 2d%%\r", td.tv_sec, i, nkeys, k); |
275 | fflush (stdout); | 286 | fflush (stdout); |
@@ -323,12 +334,11 @@ main (int argc, char **argv) | |||
323 | } | 334 | } |
324 | } | 335 | } |
325 | } | 336 | } |
326 | gdbm_close (dbf); | ||
327 | if (verbose) | 337 | if (verbose) |
328 | putchar ('\n'); | 338 | putchar ('\n'); |
329 | if (time_verbose) | 339 | if (time_verbose) |
330 | { | 340 | { |
331 | gettimeofday (&t_now, NULL); | 341 | t_now = get_cpu_time (); |
332 | timersub (&t_now, &t_start, &td); | 342 | timersub (&t_now, &t_start, &td); |
333 | printf ("%lu.%06lu\n", td.tv_sec, td.tv_usec); | 343 | printf ("%lu.%06lu\n", td.tv_sec, td.tv_usec); |
334 | timersub (&t_open, &t_start, &td); | 344 | timersub (&t_open, &t_start, &td); |
@@ -336,6 +346,7 @@ main (int argc, char **argv) | |||
336 | timersub (&t_now, &t_open, &td); | 346 | timersub (&t_now, &t_open, &td); |
337 | printf ("%lu.%06lu\n", td.tv_sec, td.tv_usec); | 347 | printf ("%lu.%06lu\n", td.tv_sec, td.tv_usec); |
338 | } | 348 | } |
349 | gdbm_close (dbf); | ||
339 | return status; | 350 | return status; |
340 | } | 351 | } |
341 | 352 | ||
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" \ | |||
16 | title "GDBM 1.18.1" with errorbars ls 1, \ | 16 | title "GDBM 1.18.1" with errorbars ls 1, \ |
17 | "" using 1:8 \ | 17 | "" using 1:8 \ |
18 | notitle \ | 18 | notitle \ |
19 | smooth csplines ls 2, \ | 19 | smooth bezier ls 2, \ |
20 | "newcache.log" \ | 20 | "newcache.log" \ |
21 | using 1:8:9:10 \ | 21 | using 1:8:9:10 \ |
22 | title "GDBM newcache" with errorbars ls 3, \ | 22 | title "GDBM newcache" with errorbars ls 3, \ |
23 | "" using 1:8 \ | 23 | "" using 1:8 \ |
24 | notitle \ | 24 | notitle \ |
25 | smooth csplines ls 4 | 25 | smooth bezier ls 4 |