Run details:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/125.0.0.0 Safari/537.36 Edg/125.0.0.0
Chrome 125
Windows
Desktop
2 years ago
Benchmark.js
keyBy with for loop
3.9M/s
keyBy with native reduce
3.7M/s
keyBy with forEach
2.2M/s
View exact numbers
| Test name |
Executions per second |
|
✓
keyBy with for loop
|
3,880,766 Ops/sec |
|
keyBy with native reduce
|
3,748,769 Ops/sec |
|
lodash/keyBy
|
3,151,858 Ops/sec |
|
keyBy with forEach
|
2,160,566 Ops/sec |
Tests:
-
lodash/keyBy
-
keyBy with native reduce
-
keyBy with forEach
-
keyBy with for loop