Debian Codegraph @

js/src/devtools/gc-ubench/benchmarks/selfCyclicWeakMap.js

raw
1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
3 * You can obtain one at http://mozilla.org/MPL/2.0/. */
4
5 tests.set(
6 "selfCyclicWeakMap",
7 (function() {
8 var garbage = [];
9 var garbageIndex = 0;
10 return {
11 description: "var wm = new WeakMap(); wm[k1] = k2; wm[k2] = k3; ...",
12
13 defaultGarbagePerFrame: "10K",
14 defaultGarbagePiles: "1K",
15
16 load: N => {
17 garbage = new Array(N);
18 },
19
20 unload: () => {
21 garbage = [];
22 garbageIndex = 0;
23 },
24
25 makeGarbage: M => {
26 var wm = new WeakMap();
27 var initialKey = {};
28 var key = initialKey;
29 var value = {};
30 for (var i = 0; i < M; i++) {
31 wm.set(key, value);
32 key = value;
33 value = {};
34 }
35 garbage[garbageIndex++] = [initialKey, wm];
36 if (garbageIndex == garbage.length) {
37 garbageIndex = 0;
38 }
39 },
40 };
41 })()
42 );