Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
for of set vs array and forEach
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:146.0) Gecko/20100101 Firefox/146.0
Browser:
Firefox 146
Operating system:
Windows
Device Platform:
Desktop
Date tested:
3 months ago
Test name
Executions per second
array for...of
43344.3 Ops/sec
set for...of
20466.9 Ops/sec
array.forEach
114210.9 Ops/sec
set.forEach
52502.8 Ops/sec
HTML Preparation code:
<!--your preparation HTML code goes here-->
Script Preparation code:
let arr = Array.from({length:1000},(a,i)=>i), set = new Set(arr), num = 0 function forEach(i) {num += i}
Tests:
array for...of
for(let n of arr) num+= n
set for...of
for(let n of set) num+= n
array.forEach
arr.forEach(forEach)
set.forEach
set.forEach(forEach)