OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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('ForOf', [1000], [ | 5 new BenchmarkSuite('ForOf', [1000], [ |
6 new Benchmark('ArrayValues', false, false, 0, ForOf, ForOfArraySetup, ForOfTea
rDown), | 6 new Benchmark('ArrayValues', false, false, 0, |
7 new Benchmark('ArrayKeys', false, false, 0, ForOf, ForOfArrayKeysSetup, ForOfT
earDown), | 7 ForOf, ForOfArraySetup, ForOfTearDown), |
8 new Benchmark('ArrayEntries', false, false, 0, ForOf, ForOfArrayEntriesSetup,
ForOfTearDown), | 8 new Benchmark('ArrayKeys', false, false, 0, |
9 new Benchmark('Uint8Array', false, false, 0, ForOf, ForOfUint8ArraySetup, ForO
fTearDown), | 9 ForOf, ForOfArrayKeysSetup, ForOfTearDown), |
10 new Benchmark('Float64Array', false, false, 0, ForOf, ForOfFloat64ArraySetup,
ForOfTearDown), | 10 new Benchmark('ArrayEntries', false, false, 0, |
11 new Benchmark('String', false, false, 0, ForOf, ForOfStringSetup, ForOfTearDow
n), | 11 ForOf, ForOfArrayEntriesSetup, ForOfTearDown), |
| 12 new Benchmark('Uint8Array', false, false, 0, |
| 13 ForOf, ForOfUint8ArraySetup, ForOfTearDown), |
| 14 new Benchmark('Float64Array', false, false, 0, |
| 15 ForOf, ForOfFloat64ArraySetup, ForOfTearDown), |
| 16 new Benchmark('String', false, false, 0, |
| 17 ForOf, ForOfStringSetup, ForOfTearDown), |
12 ]); | 18 ]); |
13 | 19 |
14 | 20 |
15 var iterable; | 21 var iterable; |
16 var N = 100; | 22 var N = 100; |
17 var expected, result; | 23 var expected, result; |
18 | 24 |
19 | 25 |
20 function ForOfArraySetupHelper(constructor) { | 26 function ForOfArraySetupHelper(constructor) { |
21 iterable = new constructor(N); | 27 iterable = new constructor(N); |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 throw new Error("Bad result: " + result); | 85 throw new Error("Bad result: " + result); |
80 } | 86 } |
81 } | 87 } |
82 | 88 |
83 | 89 |
84 function ForOf() { | 90 function ForOf() { |
85 for (var x of iterable) { | 91 for (var x of iterable) { |
86 result = x; | 92 result = x; |
87 } | 93 } |
88 } | 94 } |
OLD | NEW |