Skip to content
This repository has been archived by the owner on Oct 31, 2024. It is now read-only.

Latest commit

 

History

History

benchmarkjs

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 

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.