lodash omitBy vs Array.reduce omit by 100k
Date tested:
one month ago
User agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36
Test name
Executions per second
Lodash
2139758.0 Ops/sec
Native
5089965.0 Ops/sec
Native with Entries
6023474.0 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:
var max2 = 100000; var data = {}; for (var i = 0; i <= max2; i++) { data['id'] = i; }
Tests:
Lodash
_.omitBy(data, (item) => item.id === 5000)
Native
Object.keys(data).reduce((result, key) => { if (key !== 5000) { result[key] = data[key]; } return result; }, {})
Native with Entries
Object.entries(data).reduce((result, entry) => { if (entry[1] !== 5000) { result[entry[0]] = entry[1]; } return result; }, {})
Open this result on MeasureThat.net