native function vs new Function()

JavaScript performance comparison

Test case created by valmynd

Test runner

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

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
anonymous function
var myfunc = function() {
   var ret = 1
   for (var i=0; i<100; i++) ret += i
   return ret
}

myfunc()
pending…
named function
function myfunc() {
   var ret = 1
   for (var i=0; i<100; i++) ret += i
   return ret
}

myfunc()
pending…
new Function()
myfunc = new Function("return function " + "myfunc" + "(){ var ret = 1; for (var i=0; i<100; i++) ret += i; return ret;}")

myfunc()
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