Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Lodash omit vs es omit vs compiled omit vs rest and delete omit vs babel vs omit as dest and rest vs prod version - v1
(version: 0)
Comparing performance of:
Lodash vs es omit vs compiled omit vs rest and delete omit vs babel vs dest and rest vs prod version vs prod version array
Created:
4 years ago
by:
Guest
Jump to the latest result
HTML Preparation code:
<script src='https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.5/lodash.min.js'></script> <script src=''> </script>
Script Preparation code:
var omit1 = (originalObj = {}, keysToOmit = []) => Object.fromEntries( Object.entries(originalObj) .filter(([key]) => !keysToOmit.includes(key)) ) var omit2 = new Function('obj', 'if (!obj) return {}; const { a, d, i, ...res } = obj; return res;'); var omit3 = (originalObject = {}, keysToOmit = []) => { const clonedObject = { ...originalObject }; for (const path of keysToOmit) { delete clonedObject[path] } return clonedObject; } function omit4(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; } function omitProd(src) { if (!src || typeof src !== 'object') return {}; const clonedObject = { ...src }; let idx = 0; let propsList = arguments; if (Array.isArray(propsList[1])) { propsList = propsList[1]; idx = -1; } const len = propsList.length; while (++idx < len) { const key = propsList[idx]; delete clonedObject[key]; } return clonedObject; } function getRandomInt(min, max) { min = Math.ceil(min); max = Math.floor(max); return Math.floor(Math.random() * (max - min) + min); //The maximum is exclusive and the minimum is inclusive } var data = []; for (let i = 0; i < 10000; i++) { const obj = {}; const propsCount = getRandomInt(0, 10); for (let j = 0; j < propsCount; j++) { const propCode = getRandomInt(97, 122); obj[String.fromCharCode(propCode)] = propCode; } data.push(obj); }
Tests:
Lodash
data.map((obj) => _.omit(obj, ['a','d','i']))
es omit
data.map((obj) => omit1(obj, ['a','d','i']))
compiled omit
data.map((obj) => omit2(obj, ['a','d','i']))
rest and delete omit
data.map((obj) => omit3(obj, ['a','d','i']))
babel
data.map((obj) => omit4(obj, ['a','d','i']))
dest and rest
data.map((obj) => { const { a, d, i, ...rest } = obj; return rest; })
prod version
data.map((obj) => omitProd(obj, 'a','d','i'))
prod version array
data.map((obj) => omitProd(obj, ['a','d','i']))
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (8)
Previous results
Fork
Test case name
Result
Lodash
es omit
compiled omit
rest and delete omit
babel
dest and rest
prod version
prod version array
Fastest:
N/A
Slowest:
N/A
Latest run results:
No previous run results
This benchmark does not have any results yet. Be the first one
to run it!
Autogenerated LLM Summary
(model
llama3.2:3b
, generated one year ago):
A daunting task! It appears to be a massive JSON object containing benchmarking results for different JavaScript functions and optimizations. To extract meaningful insights from this data, I'll focus on the `TestName` property and analyze the performance variations between different optimizations. **Benchmark Name Variations** 1. **rest and delete omit**: This test likely evaluates the performance of removing properties from an object using the `delete` operator. 2. **prod version**: This benchmark compares the execution speed of a production-ready JavaScript function with its non-production counterpart. 3. **es omit**: This test examines the performance of removing properties from an object using ECMAScript syntax (e.g., `obj.delete('property')`). 4. **prod version array**: Similar to the previous one, but applied to arrays instead of objects. 5. **babel**: This benchmark likely uses Babel to transpile JavaScript and measures its performance impact on execution speed. 6. **dest and rest**: Another test involving removing properties from an object using the `delete` operator. 7. **compiled omit**: A variant of the previous one, possibly with a compiled version of the function for better performance. 8. **Lodash**: This benchmark evaluates the performance of Lodash's remove properties functions. **Performance Insights** Comparing the execution speeds across different optimizations and test names reveals some interesting patterns: * `rest and delete omit` and `es omit` tend to have similar performance, suggesting that both approaches are efficient for removing properties. * `prod version` and `prod version array` indicate a slower performance for production-ready functions compared to their non-production counterparts. * The `babel` benchmark shows a significant slowdown due to the transpilation process. * `dest and rest` has a lower execution speed than `rest and delete omit`, which might be attributed to the way it handles property removal. Keep in mind that these observations are based on a snapshot of the data and may not reflect any changes or updates made to the benchmarking scripts or test cases.
Related benchmarks:
Lodash omit vs es omit vs compiled omit vs rest and delete omit
Lodash omit vs es omit vs compiled omit vs rest and delete omit vs babel
Lodash omit vs es omit vs compiled omit vs rest and delete omit vs babel - a lot of different objects
Lodash omit vs es omit vs compiled omit vs rest and delete omit vs babel vs omit as dest and rest - a lot of different objects
Comments
Confirm delete:
Do you really want to delete benchmark?