https://github.com/yashladha/node-microbenchmark
Micro benchmarking library for Node.JS 🚀
https://github.com/yashladha/node-microbenchmark
benchmarking microbenchmark node
Last synced: about 2 months ago
JSON representation
Micro benchmarking library for Node.JS 🚀
- Host: GitHub
- URL: https://github.com/yashladha/node-microbenchmark
- Owner: yashLadha
- License: mit
- Created: 2020-04-29T17:31:26.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2022-01-18T05:11:51.000Z (over 3 years ago)
- Last Synced: 2025-04-12T18:12:13.617Z (about 2 months ago)
- Topics: benchmarking, microbenchmark, node
- Language: JavaScript
- Homepage:
- Size: 86.9 KB
- Stars: 6
- Watchers: 1
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
## node-microbenchmark
[](https://badge.fury.io/js/node-microbenchmark)
A micro benchmarking library inspired from [google-benchmark](https://github.com/google/benchmark)
Features available:
* Benchmarking synchronous functions
* Benchmarking of asynchronous functions
* Support for Promises
* High precision benchmark (upto nanoseconds precision)### Benchmarking of synchronous functions
```javascript
const { benchmark, show } = require('node-microbenchmark');const slowFn = () => {
for (var i = 0; i < 1e4; ++i);
}const fastFn = () => {}
benchmark(slowFn);
benchmark(fastFn);show();
```### Benchmarking of asynchronous functions
```javascript
const benchmark = require('../index');const slowTimer = () => new Promise(res => setTimeout(res, 200));
const fastTimer = () => new Promise(res => setTimeout(res, 50));const fn = async () => {
await benchmark.benchmarkPromise(slowTimer);
await benchmark.benchmarkPromise(fastTimer);
benchmark.show();
};fn();
```
## Future enhancements
* Benchmark async code like promises.
## Author
* [yashLadha](https://github.com/yashLadha)