1.0.0 • Published 4 years ago

@tangany/perf-diff v1.0.0

Weekly downloads
-
License
ISC
Repository
github
Last release
4 years ago

perf-diff

perf-diff compares the runtimes of mocha tests for different branches of a repository (e.g. for comparison after performance improvements).

For this purpose, the respective branches are cloned and stored in a temporary folder. Based on this, the tests are executed, their runtimes collected and then formatted and output as a comparison.

sample_output

Requirements

It is assumed that all tests are successfully passed in each branch. Otherwise no valid output and no comparison is possible.

In order to compare and prepare the results of the tests, the results must be output as JSON. Mocha provides the option --reporter="json" for this.

The easiest way to do this is to define an npm script in the package.json file of each branch that runs mocha and specifies this reporter. Then the (for all branches identical) name can be passed as parameter. For example:

perf-diff -r git@github.com:Tangany/btcctl_rtxi.git -b master -b feature/abc -s "test:json-out"

An example for the corresponding package.json file would be:

...
"scripts": {
    "test:json-out": "npm run build && mocha src/rtxi.spec.js --reporter='json'"
},
...

Another possibility is to overwrite the mocha parameters of an existing npm test script. See https://mochajs.org/#-opts-path

Otherwise, the CLI can also be manually passed the path of the test file (usually something like *.spec.js). Internally, a mocha command is then assembled and executed. If required, a configured command can also be executed before the actual test is performed. For example:

perf-diff -r git-repo-url -b master -b branch-to-compare -f a.spec.js -p "npm run build"

Parameters

The number of branches is variable, but must be at least 2. Branches are specified with -b name, where the first mentioned branch is used as the reference value (for example, the master branch).

An overview of all parameters can be displayed using perf-diff -h.

arguments

1.0.0

4 years ago