Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
Lodash find vs binary find
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/144.0.0.0 Safari/537.36
Browser:
Chrome 144
Operating system:
Mac OS X 10.15.7
Device Platform:
Desktop
Date tested:
3 months ago
Test name
Executions per second
Lodash find
28552550.0 Ops/sec
Binary find
503730.5 Ops/sec
HTML Preparation code:
<script src='https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.5/lodash.min.js'></script>
Tests:
Lodash find
var a = ['hello', 'a', 'bc']; var b = _.find(a, item => item === 'bc');
Binary find
var a = ['hello', 'a', 'bc']; var test = function (array, id){ var startIndex = 0, stopIndex = array.length - 1, middle = Math.floor((stopIndex + startIndex)/2); while(array[middle] != id && startIndex < stopIndex){ if (id < array[middle]){ stopIndex = middle - 1; } else if (id > array[middle]){ startIndex = middle + 1; } middle = Math.floor((stopIndex + startIndex)/2); } return (array[middle] != id) ? undefined : array[middle]; } console.log(test(a, 'a'));