Measure the time needed to execute a given function.
Similar to jsperf.com but doesn't need to be hosted.
For async functions (e.g. with disk/network I/O), use estimateAsync()
.
For sync functions, e.g. (CPU intensive calculations), use estimateSync()
The cost of OOP: source
Approach | Time to iterate 1m times | ops/second |
---|---|---|
FP | 662.61 ms | 1510 k |
OOP | 5604.00 ms | 180 k |
More examples: