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 (X11; CrOS x86_64 14541.0.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/132.0.0.0 Safari/537.36
Browser:
Chrome 132
Operating system:
Chrome OS 14541.0.0
Device Platform:
Desktop
Date tested:
one year ago
Test name
Executions per second
array for...of
3704.2 Ops/sec
set for...of
3685.1 Ops/sec
array.forEach
18994.3 Ops/sec
set.forEach
22912.3 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)