Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
set.has vs. array.includes vs plain object (100 000)
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/132.0.0.0 Safari/537.36
Browser:
Chrome 132
Operating system:
Windows
Device Platform:
Desktop
Date tested:
one year ago
Test name
Executions per second
Array.includes (best scenario)
20022028.0 Ops/sec
Set.has
24463558.0 Ops/sec
Object access
34589364.0 Ops/sec
Array.includes (middle scenario)
53375.5 Ops/sec
Array.includes (worst scenario)
26713.0 Ops/sec
Script Preparation code:
var length = 100000; var a = Array.from({ length }, (e, i) => i+1); var b = new Set(a); var c = Object.fromEntries(a.map(e => [e, true])); var best = 1; var worst = length; var middle = length / 2;
Tests:
Array.includes (best scenario)
return a.includes(best)
Set.has
return b.has(best)
Object access
return c[best]
Array.includes (middle scenario)
return a.includes(middle)
Array.includes (worst scenario)
return a.includes(worst)