https://github.com/beenotung/benchmark.ts
Measure the time needed to execute a given function.
https://github.com/beenotung/benchmark.ts
Last synced: 8 months ago
JSON representation
Measure the time needed to execute a given function.
- Host: GitHub
- URL: https://github.com/beenotung/benchmark.ts
- Owner: beenotung
- License: bsd-2-clause
- Created: 2020-11-07T05:05:14.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2021-03-04T05:45:03.000Z (over 4 years ago)
- Last Synced: 2025-02-01T12:18:32.304Z (8 months ago)
- Language: TypeScript
- Homepage:
- Size: 12.7 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# benchmark.ts
Measure the time needed to execute a given function.
[](https://www.npmjs.com/package/benchmark.ts)
Similar to jsperf.com but doesn't need to be hosted.
### Remark
For async functions (e.g. with disk/network I/O), use `estimateAsync()`.For sync functions, e.g. (CPU intensive calculations), use `estimateSync()`
## Example
*The cost of OOP*: [source](./test/fp-vs-oop.ts)
| Approach | Time to iterate 1m times | ops/second |
| :------: | ---------: | ------ |
| FP | 662.61 ms | 1510 k |
| OOP | 5604.00 ms | 180 k |More examples:
- [FP vs OOP](./test/fp-vs-oop.ts)
- [callback vs promise](./test/callback-vs-promise.ts)
- [loop over collection](./test/loop-over-collections.ts)## License
[BSD 2-Clause License](./BSD-2-Clause)