Bind vs. Curry

JavaScript performance comparison

Test case created by

Preparation code


      
      <script>
Benchmark.prototype.setup = function() {
  Function.prototype.curry = function () {
    var _self = this,
        slice = Array.prototype.slice,
        args = slice.call(arguments, 1);
    return function () {
      return _self.apply(null, args.concat(slice.call(arguments)));
    };
  };
  
  function boundFoo(x, y) {
    return x + y;
  }
   
  var bound = boundFoo.bind(null, 10);
  
  function curryedFoo(x, y) {
    // partial
    if (typeof y == "undefined") {
      return function partialFoo(y) {
        // complete
        return x + y;
      };
    }
    // complete
    return x + y;
  }
  
  var curryed = curryedFoo(10);
  
  var customCurryed = boundFoo.curry(10);

};
</script>

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
Bind
bound(20);
pending…
Curry
curryed(20);
pending…
Shimed Cury
customCurryed(20);
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