Adjust benchmark framework to avoid spending 50% of time on 'new Date'

R=dslomov@chromium.org
BUG=

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

Cr-Commit-Position: refs/heads/master@{#28476}
This commit is contained in:
erikcorry 2015-05-19 04:19:53 -07:00 committed by Commit bot
parent e5227ba5c3
commit 8cb1c3540c

View 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;