#include "lib/getopt.h"
#include "lib/conf.h"
#include "lib/fastbuf.h"
+#include "lib/ff-binary.h"
#include "lib/hashfunc.h"
#include "lib/md5.h"
#include <stdio.h>
#include <string.h>
#include <fcntl.h>
+#include <unistd.h>
/*** Time measurement ***/
+static timestamp_t timer;
+
static void
start(void)
{
- init_timer();
+ sync();
+ init_timer(&timer);
}
static void
stop(void)
{
- log(L_INFO, "Test took %.3fs", get_timer() / 1000.);
+ sync();
+ log(L_INFO, "Test took %.3fs", get_timer(&timer) / 1000.);
}
/*** Simple 4-byte integer keys ***/
{
uns N = size ? nextprime(MIN(size/4, 0xffff0000)) : 0;
uns K = N/4*3;
- log(L_INFO, ">>> Integers (%s, N=%d)", ((char *[]) { "increasing", "decreasing", "random" })[mode], N);
+ log(L_INFO, ">>> Integers (%s, N=%u)", ((char *[]) { "increasing", "decreasing", "random" })[mode], N);
struct fastbuf *f = bopen_tmp(65536);
for (uns i=0; i<N; i++)
{
uns j = bgetl(f);
if (i != j)
- die("Discrepancy: %d instead of %d", j, i);
+ die("Discrepancy: %u instead of %u", j, i);
}
bclose(f);
}
mult++;
uns N = items ? nextprime(items/(2*mult)) : 0;
uns K = N/4*3;
- log(L_INFO, ">>> Counted integers (%s, N=%d, mult=%d)", ((char *[]) { "increasing", "decreasing", "random" })[mode], N, mult);
+ log(L_INFO, ">>> Counted integers (%s, N=%u, mult=%u)", ((char *[]) { "increasing", "decreasing", "random" })[mode], N, mult);
struct fastbuf *f = bopen_tmp(65536);
for (uns m=0; m<mult; m++)
{
uns j = bgetl(f);
if (i != j)
- die("Discrepancy: %d instead of %d", j, i);
+ die("Discrepancy: %u instead of %u", j, i);
uns k = bgetl(f);
if (k != 2*mult)
- die("Discrepancy: %d has count %d instead of %d", j, k, mult);
+ die("Discrepancy: %u has count %u instead of %u", j, k, mult);
}
bclose(f);
}
test_hashes(int mode, u64 size)
{
uns N = MIN(size / sizeof(struct key3), 0xffffffff);
- log(L_INFO, ">>> Hashes (%s, N=%d)", ((char *[]) { "increasing", "decreasing", "random" })[mode], N);
+ log(L_INFO, ">>> Hashes (%s, N=%u)", ((char *[]) { "increasing", "decreasing", "random" })[mode], N);
struct key3 k, lastk;
struct fastbuf *f = bopen_tmp(65536);
{
uns avg_item_size = KEY4_MAX/2 + 4 + (mode ? 128 : 0);
uns N = MIN(size / avg_item_size, 0xffffffff);
- log(L_INFO, ">>> Strings %s(N=%d)", (mode ? "with data " : ""), N);
+ log(L_INFO, ">>> Strings %s(N=%u)", (mode ? "with data " : ""), N);
srand(1);
struct key4 k, lastk;
static void s5_write_merged(struct fastbuf *f, struct key5 **keys, void **data, uns n, void *buf)
{
- /* FIXME: Allow mode where this function is not defined? */
u32 *a = buf;
uns m = 0;
for (uns i=0; i<n; i++)
uns N = 3;
while ((u64)N*(N+2)*4 < size)
N = nextprime(N);
- log(L_INFO, ">>> Graph%s (N=%d)", (mode ? "" : " with custom presorting"), N);
+ log(L_INFO, ">>> Graph%s (N=%u)", (mode ? "" : " with custom presorting"), N);
s5_N = N;
s5_K = N/4*3;
s5_L = N/3*2;