Improve error reporting in benchmarks.
authorkasperl@chromium.org <kasperl@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Wed, 22 Oct 2008 11:55:08 +0000 (11:55 +0000)
committerkasperl@chromium.org <kasperl@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Wed, 22 Oct 2008 11:55:08 +0000 (11:55 +0000)
Review URL: http://codereview.chromium.org/8053

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@553 ce2b1a6d-e550-0410-aec6-3dcde31c8c00

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

index f02398d..2c26132 100644 (file)
@@ -169,6 +169,17 @@ BenchmarkSuite.prototype.NotifyResult = function() {
 }
 
 
+// Notifies the runner that running a benchmark resulted in an error.
+BenchmarkSuite.prototype.NotifyError = function(error) {
+  if (this.runner.NotifyError) {
+    this.runner.NotifyError(this.name, error);
+  }
+  if (this.runner.NotifyStep) {
+    this.runner.NotifyStep(this.name);
+  }
+}
+
+
 // Runs a single benchmark for at least a second and computes the
 // average time it takes to run a single iteration.
 BenchmarkSuite.prototype.RunSingle = function(benchmark) {
@@ -195,7 +206,12 @@ BenchmarkSuite.prototype.RunStep = function(runner) {
   var suite = this;
   function RunNext() {
     if (index < length) {
-      suite.RunSingle(suite.benchmarks[index++]);
+      try {
+        suite.RunSingle(suite.benchmarks[index++]);
+      } catch (e) {
+        suite.NotifyError(e);
+        return null;
+      }
       return RunNext;
     }
     suite.NotifyResult();
index 2d49dbc..41e4f78 100644 (file)
@@ -63,6 +63,8 @@ div.run {
 <script type="text/javascript">
 var completed = 0;
 var benchmarks = BenchmarkSuite.CountBenchmarks();
+var success = true;
+
 function ShowProgress(name) {
   var status = document.getElementById("status");
   var percentage = ((++completed) / benchmarks) * 100;
@@ -77,14 +79,23 @@ function AddResult(name, result) {
 }
 
 
+function AddError(name, error) {
+  AddResult(name, '<b>error</b>');
+  success = false;
+}
+
+
 function AddScore(score) {
   var status = document.getElementById("status");
-  status.innerHTML = "Score: " + score;
+  if (success) {
+    status.innerHTML = "Score: " + score;
+  }
 }
 
 
 function Run() {
   BenchmarkSuite.RunSuites({ NotifyStep: ShowProgress,
+                             NotifyError: AddError,
                              NotifyResult: AddResult,
                              NotifyScore: AddScore }); 
 }
index f73f1af..da2373b 100644 (file)
@@ -33,17 +33,27 @@ load('crypto.js');
 load('raytrace.js');
 load('earley-boyer.js');
 
+var success = true;
 
 function PrintResult(name, result) {
   print(name + ': ' + result);
 }
 
 
+function PrintError(name, error) {
+  PrintResult(name, error);
+  success = false;
+}
+
+
 function PrintScore(score) {
-  print('----');
-  print('Score (version ' + BenchmarkSuite.version + '): ' + score);
+  if (success) {
+    print('----');
+    print('Score (version ' + BenchmarkSuite.version + '): ' + score);
+  }
 }
 
 
 BenchmarkSuite.RunSuites({ NotifyResult: PrintResult,
+                           NotifyError: PrintError,
                            NotifyScore: PrintScore });