Run details:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/127.0.0.0 Safari/537.36
Chrome 127
Windows
Desktop
2 years ago
Benchmark.js
keyBy with for loop
4.5M/s
keyBy with native reduce
4.3M/s
keyBy with forEach
2.3M/s
View exact numbers
| Test name |
Executions per second |
|
✓
keyBy with for loop
|
4,524,532 Ops/sec |
|
keyBy with native reduce
|
4,278,097 Ops/sec |
|
lodash/keyBy
|
3,200,305 Ops/sec |
|
keyBy with forEach
|
2,324,570 Ops/sec |
Tests:
-
lodash/keyBy
-
keyBy with native reduce
-
keyBy with forEach
-
keyBy with for loop