UNPKG

5.46 kBMarkdownView Raw
1# benchmarked [![NPM version](https://img.shields.io/npm/v/benchmarked.svg?style=flat)](https://www.npmjs.com/package/benchmarked) [![NPM monthly downloads](https://img.shields.io/npm/dm/benchmarked.svg?style=flat)](https://npmjs.org/package/benchmarked) [![NPM total downloads](https://img.shields.io/npm/dt/benchmarked.svg?style=flat)](https://npmjs.org/package/benchmarked) [![Linux Build Status](https://img.shields.io/travis/jonschlinkert/benchmarked.svg?style=flat&label=Travis)](https://travis-ci.org/jonschlinkert/benchmarked)
2
3> Easily generate benchmarks from a glob of files.
4
5Follow this project's author, [Jon Schlinkert](https://github.com/jonschlinkert), for updates on this project and others.
6
7## Install
8
9Install with [npm](https://www.npmjs.com/):
10
11```sh
12$ npm install --save benchmarked
13```
14
15This is an opinionated wrapper for [benchmarked.js](http://benchmarkjs.com/) to make it easier to do benchmarks using glob patterns. Concept is from [remarkable](https://github.com/jonschlinkert/remarkable/tree/master/benchmark)
16
17## Usage
18
19```js
20const Suite = require('benchmarked');
21const suite = new Suite({
22 cwd: 'benchmark', // optionally define a base directory for code and fixtures
23 fixtures: 'my-fixtures/*.txt', // path or glob pattern to fixtures
24 code: 'my-functions/*.js', // path or glob pattern to code files
25 format: function(benchmark) {
26 // optionally override default formatting.
27 // return a string.
28 // see examples/basic.js for a real example.
29 }
30});
31
32// run the benchmarks
33suite.run();
34```
35
36See the [examples](./example) to get a better understanding of how this works.
37
38## API
39
40### [Benchmarked](index.js#L41)
41
42Create an instance of Benchmarked with the given `options`.
43
44**Params**
45
46* `options` **{Object}**
47
48**Example**
49
50```js
51const suite = new Suite();
52```
53
54### [.addFixtures](index.js#L265)
55
56Add fixtures to run benchmarks against.
57
58**Params**
59
60* `patterns` **{String|Array}**: Filepaths or glob patterns.
61* `options` **{Options}**
62
63**Example**
64
65```js
66benchmarks.addFixtures('fixtures/*.txt');
67```
68
69### [.addCode](index.js#L281)
70
71Specify the functions to be benchmarked.
72
73**Params**
74
75* `patterns` **{String|Array}**: Filepath(s) or glob patterns.
76* `options` **{Options}**
77
78**Example**
79
80```js
81benchmarks.addCode('fixtures/*.txt');
82```
83
84### [.addSuite](index.js#L293)
85
86Add benchmark suite to the given `fixture` file.
87
88**Params**
89
90* `fixture` **{Object}**: vinyl file object
91
92### [.run](index.js#L369)
93
94Run the benchmarks.
95
96**Params**
97
98* `options` **{Object}**
99* `cb` **{Function}**
100* `thisArg` **{Object}**
101
102**Example**
103
104```js
105benchmarks.run();
106```
107
108## About
109
110### Related projects
111
112You might also be interested in these projects:
113
114* [base-cli](https://www.npmjs.com/package/base-cli): Plugin for base-methods that maps built-in methods to CLI args (also supports methods from a… [more](https://github.com/node-base/base-cli) | [homepage](https://github.com/node-base/base-cli "Plugin for base-methods that maps built-in methods to CLI args (also supports methods from a few plugins, like 'base-store', 'base-options' and 'base-data'.")
115* [base-option](https://www.npmjs.com/package/base-option): Adds a few options methods to base, like `option`, `enable` and `disable`. See the readme… [more](https://github.com/node-base/base-option) | [homepage](https://github.com/node-base/base-option "Adds a few options methods to base, like `option`, `enable` and `disable`. See the readme for the full API.")
116* [base-pkg](https://www.npmjs.com/package/base-pkg): Plugin for adding a `pkg` method that exposes pkg-store to your base application. | [homepage](https://github.com/node-base/base-pkg "Plugin for adding a `pkg` method that exposes pkg-store to your base application.")
117* [base](https://www.npmjs.com/package/base): Framework for rapidly creating high quality node.js applications, using plugins like building blocks | [homepage](https://github.com/node-base/base "Framework for rapidly creating high quality node.js applications, using plugins like building blocks")
118
119### Contributing
120
121Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](../../issues/new).
122
123### Contributors
124
125| **Commits** | **Contributor** |
126| --- | --- |
127| 41 | [jonschlinkert](https://github.com/jonschlinkert) |
128| 7 | [elidoran](https://github.com/elidoran) |
129| 2 | [jamescostian](https://github.com/jamescostian) |
130| 1 | [leesei](https://github.com/leesei) |
131
132### Building docs
133
134_(This project's readme.md is generated by [verb](https://github.com/verbose/verb-generate-readme), please don't edit the readme directly. Any changes to the readme must be made in the [.verb.md](.verb.md) readme template.)_
135
136To generate the readme, run the following command:
137
138```sh
139$ npm install -g verbose/verb#dev verb-generate-readme && verb
140```
141
142### Running tests
143
144Running and reviewing unit tests is a great way to get familiarized with a library and its API. You can install dependencies and run tests with the following command:
145
146```sh
147$ npm install && npm test
148```
149
150### Author
151
152**Jon Schlinkert**
153
154* [github/jonschlinkert](https://github.com/jonschlinkert)
155* [twitter/jonschlinkert](https://twitter.com/jonschlinkert)
156
157### License
158
159Copyright © 2017, [Jon Schlinkert](https://github.com/jonschlinkert).
160Released under the [MIT License](LICENSE).
161
162***
163
164_This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.6.0, on September 11, 2017._
\No newline at end of file