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

Method Update

example/auto_concurrency_limiter/client.cpp:127–151  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

125 }
126
127 bool Update() {
128 if (butil::cpuwide_time_s() >= next_stage_sec) {
129 ++stage_index;
130 if (stage_index < test_case.qps_stage_list_size()) {
131 next_stage_sec += test_case.qps_stage_list(stage_index).duration_sec();
132 DisplayStage(test_case.qps_stage_list(stage_index));
133 } else {
134 return false;
135 }
136 }
137
138 int qps = 0;
139 const test::Stage& qps_stage = test_case.qps_stage_list(stage_index);
140 const int lower_bound = qps_stage.lower_bound();
141 const int upper_bound = qps_stage.upper_bound();
142 if (qps_stage.type() == test::FLUCTUATE) {
143 qps = butil::fast_rand_less_than(upper_bound - lower_bound) + lower_bound;
144 } else if (qps_stage.type() == test::SMOOTH) {
145 qps = lower_bound + (upper_bound - lower_bound) /
146 double(qps_stage.duration_sec()) * (qps_stage.duration_sec() - next_stage_sec
147 + butil::cpuwide_time_s());
148 }
149 interval_us.store(1.0 / qps * 1000000, butil::memory_order_relaxed);
150 return true;
151 }
152
153 butil::atomic<bool> running;
154 butil::atomic<int64_t> interval_us;

Callers 1

RunUpdateTaskFunction · 0.45

Calls 5

cpuwide_time_sFunction · 0.85
fast_rand_less_thanFunction · 0.85
DisplayStageFunction · 0.70
typeMethod · 0.45
storeMethod · 0.45

Tested by

no test coverage detected