X-Git-Url: http://mj.ucw.cz/gitweb/?a=blobdiff_plain;f=lib%2Fsorter%2Fsort-test.c;h=71c6a12ff75790b82bfeb6d2c216352fe94ea6fa;hb=f08c91407f0ccdcc07cee4a49ccb4bddd4c35988;hp=be6fd511681ec5b12b0bc74fdcb1b0b43934ff52;hpb=d18403664f23ca1464d659b29912758d72b2abec;p=libucw.git diff --git a/lib/sorter/sort-test.c b/lib/sorter/sort-test.c index be6fd511..71c6a12f 100644 --- a/lib/sorter/sort-test.c +++ b/lib/sorter/sort-test.c @@ -24,6 +24,7 @@ /*** Time measurement ***/ static timestamp_t timer; +static uns test_id; static void start(void) @@ -36,7 +37,7 @@ static void stop(void) { sync(); - msg(L_INFO, "Test took %.3fs", get_timer(&timer) / 1000.); + msg(L_INFO, "Test %d took %.3fs", test_id, get_timer(&timer) / 1000.); } /*** Simple 4-byte integer keys ***/ @@ -137,7 +138,7 @@ test_counted(int mode, u64 size) die("Discrepancy: %u instead of %u", j, i); uns k = bgetl(f); if (k != 2*mult) - die("Discrepancy: %u has count %u instead of %u", j, k, mult); + die("Discrepancy: %u has count %u instead of %u", j, k, 2*mult); } bclose(f); } @@ -152,9 +153,10 @@ struct key3 { static inline int s3_compare(struct key3 *x, struct key3 *y) { - /* FIXME: Maybe unroll manually? */ - for (uns i=0; i<4; i++) - COMPARE(x->hash[i], y->hash[i]); + COMPARE(x->hash[0], y->hash[0]); + COMPARE(x->hash[1], y->hash[1]); + COMPARE(x->hash[2], y->hash[2]); + COMPARE(x->hash[3], y->hash[3]); return 0; } @@ -417,7 +419,7 @@ static void s5_write_merged(struct fastbuf *f, struct key5 **keys, void **data, s5m_sort(m, a); keys[0]->cnt = m; bwrite(f, keys[0], sizeof(struct key5)); - bwrite(f, a, 4*m); /* FIXME: Might overflow here */ + bwrite(f, a, 4*m); } static void s5_copy_merged(struct key5 **keys, struct fastbuf **data, uns n, struct fastbuf *dest) @@ -452,13 +454,10 @@ static inline int s5p_lt(struct s5_pair x, struct s5_pair y) return 0; } -/* FIXME: Use smarter internal sorter when it's available */ #define ASORT_PREFIX(x) s5p_##x #define ASORT_KEY_TYPE struct s5_pair -#define ASORT_ELT(i) ary[i] #define ASORT_LT(x,y) s5p_lt(x,y) -#define ASORT_EXTRA_ARGS , struct s5_pair *ary -#include "lib/arraysort.h" +#include "lib/sorter/array.h" static int s5_presort(struct fastbuf *dest, void *buf, size_t bufsize) { @@ -469,7 +468,7 @@ static int s5_presort(struct fastbuf *dest, void *buf, size_t bufsize) n++; if (!n) return 0; - s5p_sort(n, a); + s5p_sort(a, n); uns i = 0; while (i < n) { @@ -606,6 +605,7 @@ test_int64(int mode, u64 size) static void run_test(uns i, u64 size) { + test_id = i; switch (i) { case 0: