}
+// 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) {
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();
<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;
}
+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 });
}
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 });