eval-methods

JavaScript performance comparison

Revision 7 of this test case created

Info

http://moduscreate.com/javascript-performance-tips-tricks/

Preparation code

 
<script>
Benchmark.prototype.setup = function() {
    var strCode = 'var str="";for(var i=0;i<1000;i+=1){str+="a";}';
};
</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
eval (not wrapped)
(function() {
  eval(strCode);
})();
pending…
new Function
(function() {
  (new Function(strCode))();
})();
pending…
global eval
(function() {
  (0,eval)(strCode);
})();
pending…
no eval
var str="";
for(var i=0;i<1000;i+=1){str+="a";}
 
pending…
eval (wrapped)
(function() {
  eval('(function(){'+strCode+'})()');
})();
pending…
do nothing
if (false)
  strCode = '';
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