curry vs closure

Benchmark created by will bailey on


Description

test performance of currying an argument vs closing over it

Preparation HTML

<script>
  var bind = function(func, context) {
    var args = Array.prototype.slice.call(arguments,2);
    return function() {
      func.apply(context, args);
    }
  };
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
curry
var foo = 'foo';

func = bind(function(foo) {return foo}, this, foo);
func();
ready
closure
var foo = 'foo';
func = bind(function(foo) {return foo}, this);
func();
ready

Revisions

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

  • Revision 1: published by will bailey on