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

Unified 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, 7 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 side-by-side diff with in-line comments
Download patch
« test/js-perf-test/JSTests.json ('K') | « test/js-perf-test/PreES6/run.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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.
« 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