speedr.js vs normal object iteration

JavaScript performance comparison

Revision 4 of this test case created

Info

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 code

<script src="https://raw.github.com/genericdave/speedr.js/master/speedr.js">
</script>
<script>
Benchmark.prototype.setup = function() {
    var obj = {};
    var map = new speedr.Map();
   
    for (i = 0; i <= 1000; i++) {
      iS = i.toString();
      obj[iS] = iS;
      map.set([iS, iS]);
    }
};
</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
Normal object for loop
for (k in obj) {
  var v = obj[k]
}
pending…
speedr.js each
map.each(function(k, v) {});
pending…
speedr.js iter
for (var i = 0; i < map.length; i++) {
  var ref = map.iter(i);
  var k = ref[0];
  var v = ref[1];
}
pending…
keys
Object.keys(obj).forEach(function(k){
  var v = obj[k]
})
pending…

Compare results of other browsers

Revisions

You can edit these tests or add even more tests to this page by appending /edit to the URL. Here’s a list of current revisions for this page:

0 comments

Add a comment