michael@0: //Benchmark to measure overhead of dslots allocation and deallocation michael@0: michael@0: function Object0() {}; michael@0: function Object1() { this.a=1; }; michael@0: function Object2() { this.a=1; this.b=1; }; michael@0: function Object3() { this.a=1; this.b=1; this.c=1; }; michael@0: function Object4() { this.a=1; this.b=1; this.c=1; this.d=1; }; michael@0: function Object5() { this.a=1; this.b=1; this.c=1; this.d=1; this.e=1; }; michael@0: michael@0: function test() { michael@0: var N = 1e5; michael@0: gc(); michael@0: michael@0: for(var i = 0; i<=5; i++) michael@0: { michael@0: var tmp = i==0 ? Object0 : i==1 ? Object1 : i==2 ? Object2 : i==3 ? Object3 : i==4 ? Object4 : Object5; michael@0: for (var j = 0; j != N; j++) { michael@0: var a = new tmp(); michael@0: } michael@0: gc(); michael@0: } michael@0: } michael@0: michael@0: for(var i = 0; i<=5; i++) { michael@0: test(); michael@0: }