prototype methods vs object methods

JavaScript performance comparison

Test case created by Parris

Preparation code

 
<script>
Benchmark.prototype.setup = function() {
    function Bob() {
    }
   
    var b = new Bob();
    Bob.prototype.testproto = function() {};
    b.testobj = function() {};
};
</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
Prototype Method Call
b.testproto();
pending…
Object Method Call
b.testobj();
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

1 comment

jeremy commented :

Cool test. Nice, simple, useful. First test that came up at the top of my search for when I wanted to test the very same thing.

Add a comment