universal hashb() and hashs() macros
This commit is contained in:
@@ -2,18 +2,18 @@
|
||||
#include "../src/Hashtable/hash.h"
|
||||
#include "../src/Autoarr/Autoarr.h"
|
||||
|
||||
#define AMOUNT_OF_TESTS 400000
|
||||
#define AMOUNT_OF_TESTS 10000
|
||||
|
||||
char __buf[]="iojihiojopijiugbjmoihftytryfdrh";
|
||||
char data[]="iojihiojopijiugbjmoihftytryfdrh";
|
||||
|
||||
#define test_hashfunc(hasht, hashf, tests_n)\
|
||||
optime(#hashf,1,({\
|
||||
printf("\e[94mfunction: \e[92m" #hashf "\n");\
|
||||
printf("\e[94mhash of \"%s\": \e[92m%x\n",__buf, hashf(__buf,cptr_length(__buf)));\
|
||||
printf("\e[94mhash of \"%s\": \e[92m%x\n",data, hashs(hashf,data));\
|
||||
Autoarr(hasht)* hashes=Autoarr_create(hasht,512,32768);\
|
||||
uint32 collisions=0;\
|
||||
for(uint32 i=0;i<tests_n;i++){\
|
||||
hasht h=hashf((uint8*)&i, 4);\
|
||||
hasht h=hashb(hashf, (uint8*)&i, 4);\
|
||||
bool col=false;\
|
||||
Autoarr_foreach(hashes,e,({\
|
||||
if(e==h) {\
|
||||
@@ -31,7 +31,7 @@ char __buf[]="iojihiojopijiugbjmoihftytryfdrh";
|
||||
void test_hash_functions(){
|
||||
optime("test_hash_functions",1,({
|
||||
printf("\e[96m--------[test_hash_functions]---------\n");
|
||||
test_hashfunc(uint32, hashb_crc32, 10000);
|
||||
test_hashfunc(uint32, hashb_sdbm32, 10000);
|
||||
test_hashfunc(uint32, hash_crc32, AMOUNT_OF_TESTS);
|
||||
test_hashfunc(uint32, hash_sdbm32, AMOUNT_OF_TESTS);
|
||||
}));
|
||||
}
|
||||
Reference in New Issue
Block a user