Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
findIndex vs IndexOf + map vs binary search
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/138.0.0.0 Mobile Safari/537.36
Browser:
Chrome Mobile 138
Operating system:
Android
Device Platform:
Mobile
Date tested:
9 months ago
Test name
Executions per second
findIndex
38301.5 Ops/sec
Map + IndexOf
3800.1 Ops/sec
Binary search
9317477.0 Ops/sec
HTML Preparation code:
<script> function binarySearch(lst, x) { var left = 0; var right = lst.length - 1; while (left <= right) { var mid = Math.floor((left + right) / 2); if (lst[mid] === x) { return mid; } if (lst[mid] < x) { left = mid + 1; } else { right = mid - 1; } } return -1; } </script>
Script Preparation code:
var arr = new Array(15000); arr.fill({ id: 0 }); arr = arr.map((el, idx) => el.id = idx); var foo = Math.floor(Math.random() * 15000);
Tests:
findIndex
arr.findIndex(x => x.id ===foo );
Map + IndexOf
arr.map(x => x.id).indexOf(foo);
Binary search
binarySearch(arr,foo)