Toggle navigation
MeasureThat
.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
lodash partition vs forEach with array spread iterator vs array push vs for each with concat vs two filters with 10000
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
forEach with push
34K/s
Lodash partition
25K/s
two filters
24K/s
forEach with spread
58/s
forEach with concat
15/s
View exact numbers
Test name
Executions per second
✓
forEach with push
33,878 Ops/sec
Lodash partition
25,208 Ops/sec
two filters
24,349 Ops/sec
forEach with spread
58 Ops/sec
forEach with concat
15 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
let result = _.partition(tabl, v => v%2)
forEach with push
let a = [], b = []; let result = tabl.forEach(item => {if (item%2) {a.push(item)} else {b.push(item)}})
forEach with spread
let a = [], b = []; let result = tabl.forEach(item => {if (item%2) {a = [...a, item]} else {b = [...b, item]}})
forEach with concat
let a = [], b = []; let result = tabl.forEach(item => {if (item%2) {a = a.concat(item)} else {b = b.concat(item)}})
two filters
a = tabl.filter(item => item % 2) b = tabl.filter(item => !item % 2)