X-Git-Url: https://pd.if.org/git/?p=nbds;a=blobdiff_plain;f=test%2Fsl_test.c;h=00f9ac0a63e4a1f618288c8da3c46f0ea4d2ce3b;hp=9fc6466fd6640f939328d823e0a18e1a0fff7b6d;hb=025017478bb385da88a6b185849c8bcffeb2e2aa;hpb=b21e1c182a2e469240d2b1cbbda37f2dfeb880d9 diff --git a/test/sl_test.c b/test/sl_test.c index 9fc6466..00f9ac0 100644 --- a/test/sl_test.c +++ b/test/sl_test.c @@ -5,13 +5,13 @@ #include "common.h" #include "runtime.h" -#include "struct.h" +#include "map.h" #define NUM_ITERATIONS 10000000 static volatile int wait_; static long num_threads_; -static skiplist_t *sl_; +static map_t *map_; void *worker (void *arg) { @@ -21,12 +21,22 @@ void *worker (void *arg) { for (int i = 0; i < NUM_ITERATIONS/num_threads_; ++i) { unsigned r = nbd_rand(); - int key = r & 0xF; + uint64_t key = r & 0xF; +#if 1 + char key_str[10]; + sprintf(key_str, "%llX", key); if (r & (1 << 8)) { - sl_add(sl_, key, 1); + map_set(map_, key_str, strlen(key_str) + 1, (r & 0xFF)+1); } else { - sl_remove(sl_, key); + map_remove(map_, key_str, strlen(key_str) + 1); } +#else + if (r & (1 << 8)) { + map_set(map_, (void *)key, -1, (r & 0xFF)+1); + } else { + map_remove(map_, (void *)key, -1); + } +#endif rcu_update(); } @@ -65,7 +75,7 @@ int main (int argc, char **argv) { } } - sl_ = sl_alloc(); + map_ = map_alloc(MAP_TYPE_SKIPLIST); struct timeval tv1, tv2; gettimeofday(&tv1, NULL); @@ -83,7 +93,7 @@ int main (int argc, char **argv) { gettimeofday(&tv2, NULL); int ms = (int)(1000000*(tv2.tv_sec - tv1.tv_sec) + tv2.tv_usec - tv1.tv_usec) / 1000; - sl_print(sl_); + map_print(map_); printf("Th:%ld Time:%dms\n", num_threads_, ms); return 0;