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

Function start_perf_test_with_adder

test/bvar_reducer_unittest.cpp:106–122  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

104}
105
106static long start_perf_test_with_adder(size_t num_thread) {
107 bvar::Adder<uint64_t> reducer;
108 EXPECT_TRUE(reducer.valid());
109 pthread_t threads[num_thread];
110 for (size_t i = 0; i < num_thread; ++i) {
111 pthread_create(&threads[i], NULL, &thread_counter, (void *)&reducer);
112 }
113 long totol_time = 0;
114 for (size_t i = 0; i < num_thread; ++i) {
115 void *ret = NULL;
116 pthread_join(threads[i], &ret);
117 totol_time += (long)ret;
118 }
119 long avg_time = totol_time / (OPS_PER_THREAD * num_thread);
120 EXPECT_EQ(2ul * num_thread * OPS_PER_THREAD, reducer.get_value());
121 return avg_time;
122}
123
124TEST_F(ReducerTest, perf) {
125 std::ostringstream oss;

Callers 1

TEST_FFunction · 0.85

Calls 2

validMethod · 0.45
get_valueMethod · 0.45

Tested by

no test coverage detected