eval-methods

JavaScript performance comparison

Revision 10 of this test case created by Quentin

Info

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

Preparation code

 
<script>
Benchmark.prototype.setup = function() {
   
    var strCode = 'var str="",i=0;for(;i<1;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
(function() {
  eval(strCode);
})();
pending…
new Function
(function() {
  (new Function(strCode))();
})();
pending…
Native
var str = "";
for (var i = 0; i < 1; i += 1) {
  str += "a";
}
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