JavaScript example for benchmarking with benchmark.js
This directory shows how to use github-action-benchmark
with benchmark.js.
Official documentation for usage of benchmark.js:
Prepare script bench.js
as follows:
e.g.
const Benchmark = require('benchmark');
const suite = new Benchmark.Suite();
suite
.add('some test case', () => {
// ...
})
.on('cycle', event => {
// Output benchmark result by converting benchmark result to string
console.log(String(event.target));
})
.run();
Ensure the output includes string values converted from benchmark results. This action extracts measured values fron the output.
Run the script in workflow:
e.g.
- name: Run benchmark
run: node bench.js | tee output.txt
Store the benchmark results with step using the action. Please set benchmarkjs
to tool
input.
- name: Store benchmark result
uses: benchmark-action/github-action-benchmark@v1
with:
tool: 'benchmarkjs'
output-file-path: output.txt
Please read 'How to use' section for common usage.