Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
map vs array
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:136.0) Gecko/20100101 Firefox/136.0
Browser:
Firefox 136
Operating system:
Windows
Device Platform:
Desktop
Date tested:
one year ago
Test name
Executions per second
array
22376.2 Ops/sec
map
2174710.2 Ops/sec
Script Preparation code:
var array = []; for (var i=0; i<300; ++i) { array.push('00' + i); } function hasWithIndexOf(needle) { return array.indexOf(needle) !== -1; } var map = new Set(); array.forEach(item => map.add(item)); function hasWithMap(needle) { return map.has(needle); }
Tests:
array
for (var i=0; i<100; ++i) { hasWithIndexOf('404'); }
map
for (var i=0; i<100; ++i) { hasWithMap('404'); }