Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
lodash partition vs reduce with array push vs two filter loops
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/131.0.0.0 Safari/537.36
Browser:
Chrome 131
Operating system:
Mac OS X 10.15.7
Device Platform:
Desktop
Date tested:
one year ago
Test name
Executions per second
Lodash partition
12953.6 Ops/sec
reduce with array push
27569.8 Ops/sec
double filter
22451.0 Ops/sec
HTML Preparation code:
<script src='https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.5/lodash.min.js'></script>
Script Preparation code:
var tabl = Array.from({ length: 10000 }).map((value, i) => i)
Tests:
Lodash partition
const [a, b] = _.partition(tabl, e => e % 2)
reduce with array push
const partition = (a, p) => a.reduce((result, e, i) => (result[p(e) ? 0 : 1].push(e), result), [[], []]); const predicate = e => e % 2; const [a, b] = partition(tabl, predicate);
double filter
const a = tabl.filter(e => e % 2); const b = tabl.filter(e => !e % 2);