speedr.js vs normal object iteration

JavaScript performance comparison

Test case created by genericdave

Info

Compares speedr.js iterators to normal object iteration.

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
var counter = 0;
for (k in obj) {
  var v = obj[k];
  counter++;
}
pending…
speedr.js each
var counter = 0;
map.each(function(k, v) {
  counter++;
});
pending…
speedr.js iter
var counter = 0;
for (var i = 0; i < map.length; i++) {
  var ref = map.iter(i);
  var k = ref[0];
  var v = ref[1];
  counter++;
}
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