diff options
author | ncteisen <ncteisen@gmail.com> | 2017-05-09 15:50:32 -0700 |
---|---|---|
committer | ncteisen <ncteisen@gmail.com> | 2017-05-09 15:50:32 -0700 |
commit | c7de5a760109cdb048552aeabc9b68b238f1843f (patch) | |
tree | 9c3e6c41df4a693721455c4e51d912918f9d04db /test/cpp/microbenchmarks | |
parent | 0725d3a4b385f0213a1058037443f5c016b823c4 (diff) |
Add warmup
Diffstat (limited to 'test/cpp/microbenchmarks')
-rw-r--r-- | test/cpp/microbenchmarks/bm_fullstack_trickle.cc | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/test/cpp/microbenchmarks/bm_fullstack_trickle.cc b/test/cpp/microbenchmarks/bm_fullstack_trickle.cc index db07a553e3..05fea06f44 100644 --- a/test/cpp/microbenchmarks/bm_fullstack_trickle.cc +++ b/test/cpp/microbenchmarks/bm_fullstack_trickle.cc @@ -53,7 +53,7 @@ DEFINE_int32( "Number of megabytes to pump before collecting flow control stats"); DEFINE_int32( warmup_iterations, 100, - "Number of megabytes to pump before collecting flow control stats"); + "Number of iterations to run before collecting flow control stats"); DEFINE_int32(warmup_max_time_seconds, 10, "Maximum number of seconds to run warmup loop"); @@ -366,7 +366,7 @@ static void BM_PumpUnbalancedUnary_Trickle(benchmark::State& state) { fixture->cq(), tag(1)); std::unique_ptr<EchoTestService::Stub> stub( EchoTestService::NewStub(fixture->channel())); - while (state.KeepRunning()) { + auto inner_loop = [&](bool in_warmup) { GPR_TIMER_SCOPE("BenchmarkCycle", 0); recv_response.Clear(); ClientContext cli_ctx; @@ -394,6 +394,21 @@ static void BM_PumpUnbalancedUnary_Trickle(benchmark::State& state) { senv = new (senv) ServerEnv(); service.RequestEcho(&senv->ctx, &senv->recv_request, &senv->response_writer, fixture->cq(), fixture->cq(), tag(slot)); + }; + 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); } fixture->Finish(state); fixture.reset(); |