Commit 994eb59d authored by hablich's avatar hablich Committed by Commit bot

Micro benchmark for Try-Catch-Finally

BUG=v8:4131
LOG=n

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

Cr-Commit-Position: refs/heads/master@{#28789}
parent 68beef53
// Copyright 2015 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
load('../base.js');
load('try-catch.js');
var success = true;
function PrintResult(name, result) {
print(name + '-Exceptions(Score): ' + result);
}
function PrintError(name, error) {
PrintResult(name, error);
success = false;
}
BenchmarkSuite.config.doWarmup = undefined;
BenchmarkSuite.config.doDeterministic = undefined;
BenchmarkSuite.RunSuites({ NotifyResult: PrintResult,
NotifyError: PrintError });
// Copyright 2015 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
new BenchmarkSuite('Try-Catch', [1000], [
new Benchmark('OnSuccess', false, false, 0,
OnSuccess, OnSuccessSetup,
OnSuccessTearDown),
new Benchmark('OnException', false, false, 0,
OnException, OnExceptionSetup,
OnExceptionTearDown),
new Benchmark('OnSuccessFinallyOnly', false, false, 0,
OnSuccessFinallyOnly, OnSuccessFinallyOnlySetup,
OnSuccessFinallyOnlyTearDown),
new Benchmark('WithFinallyOnException', false, false, 0,
WithFinallyOnException, WithFinallyOnExceptionSetup, WithFinallyOnExceptionTearDown)
]);
var a;
var b;
var c;
// ----------------------------------------------------------------------------
function OnSuccessSetup() {
var a = 4;
var b = 6;
var c = 0;
}
function OnSuccess() {
try {
c = a + b;
}
catch (e) {
}
}
function OnSuccessTearDown() {
return c === 10;
}
// ----------------------------------------------------------------------------
function OnExceptionSetup() {
var a = 4;
var b = 6;
var c = 0;
}
function OnException() {
try {
throw 'Test exception';
}
catch (e) {
c = a + b;
}
}
function OnExceptionTearDown() {
return c === 10;
}
// ----------------------------------------------------------------------------
function OnSuccessFinallyOnlySetup() {
var a = 4;
var b = 6;
var c = 0;
}
function OnSuccessFinallyOnly() {
try {
c = a + b;
}
finally {
c++;
}
}
function OnSuccessFinallyOnlyTearDown() {
return c === 11;
}
// ----------------------------------------------------------------------------
function WithFinallyOnExceptionSetup() {
var a = 4;
var b = 6;
var c = 0;
}
function WithFinallyOnException() {
try {
throw 'Test exception';
}
catch (e) {
c = a + b;
}
finally {
c++;
}
}
function WithFinallyOnExceptionTearDown() {
return c === 11;
}
// ----------------------------------------------------------------------------
......@@ -116,6 +116,16 @@
"tests": [
{"name": "With"}
]
},
{
"name": "Exceptions",
"path": ["Exceptions"],
"main": "run.js",
"resources": ["try-catch.js"],
"results_regexp": "^%s\\-Exceptions\\(Score\\): (.+)$",
"tests": [
{"name": "Try-Catch"}
]
}
]
}
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