/*
- * Sherlock Library -- Database Manager -- Tests and Benchmarks
+ * UCW Library -- Database Manager -- Tests and Benchmarks
*
- * (c) 1999 Martin Mares <mj@atrey.karlin.mff.cuni.cz>
+ * (c) 1999 Martin Mares <mj@ucw.cz>
+ *
+ * This software may be freely distributed and used according to the terms
+ * of the GNU Lesser General Public License.
*/
#if 1
-#include "db.c"
+#include "lib/db.c"
#define NAME "SDBM"
#else
-#include "db-emul.c"
+#include "lib/db-emul.c"
#define NAME "GDBM"
#endif
-#include <getopt.h>
+#include <stdlib.h>
#include <unistd.h>
#include <stdarg.h>
#include <sys/stat.h>
-kU Use keys with URL distribution\n\
-n<n> Number of distinct keys\n\
-d<m>[-<n>] Use specified value size (see -k<m>-<n>)\n\
+-t Perform the tests on an existing database file\n\
-v Be verbose\n\
-s Turn on synchronous mode\n\
-S Turn on supersynchronous mode\n\
byte kb[2048], vb[2048], vb2[2048];
uns ks, vs, vs2, perc, cnt;
char *ch;
+ int dont_delete = 0;
+ timestamp_t timer;
- initlog("dbtest");
+ log_init("dbtest");
setvbuf(stdout, NULL, _IONBF, 0);
setvbuf(stderr, NULL, _IONBF, 0);
- while ((c = getopt(argc, argv, "c:p:k:n:d:vsSF")) >= 0)
+ while ((c = getopt(argc, argv, "c:p:k:n:d:vsStF")) >= 0)
switch (c)
{
case 'c':
case 'F':
opts.flags |= SDBM_FAST;
break;
+ case 't':
+ dont_delete = 1;
+ break;
default:
help();
}
verb("OPEN(%s, key=%d, val=%d, cache=%d, pgorder=%d)\n", opts.name, opts.key_size, opts.val_size,
opts.cache_size, opts.page_order);
- unlink(opts.name);
+ if (!dont_delete)
+ unlink(opts.name);
d = sdbm_open(&opts);
if (!d)
die("open failed: %m");
while (optind < argc)
{
char *o = argv[optind++];
- init_timer();
+ init_timer(&timer);
switch (*o)
{
case 'c':
ch = o;
perc = 100;
}
- cnt = atol(o);
+ cnt = atol(ch);
if (!cnt)
{
cnt = num_keys;
help();
}
sdbm_sync(d);
- printf("%d ms\n", get_timer());
+ printf("%d ms\n", get_timer(&timer));
}
verb("CLOSE\n");