mirror of https://github.com/google/benchmark.git
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.
This commit is contained in:
parent
ab74ae5e10
commit
1067dfc91e
|
@ -239,8 +239,7 @@ IterationCount BenchmarkRunner::PredictNumItersNeeded(
|
||||||
// NOTE: When the last run was at least 10% of the min time the max
|
// NOTE: When the last run was at least 10% of the min time the max
|
||||||
// expansion should be 14x.
|
// expansion should be 14x.
|
||||||
bool is_significant = (i.seconds / min_time) > 0.1;
|
bool is_significant = (i.seconds / min_time) > 0.1;
|
||||||
multiplier = is_significant ? multiplier : std::min(10.0, multiplier);
|
multiplier = is_significant ? multiplier : 10.0;
|
||||||
if (multiplier <= 1.0) multiplier = 2.0;
|
|
||||||
|
|
||||||
// So what seems to be the sufficiently-large iteration count? Round up.
|
// So what seems to be the sufficiently-large iteration count? Round up.
|
||||||
const IterationCount max_next_iters = static_cast<IterationCount>(
|
const IterationCount max_next_iters = static_cast<IterationCount>(
|
||||||
|
|
Loading…
Reference in New Issue