removeChild top-to-bottom vs. bottom-up (v3)

Revision 3 of this benchmark created by John-David Dalton on


Description

Tests if it’s faster to remove list elements starting at the top or at the bottom.

Preparation HTML

<ul id="myul"><li>x</li></ul>

Setup

var ul = document.getElementById('myul'),
       li = document.createElement('li'),
       count = this.count;
  
   ul.innerHTML = '';
   li.innerHTML = 'x';
  
   while (count--) {
    ul.appendChild(li.cloneNode(true));
   }

Test runner

Ready to run.

Testing in
TestOps/sec
Bottom-up
ul.removeChild(ul.lastChild);
ready
Top-to-bottom
ul.removeChild(ul.firstChild);
ready

Revisions

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

  • Revision 3: published by John-David Dalton on