js/src/devtools/gc/tests/dslots.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/js/src/devtools/gc/tests/dslots.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,26 @@
     1.4 +//Benchmark to measure overhead of dslots allocation and deallocation
     1.5 +
     1.6 +function Object0() {};
     1.7 +function Object1() { this.a=1; };
     1.8 +function Object2() { this.a=1; this.b=1; };
     1.9 +function Object3() { this.a=1; this.b=1; this.c=1; };
    1.10 +function Object4() { this.a=1; this.b=1; this.c=1; this.d=1; };
    1.11 +function Object5() { this.a=1; this.b=1; this.c=1; this.d=1; this.e=1; };
    1.12 +
    1.13 +function test() {
    1.14 +    var N = 1e5;
    1.15 +    gc();
    1.16 +
    1.17 +    for(var i = 0; i<=5; i++)
    1.18 +    {
    1.19 +        var tmp = i==0 ? Object0 : i==1 ? Object1 : i==2 ? Object2 : i==3 ? Object3 : i==4 ? Object4 : Object5;
    1.20 +        for (var j = 0; j != N; j++) {
    1.21 +            var a = new tmp();
    1.22 +        }
    1.23 +        gc();
    1.24 +    }
    1.25 +}
    1.26 +
    1.27 +for(var i = 0; i<=5; i++) {
    1.28 +    test();
    1.29 +}

mercurial