Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Lodash _,keys() vs Lodash _.keysIn()
(version: 0)
Comparing performance of:
_.keys() vs _.keysIn()
Created:
2 years ago
by:
Guest
Jump to the latest result
HTML Preparation code:
<script src=" https://cdn.jsdelivr.net/npm/lodash@4.17.21/lodash.min.js "></script>
Script Preparation code:
var value = { a: 30310, b: 100303, c: 3040494 };
Tests:
_.keys()
_.keys(value)
_.keysIn()
_.keysIn(value)
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
_.keys()
_.keysIn()
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
one year ago
)
User agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/129.0.0.0 Safari/537.36
Browser/OS:
Chrome 129 on Windows
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
_.keys()
7080037.5 Ops/sec
_.keysIn()
6393743.0 Ops/sec
Autogenerated LLM Summary
(model
llama3.2:3b
, generated one year ago):
I'd be happy to explain the benchmark! **What is tested?** The provided JSON represents two individual test cases, each testing the performance of a different method in the Lodash library: `_.keys()` and `_.keysIn()`. The test cases are designed to measure how quickly these methods can iterate over the keys of an object. **Options compared** Two options are being compared: 1. `_.keys()`: This method returns an array containing all the property names of the input value. 2. `_.keysIn()`: This method returns an array containing all the property names of the input value, including inherited properties (i.e., properties from the prototype chain). **Pros and Cons** * **_.keys()**: Pros: + Faster execution time since it only iterates over the immediate properties of the object. + May be more efficient for objects with a small number of properties. Cons: + May not include inherited properties, which could be desirable in some cases. + Can be slower than `_.keysIn()` when the object has many properties or an extensive prototype chain. * **_.keysIn()**: Pros: + Includes all properties (inherited and non-inherited) of the object. Cons: + May be slower due to the additional work required to iterate over the entire property chain. **Library: Lodash** Lodash is a popular JavaScript library that provides a collection of reusable functions for various tasks, including array manipulation, object transformation, and more. In this benchmark, we're using version 4.17.21 of the `lodash.min.js` library. The `_.keys()` and `_.keysIn()` methods are part of Lodash's utility functions, which can be used to work with objects in a concise and efficient manner. **Special JavaScript feature or syntax** There is no special JavaScript feature or syntax being tested here. The benchmark is focused solely on the performance comparison between `_.keys()` and `_.keysIn()`. **Other alternatives** If you need to perform similar operations without using Lodash, you could use built-in methods like: * `Object.keys()`: Returns an array of a given object's own enumerable property names. * `Object.getOwnPropertyNames()`: Returns an array of all the properties (including inherited) of an object. However, these built-in methods may not offer the same level of performance or convenience as Lodash's utility functions.
Related benchmarks:
lodash.keys vs Object.keys
lodash.keys vs Object.keys
lodash.keys vs Object.keys
lodash.keys vs Object.keys
lodash.keys [4.17.11] vs Object.keys
Comments
Confirm delete:
Do you really want to delete benchmark?