apply vs call vs switch call

JavaScript performance comparison

Test case created

Preparation code

 
<script>
Benchmark.prototype.setup = function() {
    var scope = this,scope1=null, fnc = function(id){return 1+id;},
    call = Function.prototype.call;
};
</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
apply
fnc.apply(scope,[1]);
fnc.apply(scope1,[2])
pending…
call
fnc.call(scope,1)
fnc.call(scope1,2)
pending…
direct
scope?fnc.call(scope,1):fnc(1);
scope1?fnc.call(scope1,2):fnc(2);
pending…

Compare results of other browsers

Revisions

You can edit these tests or add even more tests to this page by appending /edit to the URL. Here’s a list of current revisions for this page:

0 comments

Add a comment