Deferrable Test with or without bind

JavaScript performance comparison

Revision 2 of this test case created by Ulric Wilfred

Test runner

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

Java applet disabled.

Testing in CCBot 2.0.0 / Other 0.0.0
Test Ops/sec
deferrable w/o bind
function deferrable(f) { // выберите название поприятнее
  return function() {
    return (function(f, args) {
      return function() { return f.apply(null, args); };
    })(f, arguments);
  }
}

for (var i = 0; i < 20000; i++) {
  deferrable(function(a) { a++; })(10)();
}
pending…
deferrable with bind
function deferrable( f ) {
  return function() {
    Array.prototype.unshift.call(arguments, null);
    return f.bind.apply(f, arguments); 
  }
}

for (var i = 0; i < 20000; i++) {
  deferrable(function(a) { a++; })(10)();
}
pending…
direct bind
for (var i = 0; i < 20000; i++) {
  (function(a) { a++; }).bind(null, 10)();
}
pending…
direct bind through function
function foo(a) { a++ };

for (var i = 0; i < 20000; i++) {
  foo.bind(null, 10)();
}
pending…
deferrable w/o bind through function
function deferrable(f) { // выберите название поприятнее
  return function() {
    return (function(f, args) {
      return function() { return f.apply(null, args); };
    })(f, arguments);
  }
}

function foo(a) { a++ };

for (var i = 0; i < 20000; i++) {
  deferrable(foo)(10)();
}
pending…
deferrable with bind through function
function deferrable( f ) {
  return function() {
    Array.prototype.unshift.call(arguments, null);
    return f.bind.apply(f, arguments); 
  }
}

function foo(a) { a++ };

for (var i = 0; i < 20000; i++) {
  deferrable(foo)(10)();
}
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.

0 Comments