@@ -413,6 +413,7 @@ struct ClientStats {
413413 base::Histogram total_hist, online_hist;
414414
415415 uint64_t num_responses = 0 ;
416+ uint64_t qps = 0 ;
416417 uint64_t hit_count = 0 ;
417418 uint64_t hit_opportunities = 0 ;
418419 uint64_t num_errors = 0 ;
@@ -423,10 +424,12 @@ struct ClientStats {
423424 online_hist.Merge (o.online_hist );
424425
425426 num_responses += o.num_responses ;
427+ qps += o.qps ;
426428 hit_count += o.hit_count ;
427429 hit_opportunities += o.hit_opportunities ;
428430 num_errors += o.num_errors ;
429431 num_clients += o.num_clients ;
432+
430433 return *this ;
431434 }
432435};
@@ -789,6 +792,7 @@ void Driver::PopRequest() {
789792}
790793
791794void Driver::ReceiveFb () {
795+ uint64_t now = absl::GetCurrentTimeNanos ();
792796 while (true ) {
793797 io_buf_.EnsureCapacity (256 );
794798 auto buf = io_buf_.AppendBuffer ();
@@ -813,6 +817,9 @@ void Driver::ReceiveFb() {
813817 ParseMC ();
814818 }
815819 }
820+ double usec = (absl::GetCurrentTimeNanos () - now) / 1000 ;
821+ if (usec > 0 )
822+ stats_.qps += uint64_t (double (received_) * 1e6 / usec);
816823 VLOG (1 ) << " ReceiveFb done" ;
817824}
818825
@@ -1218,9 +1225,9 @@ int main(int argc, char* argv[]) {
12181225 CHECK_LE (key_minimum, key_maximum);
12191226
12201227 uint32_t thread_key_step = 0 ;
1221- uint32_t qps = abs (GetFlag (FLAGS_qps));
1228+ uint32_t desired_qps = abs (GetFlag (FLAGS_qps));
12221229 bool throttle = GetFlag (FLAGS_qps) > 0 ;
1223- const int64_t interval = qps ? 1'000'000'000LL / qps : 0 ;
1230+ const int64_t interval = desired_qps ? 1'000'000'000LL / desired_qps : 0 ;
12241231 uint64_t num_reqs = GetFlag (FLAGS_n);
12251232
12261233 uint64_t total_conn_num = GetFlag (FLAGS_c) * pp->size ();
@@ -1242,9 +1249,9 @@ int main(int argc, char* argv[]) {
12421249 << (throttle ? " with" : " without" ) << " throttling" ;
12431250 }
12441251 if (interval) {
1245- CONSOLE_INFO << " At a rate of " << qps << " rps per connection, i.e. request every "
1252+ CONSOLE_INFO << " At a rate of " << desired_qps << " rps per connection, i.e. request every "
12461253 << interval / 1000 << " us" ;
1247- CONSOLE_INFO << " Overall scheduled RPS: " << qps * total_conn_num;
1254+ CONSOLE_INFO << " Overall scheduled RPS: " << desired_qps * total_conn_num;
12481255 } else {
12491256 CONSOLE_INFO << " Coordinated omission mode - the rate is determined by the server" ;
12501257 }
@@ -1281,12 +1288,10 @@ int main(int argc, char* argv[]) {
12811288 client.reset ();
12821289 });
12831290
1284- unsigned dur_sec = duration / absl::Seconds (1 );
1285-
12861291 CONSOLE_INFO << " \n Total time: " << duration
12871292 << " . Overall number of requests: " << summary.num_responses
1288- << " , QPS: " << (dur_sec ? StrCat ( summary.num_responses / dur_sec) : " nan " )
1289- << " , P99 lat: " << summary. total_hist . Percentile ( 99 ) << " us" ;
1293+ << " , QPS: " << summary.qps << " , P99 lat : " << summary. total_hist . Percentile ( 99 )
1294+ << " us" ;
12901295
12911296 if (summary.num_errors ) {
12921297 CONSOLE_INFO << " Got " << summary.num_errors << " error responses!" ;
0 commit comments