eval() vs eval() loop

JavaScript performance comparison

Revision 8 of this test case created by

Preparation code


      
      <script>
Benchmark.prototype.setup = function() {
  function useEvalLoop() {
  for (var i=0;i<20;i++){
  var func = eval('(function(a, b, c, d, e, f, g) {return a * b * c * d * e * f * g;})');
  var result = func(100.1, 200.2, 300.3, 400.4, 500.5, 600.6, 700.7);
  }
  }
  function useEvalArray() {
  var func0 = eval('(function(a, b, c, d, e, f, g) {return a * b * c * d * e * f * g;})');
  var result0 = func0(100.1, 200.2, 300.3, 400.4, 500.5, 600.6, 700.7);
  var func1 = eval('(function(a, b, c, d, e, f, g) {return a * b * c * d * e * f * g;})');
  var result1 = func1(100.1, 200.2, 300.3, 400.4, 500.5, 600.6, 700.7);
  var func2 = eval('(function(a, b, c, d, e, f, g) {return a * b * c * d * e * f * g;})');
  var result2 = func2(100.1, 200.2, 300.3, 400.4, 500.5, 600.6, 700.7);
  var func3 = eval('(function(a, b, c, d, e, f, g) {return a * b * c * d * e * f * g;})');
  var result3 = func3(100.1, 200.2, 300.3, 400.4, 500.5, 600.6, 700.7);
  var func4 = eval('(function(a, b, c, d, e, f, g) {return a * b * c * d * e * f * g;})');
  var result4 = func4(100.1, 200.2, 300.3, 400.4, 500.5, 600.6, 700.7);
  var func5 = eval('(function(a, b, c, d, e, f, g) {return a * b * c * d * e * f * g;})');
  var result5 = func5(100.1, 200.2, 300.3, 400.4, 500.5, 600.6, 700.7);
  var func6 = eval('(function(a, b, c, d, e, f, g) {return a * b * c * d * e * f * g;})');
  var result6 = func6(100.1, 200.2, 300.3, 400.4, 500.5, 600.6, 700.7);
  var func7 = eval('(function(a, b, c, d, e, f, g) {return a * b * c * d * e * f * g;})');
  var result7 = func7(100.1, 200.2, 300.3, 400.4, 500.5, 600.6, 700.7);
  var func8 = eval('(function(a, b, c, d, e, f, g) {return a * b * c * d * e * f * g;})');
  var result8 = func8(100.1, 200.2, 300.3, 400.4, 500.5, 600.6, 700.7);
  var func9 = eval('(function(a, b, c, d, e, f, g) {return a * b * c * d * e * f * g;})');
  var result9 = func9(100.1, 200.2, 300.3, 400.4, 500.5, 600.6, 700.7);
  var func10 = eval('(function(a, b, c, d, e, f, g) {return a * b * c * d * e * f * g;})');
  var result10 = func10(100.1, 200.2, 300.3, 400.4, 500.5, 600.6, 700.7);
  var func11 = eval('(function(a, b, c, d, e, f, g) {return a * b * c * d * e * f * g;})');
  var result11 = func11(100.1, 200.2, 300.3, 400.4, 500.5, 600.6, 700.7);
  var func12 = eval('(function(a, b, c, d, e, f, g) {return a * b * c * d * e * f * g;})');
  var result12 = func12(100.1, 200.2, 300.3, 400.4, 500.5, 600.6, 700.7);
  var func13 = eval('(function(a, b, c, d, e, f, g) {return a * b * c * d * e * f * g;})');
  var result13 = func13(100.1, 200.2, 300.3, 400.4, 500.5, 600.6, 700.7);
  var func14 = eval('(function(a, b, c, d, e, f, g) {return a * b * c * d * e * f * g;})');
  var result14 = func14(100.1, 200.2, 300.3, 400.4, 500.5, 600.6, 700.7);
  var func15 = eval('(function(a, b, c, d, e, f, g) {return a * b * c * d * e * f * g;})');
  var result15 = func15(100.1, 200.2, 300.3, 400.4, 500.5, 600.6, 700.7);
  var func16 = eval('(function(a, b, c, d, e, f, g) {return a * b * c * d * e * f * g;})');
  var result16 = func16(100.1, 200.2, 300.3, 400.4, 500.5, 600.6, 700.7);
  var func17 = eval('(function(a, b, c, d, e, f, g) {return a * b * c * d * e * f * g;})');
  var result17 = func17(100.1, 200.2, 300.3, 400.4, 500.5, 600.6, 700.7);
  var func18 = eval('(function(a, b, c, d, e, f, g) {return a * b * c * d * e * f * g;})');
  var result18 = func18(100.1, 200.2, 300.3, 400.4, 500.5, 600.6, 700.7);
  var func19 = eval('(function(a, b, c, d, e, f, g) {return a * b * c * d * e * f * g;})');
  var result19 = func19(100.1, 200.2, 300.3, 400.4, 500.5, 600.6, 700.7);
  }
  
  function useEvalLongString() {
  
   eval('var func0 = (function(a, b, c, d, e, f, g) {return a * b * c * d * e * f * g;}); var func1 = (function(a, b, c, d, e, f, g) {return a * b * c * d * e * f * g;}); var func2 = (function(a, b, c, d, e, f, g) {return a * b * c * d * e * f * g;}); var func3 = (function(a, b, c, d, e, f, g) {return a * b * c * d * e * f * g;}); var func4 = (function(a, b, c, d, e, f, g) {return a * b * c * d * e * f * g;}); var func5 = (function(a, b, c, d, e, f, g) {return a * b * c * d * e * f * g;}); var func6 = (function(a, b, c, d, e, f, g) {return a * b * c * d * e * f * g;}); var func7 = (function(a, b, c, d, e, f, g) {return a * b * c * d * e * f * g;}); var func8 = (function(a, b, c, d, e, f, g) {return a * b * c * d * e * f * g;}); var func9 = (function(a, b, c, d, e, f, g) {return a * b * c * d * e * f * g;}); var func10 = (function(a, b, c, d, e, f, g) {return a * b * c * d * e * f * g;}); var func11 = (function(a, b, c, d, e, f, g) {return a * b * c * d * e * f * g;}); var func12 = (function(a, b, c, d, e, f, g) {return a * b * c * d * e * f * g;}); var func13 = (function(a, b, c, d, e, f, g) {return a * b * c * d * e * f * g;}); var func14 = (function(a, b, c, d, e, f, g) {return a * b * c * d * e * f * g;}); var func15 = (function(a, b, c, d, e, f, g) {return a * b * c * d * e * f * g;}); var func16 = (function(a, b, c, d, e, f, g) {return a * b * c * d * e * f * g;}); var func17 = (function(a, b, c, d, e, f, g) {return a * b * c * d * e * f * g;}); var func18 = (function(a, b, c, d, e, f, g) {return a * b * c * d * e * f * g;}); var func19 = (function(a, b, c, d, e, f, g) {return a * b * c * d * e * f * g;});');  
   var result0 = func0(100.1, 200.2, 300.3, 400.4, 500.5, 600.6, 700.7);
  var result1 = func1(100.1, 200.2, 300.3, 400.4, 500.5, 600.6, 700.7);
  var result2 = func2(100.1, 200.2, 300.3, 400.4, 500.5, 600.6, 700.7);
  var result3 = func3(100.1, 200.2, 300.3, 400.4, 500.5, 600.6, 700.7);
  var result4 = func4(100.1, 200.2, 300.3, 400.4, 500.5, 600.6, 700.7);
  var result5 = func5(100.1, 200.2, 300.3, 400.4, 500.5, 600.6, 700.7);
  var result6 = func6(100.1, 200.2, 300.3, 400.4, 500.5, 600.6, 700.7);
  var result7 = func7(100.1, 200.2, 300.3, 400.4, 500.5, 600.6, 700.7);
  var result8 = func8(100.1, 200.2, 300.3, 400.4, 500.5, 600.6, 700.7);
  var result9 = func9(100.1, 200.2, 300.3, 400.4, 500.5, 600.6, 700.7);
  var result10 = func10(100.1, 200.2, 300.3, 400.4, 500.5, 600.6, 700.7);
  var result11 = func11(100.1, 200.2, 300.3, 400.4, 500.5, 600.6, 700.7);
  var result12 = func12(100.1, 200.2, 300.3, 400.4, 500.5, 600.6, 700.7);
  var result13 = func13(100.1, 200.2, 300.3, 400.4, 500.5, 600.6, 700.7);
  var result14 = func14(100.1, 200.2, 300.3, 400.4, 500.5, 600.6, 700.7);
  var result15 = func15(100.1, 200.2, 300.3, 400.4, 500.5, 600.6, 700.7);
  var result16 = func16(100.1, 200.2, 300.3, 400.4, 500.5, 600.6, 700.7);
  var result17 = func17(100.1, 200.2, 300.3, 400.4, 500.5, 600.6, 700.7);
  var result18 = func18(100.1, 200.2, 300.3, 400.4, 500.5, 600.6, 700.7);
  var result19 = func19(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
useEvalArray
useEvalArray();
pending…
Longstring
useEvalLongString();
pending…
useEvalLoop
useEvalLoop();
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