X-Git-Url: http://mj.ucw.cz/gitweb/?a=blobdiff_plain;ds=inline;f=ucw%2Fsorter%2Fsort-test.c;h=f8384a7554a144eba31211e414ab1fb2b282f037;hb=959566090f98dd31eaa67d3d5959b641e5fe902b;hp=a35a68878b2ca5554581f1f861429457c8148300;hpb=46a15649d1e544dce95f76424a4870d69caa955c;p=libucw.git diff --git a/ucw/sorter/sort-test.c b/ucw/sorter/sort-test.c index a35a6887..f8384a75 100644 --- a/ucw/sorter/sort-test.c +++ b/ucw/sorter/sort-test.c @@ -16,7 +16,7 @@ #include #include #include -#include +#include #include #include @@ -34,7 +34,7 @@ /*** Time measurement ***/ static timestamp_t timer; -static uns test_id; +static uint test_id; static void start(void) @@ -69,12 +69,12 @@ struct key1 { static void test_int(int mode, u64 size) { - uns N = size ? nextprime(MIN(size/4, 0xffff0000)) : 0; - uns K = N/4*3; + uint N = size ? nextprime(MIN(size/4, 0xffff0000)) : 0; + uint K = N/4*3; 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(f, k[0], sizeof(struct key2)); } @@ -119,17 +119,17 @@ static void test_counted(int mode, u64 size) { u64 items = size / sizeof(struct key2); - uns mult = 2; + uint mult = 2; while (items/(2*mult) > 0xffff0000) mult++; - uns N = items ? nextprime(items/(2*mult)) : 0; - uns K = N/4*3; + uint N = items ? nextprime(items/(2*mult)) : 0; + uint K = N/4*3; 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; mhash[0]; } @@ -184,7 +184,7 @@ static inline uns s3_hash(struct key3 *x) #include static void -gen_hash_key(int mode, struct key3 *k, uns i) +gen_hash_key(int mode, struct key3 *k, uint i) { k->i = i; k->payload[0] = 7*i + 13; @@ -213,13 +213,13 @@ gen_hash_key(int mode, struct key3 *k, uns i) static void test_hashes(int mode, u64 size) { - uns N = MIN(size / sizeof(struct key3), 0xffffffff); + uint N = MIN(size / sizeof(struct key3), 0xffffffff); msg(L_INFO, ">>> Hashes (%s, N=%u)", ((char *[]) { "increasing", "decreasing", "random" })[mode], N); struct key3 k, lastk; struct fastbuf *f = bopen_tmp(65536); - uns hash_sum = 0; - for (uns i=0; ilen, y->len); + uint l = MIN(x->len, y->len); int c = memcmp(x->s, y->s, l); if (c) return c; @@ -295,7 +295,7 @@ static inline void s4_write_key(struct fastbuf *f, struct key4 *x) #define s4b_read_key s4_read_key #define s4b_write_key s4_write_key -static inline uns s4_data_size(struct key4 *x) +static inline uint s4_data_size(struct key4 *x) { return x->len ? (x->s[0] ^ 0xad) : 0; } @@ -313,12 +313,12 @@ static void gen_key4(struct key4 *k) { k->len = random_max(KEY4_MAX); - for (uns i=0; ilen; i++) + for (uint i=0; ilen; i++) k->s[i] = random(); } static void -gen_data4(byte *buf, uns len, uns h) +gen_data4(byte *buf, uint len, uint h) { while (len--) { @@ -328,23 +328,23 @@ gen_data4(byte *buf, uns len, uns h) } static void -test_strings(uns mode, u64 size) +test_strings(uint mode, u64 size) { - uns avg_item_size = KEY4_MAX/2 + 4 + (mode ? 128 : 0); - uns N = MIN(size / avg_item_size, 0xffffffff); + uint avg_item_size = KEY4_MAX/2 + 4 + (mode ? 128 : 0); + uint N = MIN(size / avg_item_size, 0xffffffff); msg(L_INFO, ">>> Strings %s(N=%u)", (mode ? "with data " : ""), N); srand(1); struct key4 k, lastk; byte buf[256], buf2[256]; - uns sum = 0; + uint sum = 0; struct fastbuf *f = bopen_tmp(65536); - for (uns i=0; i -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, uint n, void *buf) { u32 *a = buf; - uns m = 0; - for (uns i=0; icnt); m += keys[i]->cnt; @@ -427,11 +427,11 @@ static void s5_write_merged(struct fastbuf *f, struct key5 **keys, void **data, bwrite(f, a, 4*m); } -static void s5_copy_merged(struct key5 **keys, struct fastbuf **data, uns n, struct fastbuf *dest) +static void s5_copy_merged(struct key5 **keys, struct fastbuf **data, uint n, struct fastbuf *dest) { u32 k[n]; - uns m = 0; - for (uns i=0; icnt; @@ -440,8 +440,8 @@ static void s5_copy_merged(struct key5 **keys, struct fastbuf **data, uns n, str bwrite(dest, &key, sizeof(key)); while (key.cnt--) { - uns b = 0; - for (uns i=1; i static void -test_graph(uns mode, u64 size) +test_graph(uint mode, u64 size) { - uns N = 3; + uint N = 3; while ((u64)N*(N+2)*4 < size) N = nextprime(N); if (!size) @@ -548,18 +548,18 @@ test_graph(uns mode, u64 size) stop(); SORT_XTRACE(2, "Verifying"); - uns c = bgetl(f); + uint c = bgetl(f); ASSERT(c == 0xfeedcafe); - for (uns i=0; i= 0) switch (c) @@ -696,7 +696,7 @@ main(int argc, char **argv) if (optind != argc) goto usage; - for (uns i=0; i