Eval vs new Function vs function() (v6)

Revision 6 of this benchmark created by PAEz on


Setup

var _={a:1,b:2};
    var func= new Function("$","return $.a+$.b");
    var funcAdd = function (){
    var result=arguments[0];
    for (var i=1,end=arguments.length;i<end;i++){
    result+=arguments[i];
    }
    return result;
    }

Test runner

Ready to run.

Testing in
TestOps/sec
Eval
var b=eval('_.a+_.b');
ready
new Function
var b=func(_);
ready
function
var b=funcAdd(_.a,_.b);
ready

Revisions

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