Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Lodash find
(version: 0)
Comparing performance of:
lodash.find vs native.find
Created:
7 years ago
by:
Guest
Jump to the latest result
HTML Preparation code:
<script src="https://cdn.jsdelivr.net/lodash/4.16.0/lodash.min.js"></script>
Script Preparation code:
var value = [ { a: 100 }, { a: 101 }, { a: 102 }, { a: 103 }, { a: 104 }, { a: 105 }, { a: 106 }, { a: 107 }, { a: 108 }, { a: 109 }, { a: 110 }, { a: 111 }, { a: 112 }, { a: 113 }, { a: 114 }, { a: 115 }, { a: 116 }, { a: 117 }, { a: 118 }, { a: 119 }, { a: 120 }, { a: 121 }, { a: 122 }, { a: 123 }, { a: 124 }, { a: 125 }, { a: 126 }, { a: 127 }, { a: 128 }, { a: 129 }, { a: 130 }, { a: 131 }, { a: 132 }, { a: 133 }, { a: 134 }, { a: 135 }, { a: 136 }, { a: 137 }, { a: 138 }, { a: 139 }, { a: 140 }, { a: 141 }, { a: 142 }, { a: 143 }, { a: 144 }, { a: 145 }, { a: 146 }, { a: 147 }, { a: 148 }, { a: 149 }, { a: 150 }, { a: 151 }, { a: 152 }, { a: 153 }, { a: 154 }, { a: 155 }, { a: 156 }, { a: 157 }, { a: 158 }, { a: 159 }, { a: 160 }, { a: 161 }, { a: 162 }, { a: 163 }, { a: 164 }, { a: 165 }, { a: 166 }, { a: 167 }, { a: 168 }, { a: 169 }, { a: 170 }, { a: 171 }, { a: 172 }, { a: 173 }, { a: 174 }, { a: 175 }, { a: 176 }, { a: 177 }, { a: 178 }, { a: 179 }, { a: 180 }, { a: 181 }, { a: 182 }, { a: 183 }, { a: 184 }, { a: 185 }, { a: 186 }, { a: 187 }, { a: 188 }, { a: 189 }, { a: 190 }, { a: 191 }, { a: 192 }, { a: 193 }, { a: 194 }, { a: 195 }, { a: 196 }, { a: 197 }, { a: 198 }, { a: 199 }];
Tests:
lodash.find
_.find(value, (i) => i.a === 180)
native.find
value.find((i) => i.a === 180)
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
lodash.find
native.find
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):
Let's dive into the world of JavaScript microbenchmarks! **Benchmark Definition JSON** The provided benchmark definition consists of two main parts: 1. **Script Preparation Code**: This is a JavaScript code snippet that creates an array `value` with 200 elements, each containing an object with a property `a`. The value of `a` increases consecutively from 100 to 200. 2. **Html Preparation Code**: This is a HTML snippet that includes a script tag pointing to the Lodash library (version 4.16.0) hosted on CDN. **Individual Test Cases** There are two test cases: 1. **Lodash find**: This benchmark tests the `_.find` function from the Lodash library, which takes two arguments: an array (`value`) and a callback function `(i) => i.a === 180`. The callback function is used to filter elements in the array based on the condition `i.a === 180`. 2. **Native find**: This benchmark tests the native JavaScript `find` method on the `value` array, which also takes two arguments: an array (`value`) and a callback function `(i) => i.a === 180`. The callback function is used to filter elements in the array based on the condition `i.a === 180`. **What's being tested?** In essence, these benchmarks are testing the performance of two approaches: 1. **Lodash find**: This tests how fast Lodash can find a specific element in the array using its optimized implementation. 2. **Native find**: This tests how fast the native JavaScript `find` method can find an element in the array. **Options compared** The benchmark is comparing the performance of two approaches: 1. **Lodash**: Using the `_.find` function from Lodash library. 2. **Native**: Using the built-in JavaScript `find` method on the `value` array. **Pros and Cons** Here's a brief summary: * **Lodash**: + Pros: Lodash is an established library with optimized implementations, reducing the complexity of filtering arrays. + Cons: Adding overhead due to library dependencies and potential performance trade-offs. * **Native**: + Pros: Native JavaScript methods are often faster and more efficient than third-party libraries. + Cons: Requires manual implementation of the filtering logic, which can be error-prone. **Other considerations** When choosing between these two approaches, consider the following: * **Performance**: If speed is crucial, native `find` might be a better choice. However, if you prioritize ease of use and less code maintenance, Lodash might be a better fit. * **Complexity**: If your filtering logic is complex or requires multiple conditions, using a library like Lodash can simplify the process. **Latest Benchmark Result** The latest benchmark result shows two runs for each test case: 1. **Lodash find**: 414236.71875 executions per second 2. **Native find**: 3309630.5 executions per second These results indicate that native `find` is significantly faster than Lodash in this specific scenario. However, keep in mind that these results might vary depending on the specific use case and environment. There you have it! A deep dive into JavaScript microbenchmarks.
Related benchmarks:
map lodash vs natvie
indexof vs set123
index vs map111
lodash flatmap vs Vanilla flatmap 3
Comments
Confirm delete:
Do you really want to delete benchmark?