for vs. white nextSibling

JavaScript performance comparison

Test case created

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

Child

Child

Child

Child

Child

Child

Child

Child

Child

Child

Test runner

Warning! For accurate results, please disable Firebug before running the tests. (Why?)

Java applet disabled.

Testing in unknown unknown
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

Add a comment