Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
set vs array iteration + for each - large arrays - sum
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/148.0.0.0 Safari/537.36
Browser:
Chrome 148
Operating system:
Windows
Device Platform:
Desktop
Date tested:
19 days ago
Test name
Executions per second
array
86308.3 Ops/sec
set
84817.4 Ops/sec
Array for Each
39888.5 Ops/sec
Set for Each
16858.0 Ops/sec
Script Preparation code:
const base = Array.from(Array(10000).keys()) var a = base.map(Math.random); var b = new Set(base.map(Math.random)) var c = new Set(base.map(Math.random)) var d = base.map(Math.random);
Tests:
array
let sum = 0 for (const x of a) {sum += x}
set
let sum = 0 for (const x of b) {sum += x}
Array for Each
let sum = 0 d.forEach(x => sum += x)
Set for Each
let sum = 0 c.forEach(x => sum += x)