curry cost (v4)

Revision 4 of this benchmark created by xixixao on


Setup

var _;
    
    var curried = function(x){
      return function(y){
         return x + y;
      };
    };
    
    var precurried = curried(1);
    
    var notcurried = _ = function(x, y){
       return x + y;
    }; _._ = 2;
    
    function F2(fun) {
        function wrapper(a) { return function(b) { return fun(a,b) } }
        wrapper.arity = 2;
        wrapper.func = fun;
        return wrapper;
    }
    
    function A2(fun,a,b) {
       return fun.arity === 2
                ? fun.func(a,b)
                : fun(a)(b);
    }
    
    elmcurried = F2(function(x, y){
       return x + y;
    });
    
    var _2 = function (f, a, b) {
      if (f._ === 2 || f.length === 2) {
        return f(a, b);
      }
    };

Test runner

Ready to run.

Testing in
TestOps/sec
curried
return curried(1)(2);
ready
not curried
return notcurried(1,2);
ready
pre curried
return precurried(2);
ready
elm curried
return A2(elmcurried, 1, 2);
ready
TS curried
return _2(notcurried, 1, 2);
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.