node/deps/v8/test/js-perf-test/Exceptions/try-catch.js
Ali Ijaz Sheikh 9fddd83cf9 deps: upgrade V8 to 4.5.103.24
Upgrade to the latest branch-head for V8 4.5. For the full commit log see
https://github.com/v8/v8-git-mirror/commits/4.5.103.24

PR-URL: https://github.com/nodejs/node/pull/2509
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2015-09-06 21:38:01 +10:00

111 lines
2.1 KiB
JavaScript

// 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() {
a = 4;
b = 6;
c = 0;
}
function OnSuccess() {
try {
c = a + b;
}
catch (e) {
c++;
}
}
function OnSuccessTearDown() {
return c === 10;
}
// ----------------------------------------------------------------------------
function OnExceptionSetup() {
a = 4;
b = 6;
c = 0;
}
function OnException() {
try {
throw 'Test exception';
}
catch (e) {
c = a + b;
}
}
function OnExceptionTearDown() {
return c === 10;
}
// ----------------------------------------------------------------------------
function OnSuccessFinallyOnlySetup() {
a = 4;
b = 6;
c = 0;
}
function OnSuccessFinallyOnly() {
try {
c = a + b;
}
finally {
c++;
}
}
function OnSuccessFinallyOnlyTearDown() {
return c === 11;
}
// ----------------------------------------------------------------------------
function WithFinallyOnExceptionSetup() {
a = 4;
b = 6;
c = 0;
}
function WithFinallyOnException() {
try {
throw 'Test exception';
}
catch (e) {
c = a + b;
}
finally {
c++;
}
}
function WithFinallyOnExceptionTearDown() {
return c === 11;
}
// ----------------------------------------------------------------------------