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