X-Git-Url: https://www.kengrimes.com/gitweb/?p=henge%2Fapc.git;a=blobdiff_plain;f=src%2Ftestston.c;fp=src%2Ftestston.c;h=0acb9b4d42282e302129e00e6d08b1f9eb6b1b9e;hp=0c0fc19db1b7b3a210e10e5730ff721abe80ccca;hb=f6c4925aadcbbf535d1783230b850a0231ecbff4;hpb=6bcbbd2bd3710e13cad79b6822ef93e796d5e105 diff --git a/src/testston.c b/src/testston.c index 0c0fc19..0acb9b4 100644 --- a/src/testston.c +++ b/src/testston.c @@ -76,9 +76,17 @@ _FREE(_HT); \ } while (0) +void testiter(void*,void*,void*); +void testiter +( void* key, + void* val, + void* data +) +{ *(uint32_t*)ston_dht_val((ston_dht)data,key) = *(uint32_t*)val; } + int main(int argc, char* argv[]) { static ston_ht ht; - static ston_dht dht; + static ston_dht dht, dht2; uint32_t val[255], key; uint32_t* htval; size_t i; @@ -104,11 +112,35 @@ int main(int argc, char* argv[]) do_test(2,500000,dht,ston_dht_free,ston_dht32_new(2,malloc,free),ston_dht32_insertx,ston_dht32_row,0xCEED); do_test(5,500000,dht,ston_dht_free,ston_dht32_new(5,malloc,free),ston_dht32_insertx,ston_dht32_row,0xCEED); - printf("\nMid-high usage:\n"); - do_test(2,9000000,ht,free,ston_ht32_new(2,9000000,0,malloc),ston_ht32_insertx,ston_ht32_row,0xCEED); - do_test(5,9000000,ht,free,ston_ht32_new(5,9000000,0,malloc),ston_ht32_insertx,ston_ht32_row,0xCEED); - do_test(2,9000000,dht,ston_dht_free,ston_dht32_new(2,malloc,free),ston_dht32_insertx,ston_dht32_row,0xCEED); - do_test(2,9000000,dht,ston_dht_free,ston_dht32_new(5,malloc,free),ston_dht32_insertx,ston_dht32_row,0xCEED); + printf("\nIterator:\n"); + dht = ston_dht_new(sizeof(uint32_t),sizeof(uint32_t),malloc,free); + dht2 = ston_dht_new(sizeof(uint32_t),sizeof(uint32_t),malloc,free); + for (count = 0; count < 50000; count++) + { key = XXH32(&count,4,0xCEED); + * (uint32_t*) ston_dht_val(dht,&key) = key * key; + } + startclock("Duplicating 50000 element DHT by iteration"); + ston_dht_iterate(dht,testiter,dht2); + endclockn(); + fail = 0; + startclock("Checking for correctness"); + for (count = 0; count < 50000; count++) + { key = XXH32(&count,4,0xCEED); + if (*(uint32_t*)ston_dht_val(dht2,&key) != key * key) + fail++; + } + endclock(); + if (fail) + printf(RED"\nFAIL"CLRC"(%i)\n", fail); + else + printf(GREEN"\nPASS"CLRCN); + + + /* printf("\nMid-high usage:\n"); */ + /* do_test(2,9000000,ht,free,ston_ht32_new(2,9000000,0,malloc),ston_ht32_insertx,ston_ht32_row,0xCEED); */ + /* do_test(5,9000000,ht,free,ston_ht32_new(5,9000000,0,malloc),ston_ht32_insertx,ston_ht32_row,0xCEED); */ + /* do_test(2,9000000,dht,ston_dht_free,ston_dht32_new(2,malloc,free),ston_dht32_insertx,ston_dht32_row,0xCEED); */ + /* do_test(2,9000000,dht,ston_dht_free,ston_dht32_new(5,malloc,free),ston_dht32_insertx,ston_dht32_row,0xCEED); */ /* printf("\nHigh usage:\n"); */ /* do_test(2,90000000,ht,free,ston_ht32_new(2,90000000,0,malloc),ston_ht32_insertx,ston_ht32_row,0xCEED); */