lodash partition vs remove 3
Date tested:
one year ago
User agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/116.0.0.0 Safari/537.36 Edg/116.0.1938.76
Test name
Executions per second
lodash partition
6260.9 Ops/sec
lodash remove
5708.4 Ops/sec
Benchmark definition (click to collapse):
HTML Preparation code:
<script src='https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.5/lodash.min.js'></script>
Script Preparation code:
function randomIntFromInterval(min, max) { // min and max included return Math.floor(Math.random() * (max - min + 1) + min) } var tabl = Array.from({ length: 10000 }).map((value, i) => ({ id: i, value: randomIntFromInterval(0, i) }))
Tests:
lodash partition
const [a, b] = _.partition(tabl, e => e.value % 2)
lodash remove
const a = _.remove(tabl, e => e.value % 2) tabl = [...tabl, ...a]
Open this result on MeasureThat.net