MCPcopy Create free account
hub / github.com/apache/brpc / start_perf_test_with_atomic

Function start_perf_test_with_atomic

test/bvar_reducer_unittest.cpp:89–104  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

87}
88
89static long start_perf_test_with_atomic(size_t num_thread) {
90 butil::atomic<uint64_t> counter(0);
91 pthread_t threads[num_thread];
92 for (size_t i = 0; i < num_thread; ++i) {
93 pthread_create(&threads[i], NULL, &add_atomic, (void *)&counter);
94 }
95 long totol_time = 0;
96 for (size_t i = 0; i < num_thread; ++i) {
97 void *ret;
98 pthread_join(threads[i], &ret);
99 totol_time += (long)ret;
100 }
101 long avg_time = totol_time / (OPS_PER_THREAD / 100 * num_thread);
102 EXPECT_EQ(2ul * num_thread * OPS_PER_THREAD / 100, counter.load());
103 return avg_time;
104}
105
106static long start_perf_test_with_adder(size_t num_thread) {
107 bvar::Adder<uint64_t> reducer;

Callers 1

TEST_FFunction · 0.85

Calls 1

loadMethod · 0.45

Tested by

no test coverage detected