summaryrefslogtreecommitdiffstats
path: root/js/src/devtools/gc-ubench/benchmarks/largeArrayPropertyAndElements.js
blob: 36ae04971b13ec2e5951a7fe75e2c7c14d6019d0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
window.tests.set('largeArrayPropertyAndElements', (function() {
  var garbage;
  var index;

  return {
    description: "Large array with both properties and elements",

    load: n => {
      garbage = new Array(n);
      garbage.fill(null);
      index = 0;
    },

    unload: () => {
      garbage = null;
      index = 0;
    },

    defaultGarbageTotal: "100K",
    defaultGarbagePerFrame: "30K",

    makeGarbage: n => {
      for (var i = 0; i < n; i++) {
        index++;
        index %= garbage.length;

        var obj = {};
        garbage[index] = obj;
        garbage["key-" + index] = obj;
      }
    }
  };

}()));