class init test

JavaScript performance comparison

Test case created by _fiveDust

Info

Test startup instantiation speed vs instantiation on demand. Useful considerations for working with huge monolithic class based JS bases in applications.

Preparation code

<script src="//ajax.googleapis.com/ajax/libs/mootools/1.4.1/mootools.js"></script>
<script>
var A2 = (function() {
   
    return new Class({
    initialize: function()
    {
       
    }
}); });

var BProto2 = {
    initialize: function()
    {
       
    }
}

var B2 = new Class({
    initialize: function()
    {
       
    }
});
</script>

Preparation code output

Test runner

Warning! For accurate results, please disable Firebug before running the tests. (Why?)

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
closure non executed
var A = (function() {
   
    return new Class({
    initialize: function()
    {
       
    }
}); });
pending…
Class Proto non executed
var BProt = { 
    initialize: function()
    {
       
    }
}
pending…
Class init Obj
var B = new Class({ 
    initialize: function()
    {
       
    }
});
pending…
Instantiation from Closure
var a = new (A2())();
pending…
Instantiation from BProto
var bP = new Class( BProto2 );
pending…
Instantiation from Class Obj
var b = new B2();
pending…

You can edit these tests or add even more tests to this page by appending /edit to the URL.

Compare results of other browsers

0 comments

Add a comment