https://github.com/paulmillr/micro-bmark
Benchmark your node.js projects with nanosecond resolution.
https://github.com/paulmillr/micro-bmark
bechmark bench nanosecond node nodejs resolution
Last synced: 22 days ago
JSON representation
Benchmark your node.js projects with nanosecond resolution.
- Host: GitHub
- URL: https://github.com/paulmillr/micro-bmark
- Owner: paulmillr
- License: mit
- Created: 2020-03-29T12:18:28.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2023-02-14T22:23:44.000Z (about 2 years ago)
- Last Synced: 2024-05-08T17:03:04.816Z (12 months ago)
- Topics: bechmark, bench, nanosecond, node, nodejs, resolution
- Language: JavaScript
- Homepage: https://paulmillr.com
- Size: 33.2 KB
- Stars: 27
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Funding: .github/funding.yml
- License: LICENSE
Awesome Lists containing this project
README
# micro-bmark
Benchmark your JS projects with nanosecond resolution.
- Utilizes `process.hrtime` for 1ns resolution
- Colorful formatting with nice units
- No dependencies, only ~150 lines of code: as lightweight as possible to not interfere with benchmarked code
- No code for estimating running time - specify samples manually
- Shows relative margin of error, min/max runs **only if it's high**
## Usage
npm install --save-dev micro-bmark
```js
import bench from 'micro-bmark';
(async () => {
await bench('printing', () => Promise.resolve(0));
await bench('base', () => Promise.resolve(1));
await bench('sqrt', 10000, () => Math.sqrt(2));
})();
```Example output:
```
getPublicKey() x 6,072 ops/sec @ 164μs/op ± 8.22% (min: 143μs, max: 17ms)
sign x 4,980 ops/sec @ 200μs/op
signSync x 4,671 ops/sec @ 214μs/op
verify x 969 ops/sec @ 1ms/op
recoverPublicKey x 890 ops/sec @ 1ms/op
getSharedSecret aka ecdh x 585 ops/sec @ 1ms/op
```## License
MIT License
Copyright (c) 2020 Paul Miller (https://paulmillr.com), (c) 2010-2016 Mathias Bynens, John-David Dalton, (c) Robert Kieffer from JSLitmus.js