diff options
author | Craig Tiller <ctiller@google.com> | 2017-04-19 14:47:27 -0700 |
---|---|---|
committer | Craig Tiller <ctiller@google.com> | 2017-04-19 14:47:27 -0700 |
commit | 3b7216304286dcf4d925cfefc57a796dd3b891bd (patch) | |
tree | 884d15b69ea5b3696f18208b615f5489bf601233 | |
parent | 47f6dc732db83a5aa183f2f67a5bd66b3f94069b (diff) |
Clamp warmup time in seconds
-rw-r--r-- | test/cpp/microbenchmarks/bm_fullstack_trickle.cc | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/test/cpp/microbenchmarks/bm_fullstack_trickle.cc b/test/cpp/microbenchmarks/bm_fullstack_trickle.cc index 2bf1c931e6..fc99b06dbb 100644 --- a/test/cpp/microbenchmarks/bm_fullstack_trickle.cc +++ b/test/cpp/microbenchmarks/bm_fullstack_trickle.cc @@ -54,6 +54,8 @@ DEFINE_int32( DEFINE_int32( warmup_iterations, 100, "Number of megabytes to pump before collecting flow control stats"); +DEFINE_int32(warmup_max_time_seconds, 10, + "Maximum number of seconds to run warmup loop"); namespace grpc { namespace testing { @@ -283,11 +285,17 @@ static void BM_PumpStreamServerToClient_Trickle(benchmark::State& state) { } } }; + gpr_timespec warmup_start = gpr_now(GPR_CLOCK_MONOTONIC); for (int i = 0; i < GPR_MAX(FLAGS_warmup_iterations, FLAGS_warmup_megabytes * 1024 * 1024 / (14 + state.range(0))); i++) { inner_loop(true); + if (gpr_time_cmp(gpr_time_sub(gpr_now(GPR_CLOCK_MONOTONIC), warmup_start), + gpr_time_from_seconds(FLAGS_warmup_max_time_seconds, + GPR_TIMESPAN)) > 0) { + break; + } } while (state.KeepRunning()) { inner_loop(false); |