X-Git-Url: http://mj.ucw.cz/gitweb/?a=blobdiff_plain;f=lib%2Fsorter%2Fsort-test.c;h=3eb2147e65ba94791083b955acff2acf11b81cd8;hb=556cfa14c25a4124673e2a7489308e82021cf58b;hp=bc6ef60871ed1a10fe8d2bf53ab8767b19d0e5e1;hpb=fdf07fb99f6fa420946e71c92bf89287d8647761;p=libucw.git diff --git a/lib/sorter/sort-test.c b/lib/sorter/sort-test.c index bc6ef608..3eb2147e 100644 --- a/lib/sorter/sort-test.c +++ b/lib/sorter/sort-test.c @@ -11,6 +11,7 @@ #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" @@ -18,19 +19,24 @@ #include #include #include +#include /*** 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(); + msg(L_INFO, "Test took %.3fs", get_timer(&timer) / 1000.); } /*** Simple 4-byte integer keys ***/ @@ -45,6 +51,7 @@ struct key1 { #define SORT_OUTPUT_FB #define SORT_UNIQUE #define SORT_INT(k) (k).x +#define SORT_DELETE_INPUT 0 #include "lib/sorter/sorter.h" @@ -53,7 +60,7 @@ test_int(int mode, u64 size) { 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); + msg(L_INFO, ">>> Integers (%s, N=%u)", ((char *[]) { "increasing", "decreasing", "random" })[mode], N); struct fastbuf *f = bopen_tmp(65536); for (uns i=0; icnt += k[i]->cnt; - bwrite(dest, k[0], sizeof(struct key2)); -} - #define SORT_KEY_REGULAR struct key2 #define SORT_PREFIX(x) s2_##x #define SORT_INPUT_FB @@ -113,7 +113,7 @@ test_counted(int mode, u64 size) 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); + msg(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>> Hashes (%s, N=%d)", ((char *[]) { "increasing", "decreasing", "random" })[mode], N); + msg(L_INFO, ">>> Hashes (%s, N=%u)", ((char *[]) { "increasing", "decreasing", "random" })[mode], N); struct key3 k, lastk; struct fastbuf *f = bopen_tmp(65536); @@ -323,7 +323,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); - log(L_INFO, ">>> Strings %s(N=%d)", (mode ? "with data " : ""), N); + msg(L_INFO, ">>> Strings %s(N=%u)", (mode ? "with data " : ""), N); srand(1); struct key4 k, lastk; @@ -407,7 +407,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) { - /* FIXME: Allow mode where this function is not defined? */ u32 *a = buf; uns m = 0; for (uns i=0; i>> Graph%s (N=%d)", (mode ? "" : " with custom presorting"), N); + msg(L_INFO, ">>> Graph%s (N=%u)", (mode ? "" : " with custom presorting"), N); s5_N = N; s5_K = N/4*3; s5_L = N/3*2; @@ -559,6 +560,47 @@ test_graph(uns mode, u64 size) bclose(f); } +/*** Simple 8-byte integer keys ***/ + +struct key6 { + u64 x; +}; + +#define SORT_KEY_REGULAR struct key6 +#define SORT_PREFIX(x) s6_##x +#define SORT_INPUT_FB +#define SORT_OUTPUT_FB +#define SORT_UNIQUE +#define SORT_INT64(k) (k).x + +#include "lib/sorter/sorter.h" + +static void +test_int64(int mode, u64 size) +{ + u64 N = size ? nextprime(MIN(size/8, 0xffff0000)) : 0; + u64 K = N/4*3; + msg(L_INFO, ">>> 64-bit integers (%s, N=%llu)", ((char *[]) { "increasing", "decreasing", "random" })[mode], (long long)N); + + struct fastbuf *f = bopen_tmp(65536); + for (u64 i=0; i