From 5088ef73ebe0049b5440b9216e9eb8a63e0096d0 Mon Sep 17 00:00:00 2001
From: Craig Tiller <ctiller@google.com>
Date: Wed, 19 Apr 2017 14:39:11 -0700
Subject: [PATCH] Refine warmup

---
 test/cpp/microbenchmarks/bm_fullstack_trickle.cc | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/test/cpp/microbenchmarks/bm_fullstack_trickle.cc b/test/cpp/microbenchmarks/bm_fullstack_trickle.cc
index 269bfd658d..e321de0e53 100644
--- a/test/cpp/microbenchmarks/bm_fullstack_trickle.cc
+++ b/test/cpp/microbenchmarks/bm_fullstack_trickle.cc
@@ -48,9 +48,12 @@ extern "C" {
 }
 
 DEFINE_bool(log, false, "Log state to CSV files");
+DEFINE_int32(
+    warmup_megabytes, 10,
+    "Number of megabytes to pump before collecting flow control stats");
 DEFINE_int32(
     warmup_iterations, 100,
-    "Number of iterations to warm up before collecting flow control stats");
+    "Number of megabytes to pump before collecting flow control stats");
 
 namespace grpc {
 namespace testing {
@@ -280,7 +283,10 @@ static void BM_PumpStreamServerToClient_Trickle(benchmark::State& state) {
         }
       }
     };
-    for (int i = 0; i < FLAGS_warmup_iterations; i++) {
+    for (int i = 0;
+         i < GPR_MAX(FLAGS_warmup_iterations, FLAGS_warmup_megabytes * 1024 *
+                                                  1024 / (14 + state.range(0)));
+         i++) {
       inner_loop(true);
     }
     while (state.KeepRunning()) {
@@ -306,7 +312,7 @@ static void BM_PumpStreamServerToClient_Trickle(benchmark::State& state) {
 
 static void TrickleArgs(benchmark::internal::Benchmark* b) {
   for (int i = 1; i <= 128 * 1024 * 1024; i *= 8) {
-    for (int j = 1; j <= 128 * 1024 * 1024; j *= 8) {
+    for (int j = 64; j <= 128 * 1024 * 1024; j *= 8) {
       double expected_time =
           static_cast<double>(14 + i) / (125.0 * static_cast<double>(j));
       if (expected_time > 2.0) continue;
-- 
GitLab