Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Set has vs object key bigger list
(version: 1)
performance comparison of ways to find if an array contains a value
Comparing performance of:
Includes vs Object[key] vs Set.has
Created:
one year ago
by:
Guest
Jump to the latest result
Script Preparation code:
var obj = (new Array(100000)).fill(null).reduce((prev, newVal) => {prev[Math.random() + ''] = Math.random() + ''; return prev; }, { sausage: 'tst' }); var array = Object.keys(obj); var set = new Set(array);
Tests:
Includes
array.includes('sausage')
Object[key]
obj['sausage']
Set.has
set.has('saudage')
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (3)
Previous results
Fork
Test case name
Result
Includes
Object[key]
Set.has
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
one year ago
)
User agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/132.0.0.0 Safari/537.36
Browser/OS:
Chrome 132 on Mac OS X 10.15.7
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
Includes
121257752.0 Ops/sec
Object[key]
104016992.0 Ops/sec
Set.has
147995904.0 Ops/sec
Related benchmarks:
array includes vs object key
Set has vs object key
Set has vs object keyx
Set has vs object key reversed
Set has vs prop in object
array includes vs object key vs set
Set has vs object key 3
Set has vs object key vs map has
Set has vs object key vs Array includes (key is at the end)
Comments
Confirm delete:
Do you really want to delete benchmark?