Fix benchmarks to not format scores that are really errors.
authorager@chromium.org <ager@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Tue, 13 Jan 2009 09:27:47 +0000 (09:27 +0000)
committerager@chromium.org <ager@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Tue, 13 Jan 2009 09:27:47 +0000 (09:27 +0000)
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

benchmarks/base.js
benchmarks/run.html
benchmarks/run.js

index 5afc110..6e1ff8c 100644 (file)
@@ -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);
-  }
-}
index d521e0b..01cadc0 100644 (file)
@@ -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;
   }
 }
 
index ecfee90..da2373b 100644 (file)
@@ -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);
   }
 }