test prototypeSfh

JavaScript performance comparison

Test case created

Preparation code

 
<script>
Benchmark.prototype.setup = function() {
    function Person() {}
    Person.prototype.init = function(isDancing){
    this.dancing = isDancing;
    },
    Person.prototype.dance = function(){
    return this.dancing;
    }
   
    function Ninja1() {}
    Ninja1.prototype.init = function(isDancing){
    Person.prototype.init.call(this, isDancing);
    },
    Ninja1.prototype.dance = function(){
    return "Ninja1"+Person.prototype.dance.call(this);
    }
   
    function Ninja2() {}
    Ninja2.prototype.init = function(isDancing){
    Ninja1.prototype.init.call(this, isDancing);
    },
    Ninja2.prototype.dance = function(){
    return "Ninja2"+Ninja1.prototype.dance.call(this)
    }
   
    function Ninja3() {}
    Ninja3.prototype.init = function(isDancing){
    Ninja2.prototype.init.call(this, isDancing);
    },
    Ninja3.prototype.dance = function(){
    return "Ninja3"+Ninja2.prototype.dance.call(this)
    }
   
    var p = new Person();
    p.init(true);
   
    var n1 = new Ninja1();
    n1.init(true);
   
    var n2 = new Ninja2();
    n2.init(true);
   
    var n3 = new Ninja3();
    n3.init(true);
};
</script>

Test runner

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

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
proto niveau1(function call)
p.dance;
pending…
proto niveau2(function call)
n1.dance;
pending…
proto niveau3(function call)
n2.dance;
pending…
proto niveau4(function call)
n3.dance;
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