dynamic hashtables optimized
[henge/apc.git] / src / testston.c
index 014a58c..0f0f1f9 100644 (file)
   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;
 }