X-Git-Url: https://pd.if.org/git/?a=blobdiff_plain;f=test%2Frcu_test.c;h=3fd10d5a60f4b785f784b914f16f9ec9b682c40e;hb=0f6e9afb06b03647c4c5f2499ddab12f42b4340e;hp=96d196b37a9c71aba3c3d1b5c6b02095c70b0382;hpb=b21e1c182a2e469240d2b1cbbda37f2dfeb880d9;p=nbds diff --git a/test/rcu_test.c b/test/rcu_test.c index 96d196b..3fd10d5 100644 --- a/test/rcu_test.c +++ b/test/rcu_test.c @@ -1,9 +1,12 @@ +#define _POSIX_C_SOURCE 1 // for rand_r #include #include #include +#include #include "common.h" #include "runtime.h" #include "mem.h" +#include "rcu.h" #define NUM_ITERATIONS 10000000 @@ -65,7 +68,7 @@ void *worker (void *arg) { } else { node_t *x = lifo_aba_pop(stk_); if (x) { - nbd_defer_free(x); + rcu_defer_free(x); } } rcu_update(); @@ -75,8 +78,7 @@ void *worker (void *arg) { } int main (int argc, char **argv) { - nbd_init(); - //lwt_set_trace_level("m0r0"); + lwt_set_trace_level("m3r3"); int num_threads = 2; if (argc == 2) @@ -96,6 +98,10 @@ int main (int argc, char **argv) { stk_ = lifo_alloc(); wait_ = num_threads; + struct timeval tv1, tv2; + gettimeofday(&tv1, NULL); + wait_ = num_threads; + pthread_t thread[num_threads]; for (int i = 0; i < num_threads; ++i) { int rc = nbd_thread_create(thread + i, i, worker, (void *)(size_t)i); @@ -105,5 +111,10 @@ int main (int argc, char **argv) { pthread_join(thread[i], NULL); } + gettimeofday(&tv2, NULL); + int ms = (int)(1000000*(tv2.tv_sec - tv1.tv_sec) + tv2.tv_usec - tv1.tv_usec) / 1000; + printf("Th:%d Time:%dms\n\n", num_threads, ms); + fflush(stdout); + return 0; }