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:140.0) Gecko/20100101 Firefox/140.0
Browser:
Firefox 140
Operating system:
Windows
Device Platform:
Desktop
Date tested:
one year ago
array.forEach
373K/s
set.forEach
341K/s
array for...of
267K/s
set for...of
122K/s
View exact numbers
Test name
Executions per second
✓
array.forEach
372,976 Ops/sec
set.forEach
341,051 Ops/sec
array for...of
267,120 Ops/sec
set for...of
121,948 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)