Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(415)

Side by Side Diff: test/js-perf-test/PreES6/with.js

Issue 1153363002: For Micro-benchmarks for 'with' (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // 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.
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], [
Michael Hablich 2015/05/29 14:36:59 Does anybody have a clue what would be a good refe
6 new Benchmark('AccessOnSameLevel', false, false, 0,
7 AccessOnSameLevel, AccessOnSameLevelSetup,
8 AccessOnSameLevelTearDown),
9 new Benchmark('AccessOverPrototypeChain', false, false, 0,
10 AccessOverPrototypeChainSetup, AccessOverPrototypeChainSetup,
11 AccessOverPrototypeChainTearDown),
12 new Benchmark('CompetingScope', false, false, 0,
13 CompetingScope, CompetingScopeSetup, CompetingScopeTearDown)
14 ]);
15
16 var objectUnderTest;
17 var objectUnderTestExtended;
18 var resultStore;
19 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.
20
21 // ----------------------------------------------------------------------------
22
23 function AccessOnSameLevelSetup() {
24 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.
25 }
26
27 function AccessOnSameLevel() {
28 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.
29 resultStore = First;
30 }
31 }
32
33 function AccessOnSameLevelTearDown() {
34 return objectUnderTest.First === resultStore;
35 }
36
37 // ----------------------------------------------------------------------------
38
39 function AccessOverPrototypeChainSetup() {
40 objectUnderTest = {"First": VALUE_OF_PROPERTY};
41 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
42 objectUnderTestExtended.Second = "Another string";
43 }
44
45 function AccessOverPrototypeChain() {
46 with(objectUnderTestExtended) {
47 resultStore = First;
48 }
49 }
50
51 function AccessOverPrototypeChainTearDown() {
52 return objectUnderTest.First === resultStore;
53 }
54
55 // ----------------------------------------------------------------------------
56
57 function CompetingScopeSetup() {
58 objectUnderTest = {"First": VALUE_OF_PROPERTY};
59 }
60
61 function CompetingScope() {
62 var First = "Not correct";
63 with(objectUnderTest) {
64 resultStore = First;
65 }
66 }
67
68 function CompetingScopeTearDown() {
69 return objectUnderTest.First === resultStore;
70 }
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.
OLDNEW
« test/js-perf-test/JSTests.json ('K') | « test/js-perf-test/PreES6/run.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698