X-Git-Url: http://mj.ucw.cz/gitweb/?a=blobdiff_plain;f=lib%2Fsorter%2Fsort-test.c;h=f103710070e9115e4b1544323b5b24ec2e725969;hb=5f2e7e93768113f1e80ac2502e670632762fb696;hp=8cf1433f8e540b7626462b7541b51c91d6172b01;hpb=969ce845f3bf35bb7423bac705d46196bb863e72;p=libucw.git diff --git a/lib/sorter/sort-test.c b/lib/sorter/sort-test.c index 8cf1433f..f1037100 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" @@ -22,18 +23,20 @@ /*** Time measurement ***/ +static timestamp_t timer; + static void start(void) { sync(); - init_timer(); + init_timer(&timer); } static void stop(void) { sync(); - log(L_INFO, "Test took %.3fs", get_timer() / 1000.); + log(L_INFO, "Test took %.3fs", get_timer(&timer) / 1000.); } /*** Simple 4-byte integer keys ***/ @@ -48,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" @@ -91,13 +95,6 @@ static inline void s2_write_merged(struct fastbuf *f, struct key2 **k, void **d bwrite(f, k[0], sizeof(struct key2)); } -static inline void s2_copy_merged(struct key2 **k, struct fastbuf **d UNUSED, uns n, struct fastbuf *dest) -{ - for (uns i=1; 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 @@ -491,6 +488,7 @@ static int s5_presort(struct fastbuf *dest, void *buf, size_t bufsize) #define SORT_PREFIX(x) s5_##x #define SORT_DATA_SIZE(k) (4*(k).cnt) #define SORT_UNIFY +#define SORT_UNIFY_WORKSPACE(k) SORT_DATA_SIZE(k) #define SORT_INPUT_PRESORT #define SORT_OUTPUT_THIS_FB #define SORT_INT(k) (k).x @@ -501,6 +499,7 @@ static int s5_presort(struct fastbuf *dest, void *buf, size_t bufsize) #define SORT_PREFIX(x) s5b_##x #define SORT_DATA_SIZE(k) (4*(k).cnt) #define SORT_UNIFY +#define SORT_UNIFY_WORKSPACE(k) SORT_DATA_SIZE(k) #define SORT_INPUT_FB #define SORT_OUTPUT_THIS_FB #define SORT_INT(k) (k).x @@ -561,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; + log(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