From: Martin Mares Date: Wed, 25 Jun 2008 19:06:46 +0000 (+0200) Subject: Renamed str-test to hashfunc-test, because that's what it is. X-Git-Tag: holmes-import~420 X-Git-Url: http://mj.ucw.cz/gitweb/?a=commitdiff_plain;h=ba0a8a7c2ca7607c474f18f2005da5d6cf9844ce;p=libucw.git Renamed str-test to hashfunc-test, because that's what it is. --- diff --git a/lib/Makefile b/lib/Makefile index c1090baf..3b3f259f 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -87,7 +87,7 @@ $(o)/lib/db-tool: $(o)/lib/db-tool.o $(LIBUCW) $(o)/lib/conf-test: $(o)/lib/conf-test.o $(LIBUCW) $(o)/lib/lfs-test: $(o)/lib/lfs-test.o $(LIBUCW) $(o)/lib/hash-test: $(o)/lib/hash-test.o $(LIBUCW) -$(o)/lib/str-test: $(o)/lib/str-test.o $(LIBUCW) +$(o)/lib/hashfunc-test: $(o)/lib/hashfunc-test.o $(LIBUCW) $(o)/lib/asort-test: $(o)/lib/asort-test.o $(LIBUCW) $(o)/lib/redblack-test: $(o)/lib/redblack-test.o $(LIBUCW) $(o)/lib/binheap-test: $(o)/lib/binheap-test.o $(LIBUCW) diff --git a/lib/hashfunc-test.c b/lib/hashfunc-test.c new file mode 100644 index 00000000..e289258a --- /dev/null +++ b/lib/hashfunc-test.c @@ -0,0 +1,132 @@ +/* + * Checking the correctness of str_len() and hash_*() and proving, that + * it is faster than the classical version ;-) + */ + +#include "lib/hashfunc.h" + +#include +#include +#include +#include + +/* It will be divided by (10 + strlen()). */ +#define TEST_TIME 1000000 + +/* The shift of the string according to the alignment. */ +static uns alignment = 0; + +static void +random_string(byte *str, int len) +{ + int i; + for (i=0; i 1) + alignment = atoi(argv[1]); + printf("Alignment set to %d\n", alignment); + for (i=0; strings[i]; i++) + if (strlen(strings[i]) != str_len(strings[i])) + die("Internal str_len() error on string %d", i); + printf("%d strings tested OK\n", i); + for (i=0; strings[i]; i++) + { + uns h1, h2; + h1 = hash_string(strings[i]); + h2 = hash_string_nocase(strings[i]); + if (h1 != hash_block(strings[i], str_len(strings[i]))) + die("Internal hash_string() error on string %d", i); + printf("hash %2d = %08x %08x", i, h1, h2); + if (h1 == h2) + printf(" upper case?"); + printf("\n"); + } + for (i=0; lengths[i] >= 0; i++) + { + byte str[lengths[i] + 1 + alignment]; + uns count = TEST_TIME / (lengths[i] + 10); + uns el1 = 0, el2 = 0, elh = 0, elhn = 0; + uns tot1 = 0, tot2 = 0, hash = 0, hashn = 0; + uns j; + for (j=0; j%d\n", i, i*3-2, i*i, hash_modify(4587, i*3-2, i*i)); + printf("test1: %d\n", hash_modify(lengths[5], 345, i)); +*/ + return 0; +} diff --git a/lib/str-test.c b/lib/str-test.c deleted file mode 100644 index e289258a..00000000 --- a/lib/str-test.c +++ /dev/null @@ -1,132 +0,0 @@ -/* - * Checking the correctness of str_len() and hash_*() and proving, that - * it is faster than the classical version ;-) - */ - -#include "lib/hashfunc.h" - -#include -#include -#include -#include - -/* It will be divided by (10 + strlen()). */ -#define TEST_TIME 1000000 - -/* The shift of the string according to the alignment. */ -static uns alignment = 0; - -static void -random_string(byte *str, int len) -{ - int i; - for (i=0; i 1) - alignment = atoi(argv[1]); - printf("Alignment set to %d\n", alignment); - for (i=0; strings[i]; i++) - if (strlen(strings[i]) != str_len(strings[i])) - die("Internal str_len() error on string %d", i); - printf("%d strings tested OK\n", i); - for (i=0; strings[i]; i++) - { - uns h1, h2; - h1 = hash_string(strings[i]); - h2 = hash_string_nocase(strings[i]); - if (h1 != hash_block(strings[i], str_len(strings[i]))) - die("Internal hash_string() error on string %d", i); - printf("hash %2d = %08x %08x", i, h1, h2); - if (h1 == h2) - printf(" upper case?"); - printf("\n"); - } - for (i=0; lengths[i] >= 0; i++) - { - byte str[lengths[i] + 1 + alignment]; - uns count = TEST_TIME / (lengths[i] + 10); - uns el1 = 0, el2 = 0, elh = 0, elhn = 0; - uns tot1 = 0, tot2 = 0, hash = 0, hashn = 0; - uns j; - for (j=0; j%d\n", i, i*3-2, i*i, hash_modify(4587, i*3-2, i*i)); - printf("test1: %d\n", hash_modify(lengths[5], 345, i)); -*/ - return 0; -}