Skip to content

Latest commit

 

History

History
62 lines (44 loc) · 1.71 KB

File metadata and controls

62 lines (44 loc) · 1.71 KB

JavaScript example for benchmarking with benchmark.js

This directory shows how to use github-action-benchmark with benchmark.js.

Run benchmarks

Official documentation for usage of benchmark.js:

https://benchmarkjs.com/

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

Process benchmark results

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.