Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
G

github-action-benchmark

> DevOps
Open source

GitHub Action for continuous benchmarking to keep performance

1.2K stars0 likes0 views
WebsiteGitHub

About

GitHub Action for continuous benchmarking to keep performance

GitHub Action for Continuous Benchmarking

[![Action Marketplace][release-badge]][marketplace] [![Build Status][build-badge]][ci] [![codecov][codecov-badge]][codecov]

[This repository][proj] provides a [GitHub Action][github-action] for continuous benchmarking. If your project has some benchmark suites, this action collects data from the benchmark outputs and monitor the results on GitHub Actions workflow.

  • This action can store collected benchmark results in [GitHub pages][gh-pages] branch and provide a chart view. Benchmark results are visualized on the GitHub pages of your project.
  • This action can detect possible performance regressions by comparing benchmark results. When benchmark results get worse than previous exceeding the specified threshold, it can raise an alert via commit comment or workflow failure.

This action currently supports the following tools:

  • [cargo bench][cargo-bench] for Rust projects
  • go test -bench for Go projects
  • [benchmark.js][benchmarkjs] for JavaScript/TypeScript projects
  • [pytest-benchmark][] for Python projects with [pytest][]
  • [Google Benchmark Framework][google-benchmark] for C++ projects
  • [Catch2][catch2] for C++ projects
  • [BenchmarkTools.jl][] for Julia packages
  • [Benchmark.Net][benchmarkdotnet] for .Net projects
  • benchmarkluau for Luau projects
  • [JMH][jmh] for Java projects
  • Custom benchmarks where either 'biggerIsBetter' or 'smallerIsBetter'

Multiple languages in the same repository are supported for polyglot projects.

Japanese Blog post

Examples

Example projects for each language are in examples/ directory. Live example workflow definitions are in .github/workflows/ directory. Live workflows are:

