eval() vs new Function()

JavaScript performance comparison

Revision 15 of this test case created by

Preparation code


      
      <script>
Benchmark.prototype.setup = function() {
  var funcEval = eval('(function(a, b, c, d, e, f, g) {return a * b * c * d * e * f * g;})');
  var funcNewf = new Function('a', 'b', 'c', 'd', 'e', 'f', 'g', 'return a * b * c * d * e * f * g;');
  var func = function(a, b, c, d, e, f, g) {return a * b * c * d * e * f * g; };
  
  function useEval() {
  var result = funcEval(100.1, 200.2, 300.3, 400.4, 500.5, 600.6, 700.7);
  }
  
  function useNewFunction() {
  var result = funcNewf(100.1, 200.2, 300.3, 400.4, 500.5, 600.6, 700.7);
  }
  
  function normalFunction() {
  var result = func(100.1, 200.2, 300.3, 400.4, 500.5, 600.6, 700.7);
  }

};
</script>

Test runner

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

Java applet disabled.

Testing in CCBot 2.0.0 / Other 0.0.0
Test Ops/sec
eval()
useEval();
pending…
new Function()
useNewFunction();
pending…
normal
normalFunction();
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.

0 Comments