js-loop-compare

JavaScript performance comparison

Test case created by ClarenceChan

Preparation code


      
      <script>
Benchmark.prototype.setup = function() {
  var nullarr = new Array(10000),
      dataarr = [];
  
  for(var i = 0 ;i < 10000; i++){
    if ( i % 2 === 0) {
    dataarr[i] = i.toString()
  } else {
    dataarr[i] = i
  }
  }
  for(var i = 0 ;i < 10000; i++){
    if( i % 2 ===0) {
    nullarr[i] = new Object(i)
    } else {
    nullarr[i] = i
   }
  }

};
</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
for dataarr
for(var i = 0; i < dataarr.length; i++ ){
  //console.log(dataarr[i])
}
pending…
for dataarr len
for(var i = 0, len = dataarr.length; i < len; i++){
  //console.log(witharr[i])
}
pending…
forEach dataarr
dataarr.forEach(function(item){
})
pending…
for in dataarr
for(item in dataarr){
}
pending…
for of dataarr
for(item of dataarr){
}
pending…
map dataarr
dataarr.map(function(item){
})
pending…
filter dataarr
dataarr.filter(function(item){

})
pending…

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

0 Comments