summaryrefslogtreecommitdiffstats
path: root/js/src/devtools/gc/tests/dslots.js
blob: 8fcb6e8aa34b4d2c31dd2f1ac298d5e8bae7cf44 (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
//Benchmark to measure overhead of dslots allocation and deallocation

function Object0() {};
function Object1() { this.a=1; };
function Object2() { this.a=1; this.b=1; };
function Object3() { this.a=1; this.b=1; this.c=1; };
function Object4() { this.a=1; this.b=1; this.c=1; this.d=1; };
function Object5() { this.a=1; this.b=1; this.c=1; this.d=1; this.e=1; };

function test() {
    var N = 1e5;
    gc();

    for(var i = 0; i<=5; i++)
    {
        var tmp = i==0 ? Object0 : i==1 ? Object1 : i==2 ? Object2 : i==3 ? Object3 : i==4 ? Object4 : Object5;
        for (var j = 0; j != N; j++) {
            var a = new tmp();
        }
        gc();
    }
}

for(var i = 0; i<=5; i++) {
    test();
}