OLD | NEW |
1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 new BenchmarkSuite('Basic1', [1000], [ | 5 new BenchmarkSuite('Basic1', [1000], [ |
6 new Benchmark('BasicRest1', false, false, 0, | 6 new Benchmark('BasicRest1', false, false, 0, |
7 BasicRest1, BasicRest1Setup, BasicRest1TearDown) | 7 BasicRest1, BasicRest1Setup, BasicRest1TearDown) |
8 ]); | 8 ]); |
9 | 9 |
| 10 new BenchmarkSuite('ReturnArgsBabel', [10000], [ |
| 11 new Benchmark('ReturnArgsBabel', false, false, 0, |
| 12 ReturnArgsBabel, ReturnArgsBabelSetup, |
| 13 ReturnArgsBabelTearDown) |
| 14 ]); |
| 15 |
| 16 new BenchmarkSuite('ReturnArgsNative', [10000], [ |
| 17 new Benchmark('ReturnArgsNative', false, false, 0, |
| 18 ReturnArgsNative, ReturnArgsNativeSetup, |
| 19 ReturnArgsNativeTearDown) |
| 20 ]); |
| 21 |
10 // ---------------------------------------------------------------------------- | 22 // ---------------------------------------------------------------------------- |
11 | 23 |
12 var result; | 24 var result; |
13 | 25 |
14 function basic_rest_fn_1(factor, ...values) { | 26 function basic_rest_fn_1(factor, ...values) { |
15 var result = 0; | 27 var result = 0; |
16 for (var i = 0; i < values.length; ++i) { | 28 for (var i = 0; i < values.length; ++i) { |
17 result += (factor * values[i]); | 29 result += (factor * values[i]); |
18 } | 30 } |
19 return result; | 31 return result; |
20 } | 32 } |
21 | 33 |
22 function BasicRest1Setup() {} | 34 function BasicRest1Setup() {} |
23 | 35 |
24 function BasicRest1() { | 36 function BasicRest1() { |
25 result = basic_rest_fn_1(10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10); | 37 result = basic_rest_fn_1(10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10); |
26 } | 38 } |
27 | 39 |
28 function BasicRest1TearDown() { | 40 function BasicRest1TearDown() { |
29 return result == 550; | 41 return result == 550; |
30 } | 42 } |
| 43 |
| 44 // ---------------------------------------------------------------------------- |
| 45 |
| 46 var length = 50; |
| 47 var numbers = Array.apply(null, {length}).map(Number.call, Number); |
| 48 var strings = numbers.map(String.call, String); |
| 49 |
| 50 function ReturnArgsBabelFunction(unused) { |
| 51 "use strict"; |
| 52 for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), |
| 53 _key = 1; |
| 54 _key < _len; _key++) { |
| 55 args[_key - 1] = arguments[_key]; |
| 56 } |
| 57 return args; |
| 58 } |
| 59 |
| 60 function ReturnArgsBabelSetup() { |
| 61 // Warm up with FAST_HOLEY_ELEMENTS |
| 62 result = ReturnArgsBabelFunction(...strings); |
| 63 // Warm up with FAST_HOLEY_SMI_ELEMENTS |
| 64 result = ReturnArgsBabelFunction(...numbers); |
| 65 } |
| 66 |
| 67 function ReturnArgsBabel() { |
| 68 result = ReturnArgsBabelFunction(...strings); |
| 69 result = ReturnArgsBabelFunction(...numbers); |
| 70 } |
| 71 |
| 72 function ReturnArgsBabelTearDown() { |
| 73 return result.indexOf(0) === 0; |
| 74 } |
| 75 |
| 76 // ---------------------------------------------------------------------------- |
| 77 |
| 78 function ReturnArgsNativeFunction(unused, ...args) { |
| 79 return args; |
| 80 } |
| 81 |
| 82 function ReturnArgsNativeSetup() { |
| 83 // Warm up with FAST_HOLEY_ELEMENTS |
| 84 result = ReturnArgsNativeFunction(...strings); |
| 85 // Warm up with FAST_HOLEY_SMI_ELEMENTS |
| 86 result = ReturnArgsNativeFunction(...numbers); |
| 87 } |
| 88 |
| 89 function ReturnArgsNative() { |
| 90 result = ReturnArgsNativeFunction(...strings); |
| 91 result = ReturnArgsNativeFunction(...numbers); |
| 92 } |
| 93 |
| 94 function ReturnArgsNativeTearDown() { |
| 95 return result.indexOf(0) === 0; |
| 96 } |
OLD | NEW |