native-bind-vs-bind-with-varargs

JavaScript performance comparison

Revision 2 of this test case created by Josh D

Preparation code

<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
 
<script>
Benchmark.prototype.setup = function() {
    var self = new Object();
    self.i = 0;
    self.foo = function(a, b, c) {
      self.i += a, b, c;
    }
   
    function bindWithVarArgs(fn, self, var_args) {
      return fn.call.apply(fn.bind, arguments);
    }
   
};

Benchmark.prototype.teardown = function() {
    self.foo(1, 2, 3)
    console.log(self.i);
};
</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
native-bind
boundFoo = self.foo.bind(self);
 
pending…
bind-with-varargs
boundFoo = bindWithVarArgs(self.foo, self);
pending…
anonymous
boundFoo = function(a, b, c) {
  self.foo(a, b, c);
}
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