| 326 | }; |
| 327 | |
| 328 | void* ThreadKeyPerfFunc(void* void_arg) { |
| 329 | auto args = (ThreadKeyPerfArgs*)void_arg; |
| 330 | args->ready = true; |
| 331 | std::unique_ptr<int> data(new int(1)); |
| 332 | if (args->is_pthread_key) { |
| 333 | pthread_setspecific(args->pthread_key, (void*)data.get()); |
| 334 | } else { |
| 335 | butil::thread_setspecific(*args->thread_key, (void*)data.get()); |
| 336 | } |
| 337 | butil::Timer t; |
| 338 | while (!g_stopped) { |
| 339 | if (g_started) { |
| 340 | break; |
| 341 | } |
| 342 | bthread_usleep(10); |
| 343 | } |
| 344 | t.start(); |
| 345 | while (!g_stopped) { |
| 346 | if (args->is_pthread_key) { |
| 347 | pthread_getspecific(args->pthread_key); |
| 348 | } else { |
| 349 | butil::thread_getspecific(*args->thread_key); |
| 350 | } |
| 351 | ++args->counter; |
| 352 | } |
| 353 | t.stop(); |
| 354 | args->elapse_ns = t.n_elapsed(); |
| 355 | return NULL; |
| 356 | } |
| 357 | |
| 358 | |
| 359 | void ThreadKeyPerfTest(int thread_num, bool test_pthread_key) { |
nothing calls this directly
no test coverage detected