From 1067dfc91e45c842c5dd885ac0092d02b88f3797 Mon Sep 17 00:00:00 2001 From: Braedy Date: Thu, 29 Jul 2021 01:59:46 -0600 Subject: [PATCH] Remove dead code from PredictNumItersNeeded (#1206) * Remove `min` with dead path. When `isSignificant` is false, the smallest value `multiplier` can approach is 14. Thus, min(10, multiplier) will always return 10. Addresses part one of #1205. * Remove always false condition. 1. `multiplier <= 1.0` implies `i.seconds >= min_time * 1.4` 2. By (1), `isSignficant` is true because `i.seconds > min_time * 1.4` implies `i.seconds > min_time` implies that `i.seconds / minTime > 1 > 0.1`. Thus, the ternary maintains the same multiplier value. 3. `ShouldReportResults` is always called before `PredictNumItersNeeded`, if `i.seconds >= min_time` then the loop is broken and `PredictNumItersNeeded` is never called. 4. 1 and 3 together imply that `multiplier <= 1.0` is never true. Addresses part 2 of #1205. --- src/benchmark_runner.cc | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/benchmark_runner.cc b/src/benchmark_runner.cc index 334d746e..ead5c5a2 100644 --- a/src/benchmark_runner.cc +++ b/src/benchmark_runner.cc @@ -239,8 +239,7 @@ IterationCount BenchmarkRunner::PredictNumItersNeeded( // NOTE: When the last run was at least 10% of the min time the max // expansion should be 14x. bool is_significant = (i.seconds / min_time) > 0.1; - multiplier = is_significant ? multiplier : std::min(10.0, multiplier); - if (multiplier <= 1.0) multiplier = 2.0; + multiplier = is_significant ? multiplier : 10.0; // So what seems to be the sufficiently-large iteration count? Round up. const IterationCount max_next_iters = static_cast(