Script Preparation code:
x
 
var set1 = new Set();
var count = 1000;
for(var i = 0; i<count; i++)
{
  set1.add(i);
}
Tests:
  • for

     
    for (const contentId of set1) {
        set1.has(contentId);
    }
  • foreach

     
    function setTest(contentId){
        set1.has(contentId);
    }
    set1.forEach(setTest)
Rendered benchmark preparation results:

Suite status: <idle, ready to run>

Previous results

Experimental features:

  • Test case name Result
    for
    foreach

    Fastest: N/A

    Slowest: N/A

Latest run results:
Run details: (Test run date: 2 years ago)
Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.0.0 Safari/537.36
Chrome 103 on Linux
View result in a separate tab
Test name Executions per second
for 13711.5 Ops/sec
foreach 13404.9 Ops/sec