Bug 1125398 - Benchmark load: Pair of mutually recursive weakmaps, r=terrence
authorSteve Fink <sfink@mozilla.com>
Tue, 20 Jan 2015 17:07:51 -0800
changeset 239485 4bbb59685268cadedfd2c67eff58852412684c8b
parent 239484 abe775af80737a557ce1a23ed13e0c439bacc3d1
child 239486 cbf05998774213ff117b64c9a85a65880699aed3
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: Pair of mutually recursive weakmaps, r=terrence
js/src/devtools/gc-ubench/benchmarks/pairCyclicWeakMap.js
js/src/devtools/gc-ubench/index.html
new file mode 100644
--- /dev/null
+++ b/js/src/devtools/gc-ubench/benchmarks/pairCyclicWeakMap.js
@@ -0,0 +1,33 @@
+window.tests.set('pairCyclicWeakMap', (function() {
+var garbage = [];
+var garbageIndex = 0;
+return {
+    description: "wm1[k1] = k2; wm2[k2] = k3; wm1[k3] = k4; wm2[k4] = ...",
+
+    defaultGarbagePerFrame: "1K",
+    defaultGarbageTotal: "1K",
+
+    load: (N) => { garbage = new Array(N); },
+
+    unload: () => { garbage = []; garbageIndex = 0; },
+
+    makeGarbage: (M) => {
+        var wm1 = new WeakMap();
+        var wm2 = new WeakMap();
+        var initialKey = {};
+        var key = initialKey;
+        var value = {};
+        for (var i = 0; i < M/2; i++) {
+            wm1.set(key, value);
+            key = value;
+            value = {};
+            wm2.set(key, value);
+            key = value;
+            value = {};
+        }
+        garbage[garbageIndex++] = [ initialKey, wm1, wm2 ];
+        if (garbageIndex == garbage.length)
+            garbageIndex = 0;
+    }
+};
+})());
--- a/js/src/devtools/gc-ubench/index.html
+++ b/js/src/devtools/gc-ubench/index.html
@@ -7,16 +7,17 @@
   <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="benchmarks/pairCyclicWeakMap.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>