| 186 | } |
| 187 | |
| 188 | void* push_thread_which_addresses_execq(void *arg) { |
| 189 | PushArg* pa = (PushArg*)arg; |
| 190 | int64_t sum = 0; |
| 191 | butil::Timer timer; |
| 192 | timer.start(); |
| 193 | int num = 0; |
| 194 | bthread::ExecutionQueue<LongIntTask>::scoped_ptr_t ptr |
| 195 | = bthread::execution_queue_address(pa->id); |
| 196 | EXPECT_TRUE(ptr); |
| 197 | while (ptr->execute(num) == 0) { |
| 198 | sum += num; |
| 199 | ++num; |
| 200 | } |
| 201 | EXPECT_TRUE(ptr->stopped()); |
| 202 | timer.stop(); |
| 203 | pa->expected_value.fetch_add(sum, butil::memory_order_relaxed); |
| 204 | pa->total_num.fetch_add(num); |
| 205 | pa->total_time.fetch_add(timer.n_elapsed()); |
| 206 | return NULL; |
| 207 | } |
| 208 | |
| 209 | void test_performance(bool use_pthread) { |
| 210 | pthread_t threads[8]; |