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
Test name
Executions per second
Lodash partition
25207.9 Ops/sec
forEach with push
33877.6 Ops/sec
forEach with spread
58.2 Ops/sec
forEach with concat
15.1 Ops/sec
two filters
24349.4 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)