Bug 1125398 - Benchmark load: self-referential WeakMap, r=terrence
authorSteve Fink <sfink@mozilla.com>
Tue, 13 Jan 2015 09:15:30 -0800
changeset 239484 abe775af80737a557ce1a23ed13e0c439bacc3d1
parent 239483 b8257c0c97adeb4305c6e762dd741ebae9a124f3
child 239485 4bbb59685268cadedfd2c67eff58852412684c8b
push id500
push userjoshua.m.grant@gmail.com
push dateThu, 29 Jan 2015 01:48:36 +0000
reviewersterrence
bugs1125398
milestone38.0a1
Bug 1125398 - Benchmark load: self-referential WeakMap, r=terrence
js/src/devtools/gc-ubench/benchmarks/selfCyclicWeakMap.js
js/src/devtools/gc-ubench/index.html
new file mode 100644
--- /dev/null
+++ b/js/src/devtools/gc-ubench/benchmarks/selfCyclicWeakMap.js
@@ -0,0 +1,29 @@
+window.tests.set('selfCyclicWeakMap', (function() {
+var garbage = [];
+var garbageIndex = 0;
+return {
+    description: "var wm = new WeakMap(); wm[k1] = k2; wm[k2] = k3; ...",
+
+    defaultGarbagePerFrame: "1K",
+    defaultGarbageTotal: "1K",
+
+    load: (N) => { garbage = new Array(N); },
+
+    unload: () => { garbage = []; garbageIndex = 0; },
+
+    makeGarbage: (M) => {
+        var wm = new WeakMap();
+        var initialKey = {};
+        var key = initialKey;
+        var value = {};
+        for (var i = 0; i < M; i++) {
+            wm.set(key, value);
+            key = value;
+            value = {};
+        }
+        garbage[garbageIndex++] = [ initialKey, wm ];
+        if (garbageIndex == garbage.length)
+            garbageIndex = 0;
+    }
+};
+})());
--- a/js/src/devtools/gc-ubench/index.html
+++ b/js/src/devtools/gc-ubench/index.html
@@ -6,16 +6,17 @@
   <!-- Include benchmark modules. -->
   <script>var tests = new Map();</script>
   <script src="benchmarks/noAllocation.js"></script>
   <script src="benchmarks/globalArrayNewObject.js"></script>
   <script src="benchmarks/globalArrayArrayLiteral.js"></script>
   <script src="benchmarks/globalArrayLargeArray.js"></script>
   <script src="benchmarks/globalArrayObjectLiteral.js"></script>
   <script src="benchmarks/globalArrayReallocArray.js"></script>
+  <script src="benchmarks/selfCyclicWeakMap.js"></script>
 
   <script src="harness.js"></script>
 
 </head>
 
 <body onload="onload()" onunload="onunload()">
 
 <canvas id="graph" width="1080" height="550" style="padding-left:10px"></canvas>