summaryrefslogtreecommitdiffstats
path: root/js/src/devtools/gc-ubench/benchmarks/globalArrayBuffer.js
blob: 4aee22ee7b0176bf4a5a07506aa85b3269a2c086 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
window.tests.set('globalArrayBuffer', (function() {
var garbage = [];
var garbageIndex = 0;
return {
    description: "var foo = ArrayBuffer(N); # (large malloc data)",

    load: (N) => { garbage = new Array(N); },
    unload: () => { garbage = []; garbageIndex = 0; },

    defaultGarbageTotal: "8K",
    defaultGarbagePerFrame: "4M",

    makeGarbage: (N) => {
        var ab = new ArrayBuffer(N);
        var view = new Uint8Array(ab);
        view[0] = 1;
        view[N - 1] = 2;
        garbage[garbageIndex++] = ab;
        if (garbageIndex == garbage.length)
            garbageIndex = 0;
    }
};
})());