Run details:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36
Chrome 122
Windows
Desktop
2 years ago
Benchmark.js
keyBy with for loop
2.8M/s
keyBy with native reduce
2.6M/s
keyBy with forEach
1.4M/s
View exact numbers
| Test name |
Executions per second |
|
✓
keyBy with for loop
|
2,775,003 Ops/sec |
|
keyBy with native reduce
|
2,586,783 Ops/sec |
|
lodash/keyBy
|
1,945,092 Ops/sec |
|
keyBy with forEach
|
1,441,661 Ops/sec |
Tests:
-
lodash/keyBy
-
keyBy with native reduce
-
keyBy with forEach
-
keyBy with for loop