Ordered Iterating

JavaScript performance comparison

Test case created by p4ul

Preparation code


      
      <script>
Benchmark.prototype.setup = function() {
  var timeMap = new Map();
  var timeArray = [];
  var dummyResult = []
  
  for (var i=0; i < 3000000; i++) {
     var key = Math.random()
     var val = [Math.random(),Math.random()]
     timeMap.set(key,val);
     timeArray.push(val);
  }

};
</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
Iterate Map
for (var value of timeMap) {
  dummyResult.push(value)
}
pending…
Iterate Array
for (var i=0; i < timeArray.length; i++) {
  dummyResult.push(timeArray[i])
}
pending…
Iterate Array (cached length)
var length = timeArray.length;
for (var i=0; i < length; i++) {
  dummyResult.push(timeArray[i])
}
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