Chromium Code Reviews| Index: test/js-perf-test/PreES6/with.js |
| diff --git a/test/js-perf-test/PreES6/with.js b/test/js-perf-test/PreES6/with.js |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..203e8944d02fdc2533e0419c40fac853c1352a6c |
| --- /dev/null |
| +++ b/test/js-perf-test/PreES6/with.js |
| @@ -0,0 +1,70 @@ |
| +// Copyright 2014 the V8 project authors. All rights reserved. |
|
arv (Not doing code reviews)
2015/05/28 15:18:33
15
Michael Hablich
2015/05/29 14:36:59
Done.
|
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +new BenchmarkSuite('With', [1000], [ |
|
Michael Hablich
2015/05/29 14:36:59
Does anybody have a clue what would be a good refe
|
| + new Benchmark('AccessOnSameLevel', false, false, 0, |
| + AccessOnSameLevel, AccessOnSameLevelSetup, |
| + AccessOnSameLevelTearDown), |
| + new Benchmark('AccessOverPrototypeChain', false, false, 0, |
| + AccessOverPrototypeChainSetup, AccessOverPrototypeChainSetup, |
| + AccessOverPrototypeChainTearDown), |
| + new Benchmark('CompetingScope', false, false, 0, |
| + CompetingScope, CompetingScopeSetup, CompetingScopeTearDown) |
| +]); |
| + |
| +var objectUnderTest; |
| +var objectUnderTestExtended; |
| +var resultStore; |
| +var VALUE_OF_PROPERTY = "Simply a string"; |
|
arv (Not doing code reviews)
2015/05/28 15:18:33
Don't mix and match " and '. Stick to one.
Michael Hablich
2015/05/29 14:36:59
Done.
|
| + |
| +// ---------------------------------------------------------------------------- |
| + |
| +function AccessOnSameLevelSetup() { |
| + objectUnderTest = {"First": VALUE_OF_PROPERTY}; |
|
arv (Not doing code reviews)
2015/05/28 15:18:33
objectUnderTest = {first: VALUE_OF_PROPERTY};
Cap
Michael Hablich
2015/05/29 14:36:58
Done.
|
| +} |
| + |
| +function AccessOnSameLevel() { |
| + with(objectUnderTest) { |
|
arv (Not doing code reviews)
2015/05/28 15:18:33
with (
just like, if, else for, while, catch etc.
Michael Hablich
2015/05/29 14:36:59
Done.
|
| + resultStore = First; |
| + } |
| +} |
| + |
| +function AccessOnSameLevelTearDown() { |
| + return objectUnderTest.First === resultStore; |
| +} |
| + |
| +// ---------------------------------------------------------------------------- |
| + |
| +function AccessOverPrototypeChainSetup() { |
| + objectUnderTest = {"First": VALUE_OF_PROPERTY}; |
| + objectUnderTestExtended = Object.create(objectUnderTest); |
|
arv (Not doing code reviews)
2015/05/28 15:18:33
Or
objectUnderTestExtended = {
__proto__: objec
Michael Hablich
2015/05/29 14:36:59
IMO mine is more readable.
arv (Not doing code reviews)
2015/05/29 14:43:39
IMO does not apply to style =P
https://google-sty
|
| + objectUnderTestExtended.Second = "Another string"; |
| +} |
| + |
| +function AccessOverPrototypeChain() { |
| + with(objectUnderTestExtended) { |
| + resultStore = First; |
| + } |
| +} |
| + |
| +function AccessOverPrototypeChainTearDown() { |
| + return objectUnderTest.First === resultStore; |
| +} |
| + |
| +// ---------------------------------------------------------------------------- |
| + |
| +function CompetingScopeSetup() { |
| + objectUnderTest = {"First": VALUE_OF_PROPERTY}; |
| +} |
| + |
| +function CompetingScope() { |
| + var First = "Not correct"; |
| + with(objectUnderTest) { |
| + resultStore = First; |
| + } |
| +} |
| + |
| +function CompetingScopeTearDown() { |
| + return objectUnderTest.First === resultStore; |
| +} |
|
arv (Not doing code reviews)
2015/05/28 15:18:33
Do we want to test assignment too?
with (objectUn
Michael Hablich
2015/05/29 14:36:59
Done.
|