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

Function Test

example/rdma_performance/client.cpp:221–272  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

219}
220
221void Test(int thread_num, int attachment_size) {
222 std::cout << "[Threads: " << thread_num
223 << ", Depth: " << FLAGS_queue_depth
224 << ", Attachment: " << attachment_size << "B"
225 << ", RDMA: " << (FLAGS_use_rdma ? "yes" : "no")
226 << ", Echo: " << (FLAGS_echo_attachment ? "yes]" : "no]")
227 << std::endl;
228 g_total_bytes.store(0, butil::memory_order_relaxed);
229 g_total_cnt.store(0, butil::memory_order_relaxed);
230 std::vector<PerformanceTest*> tests;
231 for (int k = 0; k < thread_num; ++k) {
232 PerformanceTest* t = new PerformanceTest(attachment_size, FLAGS_echo_attachment);
233 if (t->Init() < 0) {
234 exit(1);
235 }
236 tests.push_back(t);
237 }
238 uint64_t start_time = butil::cpuwide_time_us();
239 bthread_t tid[thread_num];
240 if (FLAGS_expected_qps > 0) {
241 bthread_t tid;
242 bthread_start_background(&tid, &BTHREAD_ATTR_NORMAL, GenerateToken, NULL);
243 }
244 for (int k = 0; k < thread_num; ++k) {
245 bthread_start_background(&tid[k], &BTHREAD_ATTR_NORMAL,
246 PerformanceTest::RunTest, tests[k]);
247 }
248 for (int k = 0; k < thread_num; ++k) {
249 while (!tests[k]->IsStop()) {
250 bthread_usleep(10000);
251 }
252 }
253 uint64_t end_time = butil::cpuwide_time_us();
254 double throughput = g_total_bytes / 1.048576 / (end_time - start_time);
255 if (FLAGS_test_iterations == 0) {
256 std::cout << "Avg-Latency: " << g_latency_recorder.latency(10)
257 << ", 90th-Latency: " << g_latency_recorder.latency_percentile(0.9)
258 << ", 99th-Latency: " << g_latency_recorder.latency_percentile(0.99)
259 << ", 99.9th-Latency: " << g_latency_recorder.latency_percentile(0.999)
260 << ", Throughput: " << throughput << "MB/s"
261 << ", QPS: " << (g_total_cnt.load(butil::memory_order_relaxed) * 1000 / (end_time - start_time)) << "k"
262 << ", Server CPU-utilization: " << g_server_cpu_recorder.latency(10) << "\%"
263 << ", Client CPU-utilization: " << g_client_cpu_recorder.latency(10) << "\%"
264 << std::endl;
265 } else {
266 std::cout << " Throughput: " << throughput << "MB/s" << std::endl;
267 }
268 g_stop = true;
269 for (int k = 0; k < thread_num; ++k) {
270 bthread_start_background(&tid[k], &BTHREAD_ATTR_NORMAL, DeleteTest, tests[k]);
271 }
272}
273
274int main(int argc, char* argv[]) {
275 GFLAGS_NAMESPACE::ParseCommandLineFlags(&argc, &argv, true);

Callers 1

mainFunction · 0.85

Calls 10

cpuwide_time_usFunction · 0.85
bthread_start_backgroundFunction · 0.85
bthread_usleepFunction · 0.85
IsStopMethod · 0.80
latencyMethod · 0.80
latency_percentileMethod · 0.80
storeMethod · 0.45
InitMethod · 0.45
push_backMethod · 0.45
loadMethod · 0.45

Tested by

no test coverage detected