Commit 7c56f0dd authored by ager@chromium.org's avatar ager@chromium.org

Fix benchmarks to not format scores that are really errors.

Uploading for Kasper.
Review URL: http://codereview.chromium.org/17641

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@1061 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 0fad6259
......@@ -120,7 +120,8 @@ BenchmarkSuite.RunSuites = function(runner) {
}
if (runner.NotifyScore) {
var score = BenchmarkSuite.GeometricMean(BenchmarkSuite.scores);
runner.NotifyScore(100 * score);
var formatted = BenchmarkSuite.FormatScore(100 * score);
runner.NotifyScore(formatted);
}
}
RunStep();
......@@ -149,6 +150,16 @@ BenchmarkSuite.GeometricMean = function(numbers) {
}
// Converts a score value to a string with at least three significant
// digits.
BenchmarkSuite.FormatScore = function(value) {
if (value > 100) {
return value.toFixed(0);
} else {
return value.toPrecision(3);
}
}
// Notifies the runner that we're done running a single benchmark in
// the benchmark suite. This can be useful to report progress.
BenchmarkSuite.prototype.NotifyStep = function(result) {
......@@ -164,7 +175,8 @@ BenchmarkSuite.prototype.NotifyResult = function() {
var score = this.reference / mean;
BenchmarkSuite.scores.push(score);
if (this.runner.NotifyResult) {
this.runner.NotifyResult(this.name, 100 * score);
var formatted = BenchmarkSuite.FormatScore(100 * score);
this.runner.NotifyResult(this.name, formatted);
}
}
......@@ -219,14 +231,3 @@ BenchmarkSuite.prototype.RunStep = function(runner) {
}
return RunNext();
}
// Converts a score value to a string with at least three significant
// digits.
function formatScore(value) {
if (value > 100) {
return value.toFixed(0);
} else {
return value.toPrecision(3);
}
}
......@@ -21,7 +21,7 @@ function ShowProgress(name) {
function AddResult(name, result) {
var text = name + ': ' + formatScore(result);
var text = name + ': ' + result;
var results = document.getElementById("results");
results.innerHTML += (text + "<br/>");
}
......@@ -36,7 +36,7 @@ function AddError(name, error) {
function AddScore(score) {
var status = document.getElementById("status");
if (success) {
status.innerHTML = "Score: " + formatScore(score);
status.innerHTML = "Score: " + score;
}
}
......
......@@ -36,7 +36,7 @@ load('earley-boyer.js');
var success = true;
function PrintResult(name, result) {
print(name + ': ' + formatScore(result));
print(name + ': ' + result);
}
......@@ -49,8 +49,7 @@ function PrintError(name, error) {
function PrintScore(score) {
if (success) {
print('----');
print('Score (version ' + BenchmarkSuite.version + '): '
+ formatScore(score));
print('Score (version ' + BenchmarkSuite.version + '): ' + score);
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment