Arguments vs. Undefined Check

JavaScript performance comparison

Revision 9 of this test case created

Info

Checks to see if it is worthwhile avoiding arguments.

Preparation code

 
<script>
Benchmark.prototype.setup = function() {
    function testMethod(a, b, c) {
      return a + b + c;
    }
   
    function variadicBind(method) {
      var context = this;
      return function() {
        var hasE = arguments[4];
        return method.apply(context, arguments);
      };
    }
   
    function restrictBind(method) {
      var context = this;
      return function(a, b, c, d, e) {
        var hasE = e !== undefined;
        return method.call(context, a, b, c, d, e);
      };
    }
   
    var variadicBound = variadicBind(testMethod);
    var restrictBound = restrictBind(testMethod);
};
</script>

Test runner

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

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
Arguments accessing beyond supplied args
variadicBound(1, 2, 3);
pending…
Undefined Check accessing beyond supplied args
restrictBound(1, 2, 3);
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. Here’s a list of current revisions for this page:

0 comments

Add a comment