Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mcollina/fastbench
the simplest benchmark you can run on node
https://github.com/mcollina/fastbench
Last synced: 13 days ago
JSON representation
the simplest benchmark you can run on node
- Host: GitHub
- URL: https://github.com/mcollina/fastbench
- Owner: mcollina
- License: mit
- Created: 2015-07-08T17:33:26.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2021-09-13T00:19:01.000Z (over 3 years ago)
- Last Synced: 2024-12-17T15:42:16.197Z (23 days ago)
- Language: JavaScript
- Size: 6.84 KB
- Stars: 87
- Watchers: 4
- Forks: 7
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# fastbench [![Build Status](https://travis-ci.org/mcollina/fastbench.png)](https://travis-ci.org/mcollina/fastbench)
The simplest benchmark you can run on node
## Install
```js
npm install fastbench
```## Usage
```js
'use strict'var bench = require('fastbench')
var run = bench([
function benchSetTimeout (done) {
setTimeout(done, 0)
},
function benchSetImmediate (done) {
setImmediate(done)
},
function benchNextTick (done) {
process.nextTick(done)
}
], 1000)// run them two times
run(run)
```Output:
```
benchSetTimeout*1000: 1363ms
benchSetImmediate*1000: 4ms
benchNextTick*1000: 1ms
benchSetTimeout*1000: 1365ms
benchSetImmediate*1000: 4ms
benchNextTick*1000: 0ms
```You can disable colors by passing a `--no-color` flag to your node
script.## API
### bench(functions, iterations)
Build a benchmark for the given functions and that precise number of
iterations. It returns a function to run the benchmark.The iterations parameter can also be an `Object`, in which case it
acceps two options:* `iterations`: the number of iterations (required)
* `max`: is a an alias for iterations
* `color`: if the output should have color (default: true)## License
MIT