https://github.com/jamen/tape-benchmark
Benchmarking functions for tape
https://github.com/jamen/tape-benchmark
Last synced: about 1 year ago
JSON representation
Benchmarking functions for tape
- Host: GitHub
- URL: https://github.com/jamen/tape-benchmark
- Owner: jamen
- License: mit
- Created: 2017-01-27T09:32:45.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2017-01-27T09:32:55.000Z (over 9 years ago)
- Last Synced: 2025-03-09T15:19:07.993Z (over 1 year ago)
- Language: JavaScript
- Homepage:
- Size: 4.88 KB
- Stars: 2
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: LICENSE
Awesome Lists containing this project
README
# tape-benchmark
> Benchmarking functions for tape
```js
// Load tape into tape-benchmark:
var test = require('tape-benchmark')(require('tape'))
test('my-test', function (t) {
// plan and do your asserts here ...
// then create benchmark asserts:
t.benchmark('original', function () {
// ...
})
t.benchmark('variant', { minSamples: 100 }, function () {
// ...
})
})
```
This module wraps [`benchmark`](https://npmjs.com/package/benchmark) into [`tape`](https://npmjs.com/tape) asserts. So there is no setup between the two, and you get the same logging with both.
## Installation
```sh
$ npm install --save tape-benchmark
```
## Usage
### `load(tape)`
Load benchmark assertions onto tape
```js
// Load like this:
var test = require('tape-benchmark')(require('tape'))
// Or just like this:
require('tape-benchmark')(test)
```
### `t.benchmark(name, [options], fn)`
Run benchmark as an assertion. Passes with results, or fails with an error. Use `t.bench` as a shorthand.
```js
test('my-test', function (t) {
t.plan(2)
t.benchmark('original', function () {
(123).toString()
})
t.benchmark('binary', { minSamples: 100 }, function () {
(123).toString(2)
})
})
```
## License
MIT © [Jamen Marz](https://git.io/jamen)
---
[][package] [](https://travis-ci.org/tape-benchmark/jamen) [][package] [][package] [][package] [](https://www.paypal.me/jamenmarz/5usd) [](https://github.com/jamen)
[package]: https://npmjs.com/package/tape-benchmark