Toggle navigation
MeasureThat
.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
Set from Array vs Array#forEach(.add)
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/139.0.0.0 Safari/537.36
Browser:
Chrome 139
Operating system:
Windows
Device Platform:
Desktop
Date tested:
11 months ago
of
24/s
new Set
10/s
.add
8/s
View exact numbers
Test name
Executions per second
✓
of
24 Ops/sec
new Set
10 Ops/sec
.add
8 Ops/sec
Script Preparation code:
let sourceArray = [] for(let i=1; i<1000000; i++) { sourceArray.push(i) } class SetlikeArray extends Array { has(key) { return this.includes(key); } keys() { return this[Symbol.iterator]() } get size() { return this.length } }
Tests:
new Set
const setObject = new Set(sourceArray)
.add
const setObject = new Set() sourceArray.forEach(x => setObject.add(x))
of
const setObject = new SetlikeArray(); for(let i=1; i<1000000; i++) { setObject.push(i) }