Run details:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/112.0.0.0 Iron Safari/537.36
Chrome 112
Windows
Desktop
2 years ago
Benchmark.js
keyBy with for loop
10.7M/s
keyBy with native reduce
10.2M/s
keyBy with forEach
5.7M/s
View exact numbers
| Test name |
Executions per second |
|
✓
keyBy with for loop
|
10,722,279 Ops/sec |
|
keyBy with native reduce
|
10,248,001 Ops/sec |
|
lodash/keyBy
|
7,363,330 Ops/sec |
|
keyBy with forEach
|
5,675,043 Ops/sec |
Tests:
-
lodash/keyBy
-
keyBy with native reduce
-
keyBy with forEach
-
keyBy with for loop