Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
indexOf vs map 002-5b
(version: 0)
Comparing performance of:
indexOf vs map
Created:
2 years ago
by:
Guest
Jump to the latest result
Script Preparation code:
var array = []; for (var i=0; i<5; ++i) { array.push('00' + i); } function hasWithIndexOf(needle) { return array.indexOf(needle) !== -1; } var map = {}; array.forEach(item => map.set(item, true)); function hasWithMap(needle) { return needle in map; }
Tests:
indexOf
for (var i=0; i<100; ++i) { array.indexOf("404") !== -1; // array.indexOf("000") !== -1; }
map
for (var i=0; i<100; ++i) { const x = map.has("404"); }
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
indexOf
map
Fastest:
N/A
Slowest:
N/A
Latest run results:
No previous run results
This benchmark does not have any results yet. Be the first one
to run it!
Comments
Confirm delete:
Do you really want to delete benchmark?