HTML Preparation code:
x
 
1
<ul>
2
</ul>
3
4
<ol>
5
</ol>
Script Preparation code:
 
const ul = document.querySelector('ul');
const ol = document.querySelector('ul');
for (let i = 0; i < 1000; i++) {
    const li = document.createElement('li')
    li.classList.add(i % 2 === 0 ? 'even' : 'odd')
    ul.appendChild(document.createElement('li'));
    ol.appendChild(document.createElement('li'));
}
var oddListItems = document.querySelectorAll('li.odd');
var anything = [];
Tests:
  • for ... of

     
    for (const item of oddListItems) {
        anything.push(item);
    }
  • Array.from

     
    Array.from(oddListItems).forEach(item => anything.push(item));
  • NodeList.forEach

     
    oddListItems.forEach(item => anything.push(item));
Rendered benchmark preparation results:

Suite status: <idle, ready to run>

Previous results

Experimental features:

  • Test case name Result
    for ... of
    Array.from
    NodeList.forEach

    Fastest: N/A

    Slowest: N/A

Latest run results:
Run details: (Test run date: 5 months ago)
Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:131.0) Gecko/20100101 Firefox/131.0
Firefox 131 on Ubuntu
View result in a separate tab
Test name Executions per second
for ... of 56175100.0 Ops/sec
Array.from 22263000.0 Ops/sec
NodeList.forEach 97272792.0 Ops/sec