_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;
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); */