X-Git-Url: https://www.kengrimes.com/gitweb/?p=henge%2Fapc.git;a=blobdiff_plain;f=src%2Ftestston.c;fp=src%2Ftestston.c;h=0f0f1f9af8aab63862924305c84dfdddd468906c;hp=014a58cdd16485113c3f32ded5a2860661ec3c19;hb=20b718e416aaa44d1faa31b6370263affa4dc1df;hpb=16091722cd675ef3e48a56c22fc827eb5cde352e diff --git a/src/testston.c b/src/testston.c index 014a58c..0f0f1f9 100644 --- a/src/testston.c +++ b/src/testston.c @@ -27,6 +27,14 @@ else \ printf("ht_size: [units:%i][bytes:%li]\n",ston_ht_size(ht),ston_ht32_size(ht)); \ +#define check_dht(_HT) \ + if ((_HT) == NULL) \ + { fprintf(stderr,RED"Could not allocate dht32"CLRCN); \ + return -1; \ + } \ + else \ + printf("ht_size: [units:%i][bytes:%i]\n",ston_dht_units(_HT,_HT->header.start_depth),ston_dht_bytes(_HT,_HT->header.start_depth)); \ + int main(int argc, char* argv[]) { static ston_ht ht; @@ -159,10 +167,10 @@ int main(int argc, char* argv[]) printf("\n--------- DHT ----------\n\n"); ston_dht dht; - elements = 50; + elements = 500; columns = 6; - dht = ston_dht32_new(columns, elements, 0, malloc, free); - check_ht(dht); + dht = ston_dht32_new(columns, malloc, free); + check_dht(dht); elements = 50000; printf("Filling Dynamic hashtable with %i entries\n", (int)elements); for(key = 0xCEED; elements--; key *= 7) @@ -186,7 +194,7 @@ int main(int argc, char* argv[]) printf(RED"FAIL"CLRC"(%i)\n", fail); else printf(GREEN"PASS"CLRCN); - max_capacity = (ston_up2pow(50 << 1) * (ston_dht_pagemax(dht) - ston_dht_pagestart(dht))) - 50000; + max_capacity = 100000; cap = max_capacity; printf("Overfilling hashtable with %i entries\n", max_capacity); for(key = 0xCEED2; cap--; key *= 13) @@ -211,18 +219,7 @@ int main(int argc, char* argv[]) else printf(GREEN"PASS"CLRCN); - cap = 20; - printf("Post-capacity insertion of %i\n",cap); - for (key = 0xCEED3; cap--; key *= 23) - { val[0] = key; - for(i = 1; i < columns; i++) - val[i] = key * -i; - size_t count = ston_dht32_insertx(dht,key,val,0,columns); - printf("Insertion %2i wrote %i bytes: %s"CLRCN, (int)cap, (int) count, - (count == 0) ? GREEN"PASS" : RED"FAIL"); - } - - + max_capacity = 5000000; printf("Refilling hashtable with %i entries\n", max_capacity); cap = max_capacity; for(key = 0xCEED2; cap--; key *= 13) @@ -247,7 +244,7 @@ int main(int argc, char* argv[]) else printf(GREEN"PASS"CLRCN); - ston_dht32_free(dht); + ston_dht_free(dht); return 0; }