for vs. white nextSibling

JavaScript performance comparison

Test case created by

Preparation code

<div id="container">
<p>Child</p>
<p>Child</p>
<p>Child</p>
<p>Child</p>
<p>Child</p>
<p>Child</p>
<p>Child</p>
<p>Child</p>
<p>Child</p>
<p>Child</p>
</div>
<script>
  var container = document.getElementById('container');
  
  function process(element) {}
</script>
    

Preparation code output

<div id="container"> <p>Child</p> <p>Child</p> <p>Child</p> <p>Child</p> <p>Child</p> <p>Child</p> <p>Child</p> <p>Child</p> <p>Child</p> <p>Child</p> </div>

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
white
var node = container.firstChild;
while (node) {
 process(node);
 node = node.nextSibling;
}
pending…
for
var node = container.firstChild;
for(node; node; node = node.nextSibling) process(node);
pending…

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

Compare results of other browsers

0 Comments

Child

Child

Child

Child

Child

Child

Child

Child

Child

Child