OLD | NEW |
---|---|
(Empty) | |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 new BenchmarkSuite( 'With', [1000], [ | |
6 new Benchmark('AccessOnSameLevel', false, false, 0, | |
7 AccessOnSameLevel, AccessOnSameLevelSetup, | |
8 AccessOnSameLevelTearDown), | |
9 new Benchmark('SetOnSameLevel', false, false, 0, | |
10 SetOnSameLevel, SetOnSameLevelSetup, | |
11 SetOnSameLevelTearDown), | |
12 new Benchmark('AccessOverPrototypeChain', false, false, 0, | |
13 AccessOverPrototypeChainSetup, AccessOverPrototypeChainSetup, | |
14 AccessOverPrototypeChainTearDown), | |
15 new Benchmark('CompetingScope', false, false, 0, | |
16 CompetingScope, CompetingScopeSetup, CompetingScopeTearDown) | |
17 ]); | |
18 | |
19 var objectUnderTest; | |
20 var objectUnderTestExtended; | |
21 var resultStore; | |
22 var VALUE_OF_PROPERTY = 'Simply a string'; | |
23 var SOME_OTHER_VALUE = 'Another value'; | |
24 | |
25 // ---------------------------------------------------------------------------- | |
26 | |
27 function AccessOnSameLevelSetup() { | |
28 objectUnderTest = {first: VALUE_OF_PROPERTY}; | |
29 } | |
30 | |
31 function AccessOnSameLevel() { | |
32 with (objectUnderTest) { | |
33 resultStore = first; | |
34 } | |
35 } | |
36 | |
37 function AccessOnSameLevelTearDown() { | |
38 return objectUnderTest.first === resultStore; | |
39 } | |
40 | |
41 // ---------------------------------------------------------------------------- | |
42 | |
43 function AccessOverPrototypeChainSetup() { | |
44 objectUnderTest = {first: VALUE_OF_PROPERTY}; | |
45 objectUnderTestExtended = Object.create(objectUnderTest); | |
46 objectUnderTestExtended.Second = 'Another string'; | |
arv (Not doing code reviews)
2015/05/29 14:43:39
s/Second/second/
Michael Hablich
2015/05/29 14:48:57
Done.
| |
47 } | |
48 | |
49 function AccessOverPrototypeChain() { | |
50 with (objectUnderTestExtended) { | |
51 resultStore = first; | |
52 } | |
53 } | |
54 | |
55 function AccessOverPrototypeChainTearDown() { | |
56 return objectUnderTest.first === resultStore; | |
57 } | |
58 | |
59 // ---------------------------------------------------------------------------- | |
60 | |
61 function CompetingScopeSetup() { | |
62 objectUnderTest = {first: VALUE_OF_PROPERTY}; | |
63 } | |
64 | |
65 function CompetingScope() { | |
66 var First = 'Not correct'; | |
arv (Not doing code reviews)
2015/05/29 14:43:39
s/First/first/
This one is not just style, the na
Michael Hablich
2015/05/29 14:48:57
Done.
| |
67 with (objectUnderTest) { | |
68 resultStore = first; | |
69 } | |
70 } | |
71 | |
72 function CompetingScopeTearDown() { | |
73 return objectUnderTest.first === resultStore; | |
74 } | |
75 | |
76 // ---------------------------------------------------------------------------- | |
77 | |
78 function SetOnSameLevelSetup() { | |
79 objectUnderTest = {first: VALUE_OF_PROPERTY}; | |
80 } | |
81 | |
82 function SetOnSameLevel() { | |
83 with (objectUnderTest) { | |
84 first = SOME_OTHER_VALUE; | |
85 } | |
86 } | |
87 | |
88 function SetOnSameLevelTearDown() { | |
89 return objectUnderTest.first === SOME_OTHER_VALUE; | |
90 } | |
OLD | NEW |