0.0.0 • Published 7 years ago
tape-benchmark v0.0.0
tape-benchmark
Benchmarking functions for tape
// 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
into tape
asserts. So there is no setup between the two, and you get the same logging with both.
Installation
$ npm install --save tape-benchmark
Usage
load(tape)
Load benchmark assertions onto tape
// 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.
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
0.0.0
7 years ago