Skip to content
activity

GitHub Action

Continuous Benchmarking for Go

v0.4.1 Latest version
Use latest version
activity

Continuous Benchmarking for Go

Runs your Go benchmarks and publishes the results to a JSON file in your gh-pages branch

Installation

Copy and paste the following snippet into your .yml file.

- name: Continuous Benchmarking for Go
  uses: bobheadxi/gobenchdata@v0.4.1
Learn more about this action in bobheadxi/gobenchdata
Choose a version

gobenchdata

Build Status View Action GoDoc Demo

a tool for inspecting go test -bench data, and a GitHub Action for continuous benchmarking.

example

About

gobenchdata was inspired by the deno.land continuous benchmarks, which aims to display performance improvements/regressions on a continuous basis.

It is available as a GitHub action or a command-line application.

GitHub Action

gobenchdata can be used as GitHub Action for uploading Go benchmark data as JSON to gh-pages and visualizing it with a generated web app (using gobenchdata-web) or your own web application.

Setup

For example, in .github/workflows/push.yml, using the new YAML syntax for workflows:

name: Benchmark
on:
  push:
    branches: [ master ]

jobs:
  benchmark:
    runs-on: ubuntu-latest
    steps:
    - name: checkout
      uses: actions/checkout@v1
      with:
        fetch-depth: 1
    - name: gobenchdata to gh-pages
      uses: bobheadxi/gobenchdata@v0.3.0
      with:
        PRUNE_COUNT: 30
        GO_TEST_FLAGS: -cpu 1,2
      env:
        GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Learn more about GitHub Actions in the official documentation.

Configuration

inputs

Input variables are configured using jobs.<job_id>.steps.with.

Variable Default Purpose
SUBDIRECTORY . subdirectory of project to run commands from
GO_BENCHMARKS . benchmarks to run (argument for -bench)
GO_TEST_FLAGS additional flags for go test
GO_TEST_PKGS ./... packages to test (argument for go test)
BENCHMARKS_OUT benchmarks.json destination path of benchmark data
PRUNE_COUNT 0 number of past runs to keep (0 keeps everything)
GIT_COMMIT_MESSAGE "add new benchmark run" the commit message for the benchmark update

env

Environment variables are configured using jobs.<job_id>.steps.env.

Variable Recommended Purpose
GITHUB_TOKEN ${{ secrets.GITHUB_TOKEN }} token to provide access to repository
GITHUB_ACTOR set by GitHub the user to make commits as

Visualisation

The gobenchdata GitHub action eventually generates a JSON file with past benchmarks. You can visualize these continuous benchmarks by creating a web app that reads from the JSON benchmarks file, or by using gobenchdata-web:

go get -u go.bobheadxi.dev/gobenchdata/x/gobenchdata-web
git checkout gh-pages
gobenchdata-web --title "my benchmarks" # generates a web app in your working directory

You test the web app locally using a tool like serve:

serve .

This feature is a work in progress. An example site published by this repository is available at gobenchdata.bobheaxi.dev.

gobenchdata CLI

gobenchdata, which the GitHub Action leverages to manage benchmark data, is also available as a CLI:

go get -u go.bobheadxi.dev/gobenchdata
gobenchdata help

Usage documentation can be found in the godocs.

Development and Contributions

Please report bugs and requests in the repository issues!

See CONTRIBUTING.md for more detailed development documentation.

You can’t perform that action at this time.