Run details:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36
Chrome 121
Windows
Desktop
2 years ago
Benchmark.js
keyBy with native reduce
4.7M/s
keyBy with for loop
4.7M/s
keyBy with forEach
2.4M/s
View exact numbers
| Test name |
Executions per second |
|
✓
keyBy with native reduce
|
4,708,755 Ops/sec |
|
keyBy with for loop
|
4,672,603 Ops/sec |
|
lodash/keyBy
|
3,333,053 Ops/sec |
|
keyBy with forEach
|
2,433,991 Ops/sec |
Tests:
-
lodash/keyBy
-
keyBy with native reduce
-
keyBy with forEach
-
keyBy with for loop