Skip to content

Commit 79739d9

Browse files
committed
extra::test: handle slow benchmarks more gracefully.
This makes sure we always run benchmarks even if they are predicted to take a long time, so that we have some non-zero time to display (although the error bars may be huge for particularly slow benchmarks). Fixes #9532.
1 parent 9bbef13 commit 79739d9

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/libextra/test.rs

+10-1
Original file line numberDiff line numberDiff line change
@@ -1110,6 +1110,15 @@ impl BenchHarness {
11101110
} else {
11111111
n = 1_000_000 / self.ns_per_iter().max(&1);
11121112
}
1113+
// if the first run took more than 1ms we don't want to just
1114+
// be left doing 0 iterations on every loop. The unfortunate
1115+
// side effect of not being able to do as many runs is
1116+
// automatically handled by the statistical analysis below
1117+
// (i.e. larger error bars).
1118+
if n == 0 { n = 1; }
1119+
1120+
debug!("Initial run took {} ns, iter count that takes 1ms estimated as {}",
1121+
self.ns_per_iter(), n);
11131122
11141123
let mut total_run = 0;
11151124
let samples : &mut [f64] = [0.0_f64, ..50];
@@ -1141,7 +1150,7 @@ impl BenchHarness {
11411150
let now = precise_time_ns();
11421151
let loop_run = now - loop_start;
11431152
1144-
// If we've run for 100ms an seem to have converged to a
1153+
// If we've run for 100ms and seem to have converged to a
11451154
// stable median.
11461155
if loop_run > 100_000_000 &&
11471156
summ.median_abs_dev_pct < 1.0 &&

0 commit comments

Comments
 (0)