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:
10 months ago
Test name
Executions per second
array for...of
267120.2 Ops/sec
set for...of
121947.6 Ops/sec
array.forEach
372976.0 Ops/sec
set.forEach
341051.2 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)