Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
Set has vs object key - small object, no caching
performance comparison of looking up a value from a set
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/134.0.0.0 Safari/537.36
Browser:
Chrome 134
Operating system:
Mac OS X 10.15.7
Device Platform:
Desktop
Date tested:
one year ago
Test name
Executions per second
Includes
15876717.0 Ops/sec
Object[key]
14940740.0 Ops/sec
Set.has
19964588.0 Ops/sec
Script Preparation code:
var obj = { '.': true, ' ': true, ',': true, ';': true, }; var array = Object.keys(obj); var set = new Set(array); function getKey() { return array[Math.floor(Math.random() * array.length)]; } function getNonKey() { return Math.random() > 0.5 ? '!' : '?'; }
Tests:
Includes
array.includes(getKey()) && array.includes(getNonKey())
Object[key]
obj[getKey()] && obj[getNonKey()]
Set.has
set.has(getKey()) && set.has(getNonKey())