https://github.com/gregl83/quick-bench
JavaScript Quick Benchmark Tool
https://github.com/gregl83/quick-bench
benchmark javascript nodejs
Last synced: about 2 months ago
JSON representation
JavaScript Quick Benchmark Tool
- Host: GitHub
- URL: https://github.com/gregl83/quick-bench
- Owner: gregl83
- Created: 2015-05-03T04:10:45.000Z (about 11 years ago)
- Default Branch: master
- Last Pushed: 2021-01-06T21:16:43.000Z (over 5 years ago)
- Last Synced: 2026-03-03T12:32:36.815Z (3 months ago)
- Topics: benchmark, javascript, nodejs
- Language: JavaScript
- Size: 7.81 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
[](https://travis-ci.org/gregl83/quick-bench)
[](https://coveralls.io/r/gregl83/quick-bench?branch=master)
# quick-bench
JavaScript Quick Benchmark Tool
## Requirements
- NodeJS v5.11.x or higher
- NPM
See `./package.json`
## Installation
Source available on [GitHub](https://github.com/gregl83/quick-bench) or install module via NPM:
$ npm install quick-bench
## Usage
After requiring quick-benchmark create a new instance. Call the start method, log some events, then call the end method and finally
the results method to obtain quick benchmarks for JavaScript code.
```js
var Benchmark = require('quick-bench')
var benchmark = new Benchmark()
benchmark.start() // time is recorded in ms
// todo some application code
benchmark.event('eventLabelOne')
benchmark.event('eventLabelOne') // events should occur many times to get useful benchmarks
// todo some more application code
benchmark.event('eventLabelTwo') // n number of events can be logged
// todo perhaps some more code
var results = benchmark.results() // automatically calls benchmark.end()
```
The above will set the `results` variable equal to an object with the following format:
```js
{
elapsedTime: milliseconds,
events: {
eventLabelOne: {
total: 2,
perSecond: total / (elapsedTime / 1000)
},
eventLabelTwo: {
total: 1,
perSecond: total / (elapsedTime / 1000)
},
}
}
```
That's it! As the module name implies this package is designed for quick benchmarks.
## License
[MIT](LICENSE)