]> mj.ucw.cz Git - libucw.git/blobdiff - lib/sorter/sort-test.c
typo
[libucw.git] / lib / sorter / sort-test.c
index bc6ef60871ed1a10fe8d2bf53ab8767b19d0e5e1..524a4cdc763da9d2608cf497436b626af19699d5 100644 (file)
@@ -11,6 +11,7 @@
 #include "lib/getopt.h"
 #include "lib/conf.h"
 #include "lib/fastbuf.h"
 #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 "lib/hashfunc.h"
 #include "lib/md5.h"
 
 #include <stdio.h>
 #include <string.h>
 #include <fcntl.h>
 #include <stdio.h>
 #include <string.h>
 #include <fcntl.h>
+#include <unistd.h>
 
 /*** Time measurement ***/
 
 
 /*** Time measurement ***/
 
+static timestamp_t timer;
+
 static void
 start(void)
 {
 static void
 start(void)
 {
-  init_timer();
+  sync();
+  init_timer(&timer);
 }
 
 static void
 stop(void)
 {
 }
 
 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 ***/
 }
 
 /*** Simple 4-byte integer keys ***/
@@ -53,7 +59,7 @@ test_int(int mode, u64 size)
 {
   uns N = size ? nextprime(MIN(size/4, 0xffff0000)) : 0;
   uns K = N/4*3;
 {
   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++)
 
   struct fastbuf *f = bopen_tmp(65536);
   for (uns i=0; i<N; i++)
@@ -69,7 +75,7 @@ test_int(int mode, u64 size)
     {
       uns j = bgetl(f);
       if (i != j)
     {
       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);
 }
     }
   bclose(f);
 }
@@ -113,7 +119,7 @@ test_counted(int mode, u64 size)
     mult++;
   uns N = items ? nextprime(items/(2*mult)) : 0;
   uns K = N/4*3;
     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++)
 
   struct fastbuf *f = bopen_tmp(65536);
   for (uns m=0; m<mult; m++)
@@ -134,10 +140,10 @@ test_counted(int mode, u64 size)
     {
       uns j = bgetl(f);
       if (i != j)
     {
       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)
       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);
 }
     }
   bclose(f);
 }
@@ -205,7 +211,7 @@ static void
 test_hashes(int mode, u64 size)
 {
   uns N = MIN(size / sizeof(struct key3), 0xffffffff);
 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);
   struct key3 k, lastk;
 
   struct fastbuf *f = bopen_tmp(65536);
@@ -323,7 +329,7 @@ test_strings(uns mode, u64 size)
 {
   uns avg_item_size = KEY4_MAX/2 + 4 + (mode ? 128 : 0);
   uns N = MIN(size / avg_item_size, 0xffffffff);
 {
   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;
   srand(1);
 
   struct key4 k, lastk;
@@ -407,7 +413,6 @@ static int s5_gen(struct s5_pair *p)
 
 static void s5_write_merged(struct fastbuf *f, struct key5 **keys, void **data, uns n, void *buf)
 {
 
 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++)
   u32 *a = buf;
   uns m = 0;
   for (uns i=0; i<n; i++)
@@ -513,7 +518,7 @@ test_graph(uns mode, u64 size)
   uns N = 3;
   while ((u64)N*(N+2)*4 < size)
     N = nextprime(N);
   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;
   s5_N = N;
   s5_K = N/4*3;
   s5_L = N/3*2;