Toggle navigation
MeasureThat
.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
Index an element in array.
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/143.0.0.0 Safari/537.36
Browser:
Chrome 143
Operating system:
Windows
Device Platform:
Desktop
Date tested:
7 months ago
Map.get Object
89.9M/s
Map.get
48.3M/s
Array.findIndex Object
28.7M/s
Array.findIndex
22.5M/s
Array.indexOf Object
21.5M/s
Array.indexOf
14.1M/s
View exact numbers
Test name
Executions per second
✓
Map.get Object
89,910,304 Ops/sec
Map.get
48,334,256 Ops/sec
Array.findIndex Object
28,675,804 Ops/sec
Array.findIndex
22,477,300 Ops/sec
Array.indexOf Object
21,452,514 Ops/sec
Array.indexOf
14,068,353 Ops/sec
HTML Preparation code:
<!--your preparation HTML code goes here--> <script src='https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.21/lodash.min.js'></script>
Script Preparation code:
const array = Array.from({ length: 10 }, () => Math.random()); const arrayObject = Array.from({ length: 10 }, () => ({ value: Math.random() })); const map = new Map(); const mapObject = new Map(); array.forEach((v, i) => map.set(v, i)); arrayObject.forEach((v, i) => map.set(v, i)); const testArray = _.shuffle(array); const testArrayObject = _.shuffle(arrayObject);
Tests:
Array.indexOf
testArray.forEach(v => { const index = array.indexOf(v); });
Map.get
testArray.forEach(v => { const index = map.get(v) ?? -1; });
Array.findIndex
testArray.forEach(v => { const index = array.findIndex(vv => v === vv); });
Array.indexOf Object
testArrayObject.forEach(v => { const index = arrayObject.indexOf(v); });
Map.get Object
testArrayObject.forEach(v => { const index = mapObject.get(v) ?? -1; });
Array.findIndex Object
testArrayObject.forEach(v => { const index = arrayObject.findIndex(vv => v === vv); });