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:
2 months ago
array
86K/s
set
85K/s
Array for Each
40K/s
Set for Each
17K/s
View exact numbers
Test name
Executions per second
✓
array
86,308 Ops/sec
set
84,817 Ops/sec
Array for Each
39,889 Ops/sec
Set for Each
16,858 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)