eval VS multiples-variables

JavaScript performance comparison

Test case created by badger

Test runner

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

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
one eval
function Voiture() {
  this.x = 0;
  this.move = function() {
    this.x++;
  }
}

var str = "",
    i = 10000;
while (i--) {
  str += ' var v' + i + ' = new Voiture(); v' + i + '.move();';
}

eval(str);
pending…
multiple eval
function Voiture() {
  this.x = 0;
  this.move = function() {
    this.x++;
  }
}

var str = "",
    i = 10000;
while (i--) {
  eval('var v = new Voiture();');
  v.move();
}
pending…

You can edit these tests or add even more tests to this page by appending /edit to the URL.

Compare results of other browsers

0 comments

Add a comment