Curry Imperative vs Functional

JavaScript performance comparison

Revision 2 of this test case created by

Preparation code

<script>
var curryImperative = function() {
  var args = Array.prototype.slice.call(arguments),
      fn = this;

  return function() {
    var innerArgs = Array.prototype.slice.call(arguments);
    return fn.apply(this, args.concat(innerArgs));
  }
}
var curryFunctional = function() {
  return (function(args, fn) {
    return function() {
      return (function (innerArgs, context) {
        return fn.apply(context, args.concat(innerArgs));
      })(Array.prototype.slice.call(arguments), this);
    }
  })(Array.prototype.slice.call(arguments), this);
}

function add(a, b) { return a + b };
var add5Imperative = curryImperative.call(add, 5);
var add5Functional = curryFunctional.call(add, 5);
</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
Imperative Curry
curryImperative.call(add, 5);
pending…
Functional Curry
curryFunctional.call(add, 5);
pending…
Imperative Curry Call
add5Imperative(5);
pending…
Functional Curry Call
add5Functional(5);
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