Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(10)

Unified Diff: test/js-perf-test/Exceptions/try-catch.js

Issue 1155493007: Micro benchmark for Try-Catch-Finally (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fixed formatting nit Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « test/js-perf-test/Exceptions/run.js ('k') | test/js-perf-test/JSTests.json » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/js-perf-test/Exceptions/try-catch.js
diff --git a/test/js-perf-test/Exceptions/try-catch.js b/test/js-perf-test/Exceptions/try-catch.js
new file mode 100644
index 0000000000000000000000000000000000000000..8c9734eb34307e3b326cd56fb98f111478cb1814
--- /dev/null
+++ b/test/js-perf-test/Exceptions/try-catch.js
@@ -0,0 +1,108 @@
+// 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)
arv (Not doing code reviews) 2015/06/03 14:10:00 Long line
Michael Hablich 2015/06/03 14:26:47 Done.
+]);
+
+var a;
+var b;
+var c;
+
+// ----------------------------------------------------------------------------
+
+function OnSuccessSetup() {
+ var a = 4;
arv (Not doing code reviews) 2015/06/03 14:10:00 What is the point of this setup function? It creat
Michael Hablich 2015/06/03 14:26:48 *facepalm* fixed.
+ var b = 6;
+ var c = 0;
+}
+
+function OnSuccess() {
+ try {
+ c = a + b;
+ }
+ catch (e) {
+ }
+}
+
+function OnSuccessTearDown() {
+ return c === 10;
arv (Not doing code reviews) 2015/06/03 14:10:00 This will return false because c is NaN
Michael Hablich 2015/06/03 14:26:47 Done.
+}
+
+// ----------------------------------------------------------------------------
+
+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;
+}
+// ----------------------------------------------------------------------------
« no previous file with comments | « test/js-perf-test/Exceptions/run.js ('k') | test/js-perf-test/JSTests.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698