MCPcopy Create free account
hub / github.com/alibaba/euler / ParallelQuery

Method ParallelQuery

euler/client/rpc_manager_test.cc:31–55  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

29 }
30
31 void ParallelQuery(int num_threads,
32 int num_times_per_replica, int num_replicas,
33 std::vector<std::atomic_int> *counters) {
34 EXPECT_EQ(0, num_replicas * num_times_per_replica % num_threads);
35 int num_times = num_replicas * num_times_per_replica / num_threads;
36 std::vector<std::thread> threads;
37 for (int i = 0; i < num_threads; ++i) {
38 threads.emplace_back(
39 [num_times, counters, this] {
40 std::vector<int> local_counters(counters->size());
41 for (int i = 0; i < num_times; ++i) {
42 const std::string &host_port =
43 rpc_manager_.GetChannel()->host_port();
44 ++local_counters[std::stoi(host_port)];
45 }
46 for (size_t i = 0; i < counters->size(); ++i) {
47 (*counters)[i] += local_counters[i];
48 }
49 });
50 }
51
52 for (auto &thread : threads) {
53 thread.join();
54 }
55 }
56
57 testing::MockRpcManager rpc_manager_;
58 std::shared_ptr<ServerRegister> regs_;

Callers

nothing calls this directly

Calls 3

GetChannelMethod · 0.80
sizeMethod · 0.45
host_portMethod · 0.45

Tested by

no test coverage detected