{"name":"benchr","version":"2.2.0","description":"Benchmark runner","bin":{"benchr":"./bin/benchr"},"author":{"name":"Robert Klep","email":"robert@klep.name"},"license":"MIT","repository":{"type":"git","url":"git+https://github.com/robertklep/node-benchr.git"},"dependencies":{"benchmark":"^2.1.0","chalk":"^1.1.3","docopt":"^0.6.2","easy-table":"^1.0.0","microtime":"^2.1.1"},"gitHead":"d8cdcbb27c33c7de62e6d3714d70db45a3b4e5a1","bugs":{"url":"https://github.com/robertklep/node-benchr/issues"},"homepage":"https://github.com/robertklep/node-benchr#readme","_id":"benchr@2.2.0","scripts":{},"_shasum":"c514f418f97eb01d9f5cce6c0293012f128e4cb4","_from":".","_npmVersion":"2.15.1","_nodeVersion":"4.4.3","_npmUser":{"name":"robertklep","email":"robert.klep@gmail.com"},"maintainers":[{"name":"robertklep","email":"robert.klep@gmail.com"}],"dist":{"shasum":"c514f418f97eb01d9f5cce6c0293012f128e4cb4","tarball":"http://registry-npm.ywwl.com/benchr/download/benchr-2.2.0.tgz","integrity":"sha512-FIyluxv0Ay1TSh81Y/yxVIkcoFAp3gOAvk/fa8I4RWtWyJSXw8FHVIVTjs3c8HZ6plh1X+N4IVVYvapNrBhEJA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIAanzCCbsjF1vkSxSPTHZTJf+Q2TnIz85/CWfy073tKHAiAPLRt8k+EsSGxJGVwSYYCtmET5T1pErvho/KNpG962xw=="}],"size":4153,"noattachment":false,"key":"/benchr/-/benchr-2.2.0.tgz"},"_npmOperationalInternal":{"host":"packages-12-west.internal.npmjs.com","tmp":"tmp/benchr-2.2.0.tgz_1466063647951_0.9571532900445163"},"directories":{},"readme":"## benchr\n\nNode.js benchmark runner, modelled after [`Mocha`](http://mochajs.org/) and [`bencha`](https://www.npmjs.com/package/bencha), based on [Benchmark.js](http://benchmarkjs.com/).\n\n### Installation\n\n```\n$ npm i benchr [-g]\n```\n\n### Usage\n\nRun the `benchr` script and provide it with files containing benchmarks:\n\n```\n$ benchr benchmarks/**/*.js\n$ benchr benchmarks/suite1.js benchmarks/suite2.js benchmarks/suite3.js\n```\n\n### Options\n\n```\n$ benchr -h\nbenchr – benchmark runner\n\nUsage:\n  benchr [options] <file>...\n\nOptions:\n  -h --help                  Show this screen\n  -V --version               Show version\n  -d --delay=<s>             Delay between test cycles, in seconds       [default: 0]\n  -M --min-time=<s>          Minimum run time per test cycle, in seconds [default: 0]\n  -m --max-time=<s>          Maximum run time per test cycle, in seconds [default: 5]\n  -g --grep=<s>              Only run suites matching pattern\n  -R --reporter=<name/file>  Reporter to use, either a file path or built-in (`console` or `json`) [default: console]\n  -r --require=<module>      `require()` a module before starting (for instance, `babel-register`)\n  -p --progress              Show progress       (depending on reporter)\n  -P --pretty-print          Pretty-print output (depending on reporter)\n  -v --verbose               More verbose output (depending on reporter)\n```\n\n### Suites + benchmarks\n\nA benchmark file declares one or more suites, each with one or more benchmarks to run.\n\n#### Syntax\n\n```javascript\nsuite(NAME[, OPTIONS], FN);\nbenchmark(NAME[, OPTIONS], FN);\n```\n\nCalling `suite()` is optional.\n\n#### Synchronous benchmarks\n\n```javascript\nsuite('Finding a substring', () => {\n\n  benchmark('RegExp#test', () => {\n    /o/.test('Hello World!');\n  });\n\n  benchmark('String#indexOf', () => {\n    'Hello World!'.indexOf('o') > -1;\n  });\n\n  benchmark('String#match', () => {\n    !!'Hello World!'.match(/o/);\n  });\n\n});\n```\n\n(taken from the example on the [Benchmark.js](http://benchmarkjs.com/) website)\n\n#### Asynchronous benchmarks\n\n##### Using promises\n\nReturn a promise from a benchmark function and it will be tested asynchronously:\n\n```javascript\nsuite('Timeouts', () => {\n\n  benchmark('100ms', () => {\n    return new Promise((resolve) => {\n      setTimeout(resolve, 100);\n    });\n  });\n\n  benchmark('200ms', () => {\n    return new Promise((resolve) => {\n      setTimeout(resolve, 200);\n    });\n  });\n\n});\n```\n\n**NOTE**: to determine if a function under test returns a promise, it is called once before the tests start. If this is undesirable, for instance due to side-effects, set the `promises` option for the benchmark or the entire suite:\n\n```javascript\nsuite('Timeouts',  { promises : true }, () => { ... });\nbenchmark('100ms', { promises : true }, () => { ... });\n```\n\n##### Using callbacks\n\nIf a benchmark takes an argument, it is assumed to be a continuation callback (pass any errors as first argument to abort the test):\n\n```javascript\nsuite('Timeouts', () => {\n\n  benchmark('100ms', (done) => {\n    setTimeout(done, 100);\n  });\n\n  benchmark('200ms', (done) => {\n    setTimeout(done, 200);\n  });\n\n});\n```\n\n#### Playing nice with linters\n\nTo work around linter errors regarding `suite` and `benchmark` being undefined, your test files can export a function that would take `suite` and `benchmark` as its arguments, thereby making the linter happy:\n\n```javascript\nmodule.exports = (suite, benchmark) => {\n  suite('My test suite', () => {\n    benchmark('Bench 1', ...);\n    benchmark('Bench 2', ...);\n    ...\n  })\n}\n```\n\n### Using the Runner programmatically\n\n```\nconst Runner = require('benchr');\nconst runner = new Runner({\n    reporter    : Function,\n    grep        : String,\n    delay       : Number,\n    minTime     : Number,\n    maxTime     : Number,\n    progress    : Boolean,\n    prettyPrint : Boolean,\n    verbose     : Boolean,\n}, [ \"file1.js\", \"file2.js\", ... ]);\n```\n\nAll options map to the similarly-named command line options.\n\n### Implementing a reporter\n\nA reporter is a CommonJS module that should export a function that gets passed a benchmark runner instance as argument.\n\nThis runner instance implements the `EventEmitter` interface, and will emit the following events:\n\n* `run.start` / `run.complete`\n* `file.start` / `file.complete`\n* `suite.start` / `suite.complete`\n* `benchmark.start` / `benchmark.complete`\n\nThe different parts are explained as follows:\n* a _\"run\"_ consists of one or more files containing benchmarks\n* a _\"file\"_ is a file that exports or contains one or more suites\n* a _\"suite\"_ is a structure that consists of one or more benchmarks (where each benchmark is used in a comparison between the other benchmarks in the same suite)\n* a _\"benchmark\"_ is a single test\n\n### TODO\n\n- [x] Option to pass custom reported module\n- [x] Before/after hooks\n- [x] Benchmark/suite options (minTime, maxTime, ...)\n- [x] Separate reporters (very hardcoded now)\n- [x] Handle multiple \"fastest\" benchmarks better\n- [x] Promises support (just like Mocha)\n","publish_time":1466063650577,"_cnpm_publish_time":1466063650577,"dist-tags":{"latest":"4.3.0"}}