wwbmmm commented on code in PR #1763:
URL: https://github.com/apache/incubator-brpc/pull/1763#discussion_r874306362
##########
tools/rpc_press/rpc_press_impl.cpp:
##########
@@ -247,21 +242,12 @@ void RpcPress::sync_client() {
if (_options.test_req_rate <= 0) {
brpc::Join(cid1);
} else {
- int64_t end_time = butil::gettimeofday_us();
- int64_t expected_elp = 0;
- int64_t actual_elp = 0;
- timeq.push_back(end_time);
- if (timeq.size() > MAX_QUEUE_SIZE) {
- actual_elp = end_time - timeq.front();
- timeq.pop_front();
- expected_elp = (int64_t)(1000000 * timeq.size() / req_rate);
- } else {
- actual_elp = end_time - timeq.front();
- expected_elp = (int64_t)(1000000 * (timeq.size() - 1) /
req_rate);
- }
- if (actual_elp < expected_elp) {
- usleep(expected_elp - actual_elp);
+ int64_t end_time = butil::monotonic_time_ns();
+ int64_t expected_time = last_expected_time + interval;
+ if (end_time < expected_time) {
+
std::this_thread::sleep_for(std::chrono::nanoseconds(expected_time - end_time));
Review Comment:
保持代码风格一致吧,brpc其它地方sleep的时候都是用的usleep
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]