about summary refs log tree commit diff
path: root/src/libextra
diff options
context:
space:
mode:
authorHuon Wilson <dbau.pp+github@gmail.com>2013-12-13 22:51:11 +1100
committerHuon Wilson <dbau.pp+github@gmail.com>2013-12-13 23:18:55 +1100
commit79739d96f79b53a17bd79ab811efd5adfddf3a26 (patch)
treefd26ffafa731ad5659aad0b3f4ad2df9b6375396 /src/libextra
parent9bbef13702561b955bc1fd71608502d3a10a4acc (diff)
downloadrust-79739d96f79b53a17bd79ab811efd5adfddf3a26.tar.gz
rust-79739d96f79b53a17bd79ab811efd5adfddf3a26.zip
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.
Diffstat (limited to 'src/libextra')
-rw-r--r--src/libextra/test.rs11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/libextra/test.rs b/src/libextra/test.rs
index 1bda69360c2..c2b4ff05d5d 100644
--- a/src/libextra/test.rs
+++ b/src/libextra/test.rs
@@ -1110,6 +1110,15 @@ impl BenchHarness {
         } else {
             n = 1_000_000 / self.ns_per_iter().max(&1);
         }
+        // if the first run took more than 1ms we don't want to just
+        // be left doing 0 iterations on every loop. The unfortunate
+        // side effect of not being able to do as many runs is
+        // automatically handled by the statistical analysis below
+        // (i.e. larger error bars).
+        if n == 0 { n = 1; }
+
+        debug!("Initial run took {} ns, iter count that takes 1ms estimated as {}",
+               self.ns_per_iter(), n);
 
         let mut total_run = 0;
         let samples : &mut [f64] = [0.0_f64, ..50];
@@ -1141,7 +1150,7 @@ impl BenchHarness {
             let now = precise_time_ns();
             let loop_run = now - loop_start;
 
-            // If we've run for 100ms an seem to have converged to a
+            // If we've run for 100ms and seem to have converged to a
             // stable median.
             if loop_run > 100_000_000 &&
                 summ.median_abs_dev_pct < 1.0 &&