testing loops over dom nodes

JavaScript performance comparison

Test case created by

Preparation code

<ul id="test-node">
<li>node</li>
<li>node</li>
<li>node</li>
<li>node</li>
<li>node</li>
<li>node</li>
<li>node</li>
<li>node</li>
</ul>
      
<script>
Benchmark.prototype.setup = function() {
  nodes = document.getElementById('test-node').childNodes;
  
  function worker() {
    return (1 + 1);
  }

};
</script>

Preparation code output

<ul id="test-node"> <li>node</li> <li>node</li> <li>node</li> <li>node</li> <li>node</li> <li>node</li> <li>node</li> <li>node</li> </ul>

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
classic
for (var i = 0; i < nodes.length; i++) {
  worker();
}
pending…
cached
for (var i = 0, len = nodes.length; i < len; i++) {
  worker();
}
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.

0 Comments