0.3.1 • Published 4 months ago
@twada/benchmark-commits v0.3.1
benchmark-commits
Run benchmark on specified git commits.
INSTALL
$ npm install @twada/benchmark-commits
SPEC
runBenchmark(commitsOrSpecs, register): run benchmark for given commitsOrSpecs
. Each benchmark function is registered via register
function
- if all benchmark executions have finished (at least one benchmark was successful), output benchmark result then resolve with benchmark suite
if all benchmark executions have failed, reject with Error
commitsOrSpecs
is an array of either (1) string specifying git tag/branch/commit or (2) object havingname
andgit
properties, pointing to git object to be checked out for the benchmark- internally, each item in
commitsOrSpecs
is normalized tospec
object in {name, git} form- if
commitsOrSpecs
is an array of string specifying git tag/branch/commit- converts each string to {name, git} form. name === git in this case.
- use git object name as benchmark name
- if
commitsOrSpecs
is already an array ofspec
object having {name, git} form- use them as
spec
object - generated benchmark name is
name(git)
- use them as
- if
- internally, each item in
register
is a benchmark registration function that returns benchmark function. benchmark registration function takes { suite, spec, dir} as arguments.- if
register
function runs synchronously, register benchmark function immediately - if
register
function is an async function or returns Promise, register benchmark function asynchronously - benchmark function (a function returned from
register
function) with no parameters will be executed synchronously - if benchmark function takes one parameter, it means that the benchmark function is intended to run asynchronously, so register it as deferred function
- if benchmark function takes more than one parameter, skip benchmark registration for that
spec
since benchmark function is invalid - if git commit object in
commitsOrSpecs
does not exist in underlying git repository, skip benchmark registration for thatspec
- if error occurred while executing registration function, skip benchmark registration for that
spec
- if async registration function rejects, skip benchmark registration for that
spec
- if benchmark registration function does not return function, skip benchmark registration for that
spec
- if all benchmark registrations have skipped, rejects with Error
- if
AUTHOR
LICENSE
Licensed under the MIT license.