Run details:
Mozilla/5.0 (iPhone; CPU iPhone OS 17_2_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.2 Mobile/15E148 Safari/604.1
Mobile Safari 17
iOS 17.2.1
Mobile
2 years ago
Benchmark.js
keyBy with for loop
13.8M/s
keyBy with native reduce
12.3M/s
keyBy with forEach
6.7M/s
View exact numbers
| Test name |
Executions per second |
|
✓
keyBy with for loop
|
13,837,790 Ops/sec |
|
map
|
12,496,121 Ops/sec |
|
keyBy with native reduce
|
12,285,606 Ops/sec |
|
lodash/keyBy
|
10,463,237 Ops/sec |
|
keyBy with forEach
|
6,735,573 Ops/sec |
Tests:
-
lodash/keyBy
-
keyBy with native reduce
-
keyBy with forEach
-
keyBy with for loop
-
map