Language Workflow Example Project
Rust [![Rust Example Workflow][rust-badge]][rust-workflow-example] examples/rust
Go [![Go Example Workflow][go-badge]][go-workflow-example] examples/go
JavaScript [![JavaScript Example Workflow][benchmarkjs-badge]][benchmarkjs-workflow-example] examples/benchmarkjs
Python [![pytest-benchmark Example Workflow][pytest-benchmark-badge]][pytest-workflow-example] examples/pytest
C++ [![C++ Example Workflow][cpp-badge]][cpp-workflow-example] examples/cpp
C++ (Catch2) [![C++ Catch2 Example Workflow][catch2-badge]][catch2-workflow-example] examples/catch2
Julia [![Julia Example][julia-badge]][julia-workflow-example] examples/julia
.Net [![C# Benchmark.Net Example Workflow][benchmarkdotnet-badge]][benchmarkdotnet-workflow-example] examples/benchmarkdotnet
Java [![Java Example Workflow][java-badge]][java-workflow-example] examples/java
Luau Coming soon Coming soon

All benchmark charts from above workflows are gathered in GitHub pages:

https://benchmark-action.github.io/github-action-benchmark/dev/bench/

Additionally, even though there is no explicit example for them, you can use customBiggerIsBetter and customSmallerIsBetter to use this action and create your own graphs from your own benchmark data. The name in these tools define which direction "is better" for your benchmarks.

Every entry in the JSON file you provide only needs to provide name, unit, and value. You can also provide optional range (results' variance) and extra (any additional information that might be useful to your benchmark's context) properties. Like this:

json
[
    {
        "name": "My Custom Smaller Is Better Benchmark - CPU Load",
        "unit": "Percent",
        "value": 50
    },
    {
        "name": "My Custom Smaller Is Better Benchmark - Memory Used",
        "unit": "Megabytes",
        "value": 100,
        "range": "3",
        "extra": "Value for Tooltip: 25\nOptional Num #2: 100\nAnything Else!"
    }
]

Screenshots

Charts on GitHub Pages

Mouseover on data point shows a tooltip. It includes

  • Commit hash
  • Commit message
  • Date and committer
  • Benchmark value

Clicking data point in chart opens the commit page on a GitHub repository.

At bottom of the page, the download button is available for downloading benchmark results as a JSON file.

Alert comment on commit page

This action can raise [an alert comment][alert-comment-example]. to the commit when its benchmark results are worse than previous exceeding a specified threshold.

Why?

Since performance is important. Writing benchmarks is a popular and correct way to visualize a software performance. Benchmarks help us to keep performance and to confirm the effects of optimizations. For keeping the performance, it's important to monitor the benchmark results along with changes to the software. To notice performance regression quickly, it's useful to monitor benchmarking results continuously.

However, there is no good free tool to watch the performance easily and continuously across languages (as far as I looked into). So I built a new tool on top of GitHub Actions.

How to use

This action takes a file that contains benchmark output. And it outputs the results to GitHub Pages branch and/or alert commit comment.

Minimal setup

Let's start with a minimal workflow setup. For explanation, here let's say we have a Go project. But basic setup is the same when you use other languages. For language-specific setup, please read the later section.

…

The step which runs github-action-benchmark does followings:

  1. Extract benchmark result from the output in output.txt
  2. Update the downloaded cache file with the extracted result
  3. Compare the result with the previous result. If it gets worse than previous exceeding 200% threshold, the workflow fails and the failure is notified to you

By default, this action marks the result as performance regression when it is worse than the previous exceeding 200% threshold. For example, if the previous benchmark result was 100 iter/ns and this time it is 230 iter/ns, it means 230% worse than the previous and an alert will happen. The threshold can be changed by alert-threshold input.

A live workflow example is here. And the results of the workflow can be seen [here][minimal-workflow-example].

Commit comment

In addition to the above setup, GitHub API token needs to be given to enable comment-on-alert feature.

yaml
- name: Store benchmark result
  uses: benchmark-action/github-action-benchmark@v1
  with:
    tool: 'go'
    output-file-path: output.txt
    external-data-json-path: ./cache/benchmark-data.json
    fail-on-alert: true
    # GitHub API token to make a commit comment
    github-token: ${{ secrets.GITHUB_TOKEN }}
    # Enable alert commit comment
    comment-on-alert: true
    # Mention @rhysd in the commit comment
    alert-comment-cc-users: '@rhysd'

secrets.GITHUB_TOKEN is [a GitHub API token automatically generated for each workflow run][help-github-token]. It is necessary to send a commit comment when the benchmark result of the commit is detected as possible performance regression.

Now, in addition to making workflow fail, the step leaves a commit comment when it detects performance regression [like this][alert-comment-example]. Though alert-comment-cc-users input is not mandatory for this, I recommend to set it to make sure you can notice the comment via GitHub notification. Please note that this value must be quoted like '@rhysd' because @ is an indicator in YAML syntax.

A live workflow example is here. And the results of the workflow can be seen [here][commit-comment-workflow-example].

Job Summary

Similar to the Commit comment feature, Github Actions Job Summaries are also supported. In order to use Job Summaries, turn on the summary-always option.

yaml
- name: Store benchmark result
  uses: benchmark-action/github-action-benchmark@v1
  with:
    tool: 'cargo'
    output-file-path: output.txt
    external-data-json-path: ./cache/benchmark-data.json
    fail-on-alert: true
    # GitHub API token to make a commit comment
    github-token: ${{ secrets.GITHUB_TOKEN }}
    # Enable alert commit comment
    comment-on-alert: true
    # Enable Job Summary for PRs
    summary-always: true
    # Mention @rhysd in the commit comment
    alert-comment-cc-users: '@rhysd'

Charts on GitHub Pages

It is useful to see how the benchmark results changed on each change in time-series charts. This action provides a chart dashboard on GitHub pages.

It requires some preparations before the workflow setup.

You need to create a branch for GitHub Pages if you haven't created it yet.

bash
# Create a local branch
$ git checkout --orphan gh-pages
# Push it to create a remote branch
$ git push origin gh-pages:gh-pages

Now you're ready for workflow setup.

…

The step which runs github-action-benchmark does followings:

  1. Extract benchmark result from the output in output.txt
  2. Switch branch to gh-pages (when gh-repository is set, the action instead shallow-clones only the gh-pages branch of that repository)
  3. Read existing benchmark results from dev/bench/data.js
  4. Update dev/bench/data.js with the extracted benchmark result
  5. Generate a commit to store the update in gh-pages branch
  6. Push gh-pages branch to remote
  7. Compare the results with previous results and make an alert if possible performance regression is detected

After the first workflow run, you will get the first result on https://you.github.io/repo/dev/bench [like this][examples-page].

By default, this action assumes that gh-pages is your GitHub Pages branch and that /dev/bench is a path to put the benchmark dashboard page. If they don't fit your use case, please tweak them by gh-pages-branch, gh-repository and benchmark-data-dir-path inputs.

This action merges all benchmark results into one GitHub pages branch. If your workflows have multiple steps to check benchmarks from multiple tools, please give name input to each step to make each benchmark results identical.

Please see the above 'Examples' section to see live workflow examples for each language.

If you don't want to pass GitHub API token to this action, it's still OK.

yaml
- name: Store benchmark result
  uses: benchmark-action/github-action-benchmark@v1
  with:
    name: My Project Go Benchmark
    tool: 'go'
    output-file-path: output.txt
    # Set auto-push to false since GitHub API token is not given
    auto-push: false
# Push gh-pages branch by yourself
- name: Push benchmark result
  run: git push 'https://you:${{ secrets.GITHUB_TOKEN }}@github.com/you/repo-name.git' gh-pages:gh-pages

Please add a step to push the branch to the remote.

Tool specific setup

Please read README.md files at each example directory. Usually, take stdout from a benchmark tool and store it to file. Then specify the file path to output-file-path input.

  • cargo bench for Rust projects
  • [

Issues· 0 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

TypeScriptbenchmarkcigithub-action

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 17, 2026
CategoryDevOps
PricingOpen source

> Related tools

D
Docker
容器化平台,标准化应用交付
G
GitHub Actions
GitHub 原生 CI/CD 工作流
N
Nginx
高性能 Web 服务器与反向代理