speedr.js vs normal object iteration (v4)

Revision 4 of this benchmark created on


Description

Compares speedr.js iterators to normal object iteration.

All functions are designed so that they end up with two local variables, k and v, which correspond to key, value pairs.

Preparation HTML

<script src="https://raw.github.com/genericdave/speedr.js/master/speedr.js">
</script>

Setup

var obj = {};
    var map = new speedr.Map();
    
    for (i = 0; i <= 1000; i++) {
      iS = i.toString();
      obj[iS] = iS;
      map.set([iS, iS]);
    }

Test runner

Ready to run.

Testing in
TestOps/sec
Normal object for loop
for (k in obj) {
  var v = obj[k]
}
ready
speedr.js each
map.each(function(k, v) {});
ready
speedr.js iter
for (var i = 0; i < map.length; i++) {
  var ref = map.iter(i);
  var k = ref[0];
  var v = ref[1];
}
ready
keys
Object.keys(obj).forEach(function(k){
  var v = obj[k]
})
ready

Revisions

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