X-Git-Url: https://pd.if.org/git/?p=nbds;a=blobdiff_plain;f=test%2Fperf_test.c;fp=test%2Fperf_test.c;h=088956efefbbd115bca68532671d7398ed09bca0;hp=1ea0bcb3eb11f831c9ca50991213121b0e659cf8;hb=75b0d2f02f548b3a1e4daba8b0d55eea2fb24e92;hpb=ff3c302d5e137d9653c656eee016bacf5d988d66 diff --git a/test/perf_test.c b/test/perf_test.c index 1ea0bcb..088956e 100644 --- a/test/perf_test.c +++ b/test/perf_test.c @@ -27,7 +27,7 @@ static int duration_; #define OP_SELECT_RANGE (1ULL << 20) void *worker (void *arg) { - volatile uint64_t ops = 0; + nbd_thread_init(); // Wait for all the worker threads to be ready. (void)SYNC_ADD(&load_, -1); @@ -44,6 +44,7 @@ void *worker (void *arg) { (void)SYNC_ADD(&start_, -1); do {} while (start_); + uint64_t ops = 0; while (!stop_) { ++ops; map_key_t key = (nbd_rand() & (num_keys_ - 1)) + 1; @@ -77,7 +78,7 @@ uint64_t run_test (void) { pthread_t thread[MAX_NUM_THREADS]; for (int i = 0; i < num_threads_; ++i) { - int rc = nbd_thread_create(thread + i, i, worker, (void*)(size_t)i); + int rc = pthread_create(thread + i, NULL, worker, (void*)(size_t)i); if (rc != 0) { perror("pthread_create"); exit(rc); } } @@ -152,6 +153,7 @@ int main (int argc, char **argv) { get_range_ = (int)((double)OP_SELECT_RANGE / 100 * read_ratio); put_range_ = get_range_ + (int)(((double)OP_SELECT_RANGE - get_range_) / 100 * put_ratio); + nbd_thread_init(); static const map_impl_t *map_types[] = { &MAP_IMPL_HT }; for (int i = 0; i < sizeof(map_types)/sizeof(*map_types); ++i) { #ifdef TEST_STRING_KEYS