Variable declaration

JavaScript performance comparison

Test case created by Joshua Feather

Preparation code

 
<script>
Benchmark.prototype.setup = function() {
    var milliseconds = 4000
};
</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
inside the loop
var one = null;
var two = null;
var two1 = null;
var two2 = null;
var two3 = null;
var two4 = null;

for (var i = 0; i < 10000; i++) {
  one = new Date(milliseconds );
  two = new Date(milliseconds );
  two1 = new Date(milliseconds );
  two2 = new Date(milliseconds );
  two3 = new Date(milliseconds );
  two4 = new Date(milliseconds );
}
pending…
outside the loop
for (var i = 0; i < 10000; i++) {
  var one = new Date(milliseconds );
  var two = new Date(milliseconds );
  var two1 = new Date(milliseconds );
  var two2 = new Date(milliseconds );
  var two3 = new Date(milliseconds );
  var two4 = new Date(milliseconds );
}
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