Adjust benchmark framework to avoid spending 50% of time on 'new Date'
authorerikcorry <erikcorry@chromium.org>
Tue, 19 May 2015 11:19:53 +0000 (04:19 -0700)
committerCommit bot <commit-bot@chromium.org>
Tue, 19 May 2015 11:19:36 +0000 (11:19 +0000)
R=dslomov@chromium.org
BUG=

Review URL: https://codereview.chromium.org/1133843007

Cr-Commit-Position: refs/heads/master@{#28476}

test/js-perf-test/base.js

index b0ce40b..cef2867 100644 (file)
@@ -281,28 +281,28 @@ BenchmarkSuite.prototype.RunSingleBenchmark = function(benchmark, data) {
   // by minIterations, depending on the config flag doDeterministic.
     for (var i = 0; (doDeterministic ?
       i<benchmark.deterministicIterations : elapsed < 1000); i++) {
-      benchmark.run();
+      for (var j = 0; j < 100; j++) benchmark.run();
       elapsed = new Date() - start;
     }
     if (data != null) {
-      data.runs += i;
+      data.hectoruns += i;
       data.elapsed += elapsed;
     }
   }
 
   // Sets up data in order to skip or not the warmup phase.
   if (!doWarmup && data == null) {
-    data = { runs: 0, elapsed: 0 };
+    data = { hectoruns: 0, elapsed: 0 };
   }
 
   if (data == null) {
     Measure(null);
-    return { runs: 0, elapsed: 0 };
+    return { hectoruns: 0, elapsed: 0 };
   } else {
     Measure(data);
     // If we've run too few iterations, we continue for another second.
-    if (data.runs < benchmark.minIterations) return data;
-    var usec = (data.elapsed * 1000) / data.runs;
+    if (data.hectoruns * 100 < benchmark.minIterations) return data;
+    var usec = (data.elapsed * 10) / data.hectoruns;
     var rms = (benchmark.rmsResult != null) ? benchmark.rmsResult() : 0;
     this.NotifyStep(new BenchmarkResult(benchmark, usec, rms));
     return null;