Code Monkey home page Code Monkey logo

github-action-benchmark's Introduction

GitHub Action for Continuous Benchmarking

Action Marketplace Build Status codecov

This repository provides a 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 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:

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 examples/rust
Go Go Example Workflow examples/go
JavaScript JavaScript Example Workflow examples/benchmarkjs
Python pytest-benchmark Example Workflow examples/pytest
C++ C++ Example Workflow examples/cpp
C++ (Catch2) C++ Catch2 Example Workflow examples/catch2
Julia Julia Example examples/julia
.Net C# Benchmark.Net Example Workflow examples/benchmarkdotnet
Java Java Example Workflow 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:

[
    {
        "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

page screenshot

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.

tooltip

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

download button

Alert comment on commit page

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

alert comment

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.

name: Minimal setup
on:
  push:
    branches:
      - master

jobs:
  benchmark:
    name: Performance regression check
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-go@v4
        with:
          go-version: "stable"
      # Run benchmark with `go test -bench` and stores the output to a file
      - name: Run benchmark
        run: go test -bench 'BenchmarkFib' | tee output.txt
      # Download previous benchmark result from cache (if exists)
      - name: Download previous benchmark data
        uses: actions/cache@v4
        with:
          path: ./cache
          key: ${{ runner.os }}-benchmark
      # Run `github-action-benchmark` action
      - name: Store benchmark result
        uses: benchmark-action/github-action-benchmark@v1
        with:
          # What benchmark tool the output.txt came from
          tool: 'go'
          # Where the output from the benchmark tool is stored
          output-file-path: output.txt
          # Where the previous data file is stored
          external-data-json-path: ./cache/benchmark-data.json
          # Workflow will fail when an alert happens
          fail-on-alert: true
      # Upload the updated cache file for the next job by actions/cache

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.

Commit comment

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

- 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. 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. 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.

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.

- 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.

# 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.

# Do not run this workflow on pull request since this workflow has permission to modify contents.
on:
  push:
    branches:
      - master

permissions:
  # deployments permission to deploy GitHub pages website
  deployments: write
  # contents permission to update benchmark contents in gh-pages branch
  contents: write

jobs:
  benchmark:
    name: Performance regression check
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-go@v4
        with:
          go-version: "stable"
      # Run benchmark with `go test -bench` and stores the output to a file
      - name: Run benchmark
        run: go test -bench 'BenchmarkFib' | tee output.txt
      # gh-pages branch is updated and pushed automatically with extracted benchmark data
      - name: Store benchmark result
        uses: benchmark-action/github-action-benchmark@v1
        with:
          name: My Project Go Benchmark
          tool: 'go'
          output-file-path: output.txt
          # Access token to deploy GitHub Pages branch
          github-token: ${{ secrets.GITHUB_TOKEN }}
          # Push and deploy GitHub pages branch automatically
          auto-push: true

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
  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.

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.

- 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.

These examples are run in workflows of this repository as described in the 'Examples' section above.

Action inputs

Input definitions are written in action.yml.

name (Required)

  • Type: String
  • Default: "Benchmark"

Name of the benchmark. This value must be identical across all benchmarks in your repository.

tool (Required)

  • Type: String
  • Default: N/A

Tool for running benchmark. The value must be one of "cargo", "go", "benchmarkjs", "pytest", "googlecpp", "catch2", "julia", "jmh", "benchmarkdotnet","benchmarkluau", "customBiggerIsBetter", "customSmallerIsBetter".

output-file-path (Required)

  • Type: String
  • Default: N/A

Path to a file which contains the output from benchmark tool. The path can be relative to repository root.

gh-pages-branch (Required)

  • Type: String
  • Default: "gh-pages"

Name of your GitHub pages branch.

Note: If you're using docs/ directory of master branch for GitHub pages, please set gh-pages-branch to master and benchmark-data-dir-path to the directory under docs like docs/dev/bench.

gh-repository

  • Type: String

Url to an optional different repository to store benchmark results (eg. github.com/benchmark-action/github-action-benchmark-results)

NOTE: if you want to auto push to a different repository you need to use a separate Personal Access Token that has a write access to the specified repository. If you are not using the auto-push option then you can avoid passing the gh-token if your data repository is public

benchmark-data-dir-path (Required)

  • Type: String
  • Default: "dev/bench"

Path to a directory that contains benchmark files on the GitHub pages branch. For example, when this value is set to "path/to/bench", https://you.github.io/repo-name/path/to/bench will be available as benchmarks dashboard page. If it does not contain index.html, this action automatically generates it at first run. The path can be relative to repository root.

github-token (Optional)

  • Type: String
  • Default: N/A

GitHub API access token.

ref (Optional)

  • Type: String
  • Default: N/A

Ref to use for reporting the commit

auto-push (Optional)

  • Type: Boolean
  • Default: false

If it is set to true, this action automatically pushes the generated commit to GitHub Pages branch. Otherwise, you need to push it by your own. Please read 'Commit comment' section above for more details.

comment-always (Optional)

  • Type: Boolean
  • Default: false

If it is set to true, this action will leave a commit comment comparing the current benchmark with previous. github-token is necessary as well.

save-data-file (Optional)

  • Type: Boolean
  • Default: true

If it is set to false, this action will not save the current benchmark to the external data file. You can use this option to set up your action to compare the benchmarks between PR and base branch.

alert-threshold (Optional)

  • Type: String
  • Default: "200%"

Percentage value like "150%". It is a ratio indicating how worse the current benchmark result is. For example, if we now get 150 ns/iter and previously got 100 ns/iter, it gets 150% worse.

If the current benchmark result is worse than previous exceeding the threshold, an alert will happen. See comment-on-alert and fail-on-alert also.

comment-on-alert (Optional)

  • Type: Boolean
  • Default: false

If it is set to true, this action will leave a commit comment when an alert happens like this. github-token is necessary as well. For the threshold, please see alert-threshold also.

fail-on-alert (Optional)

  • Type: Boolean
  • Default: false

If it is set to true, the workflow will fail when an alert happens. For the threshold for this, please see alert-threshold and fail-threshold also.

fail-threshold (Optional)

  • Type: String
  • Default: The same value as alert-threshold

Percentage value in the same format as alert-threshold. If this value is set, the threshold value will be used to determine if the workflow should fail. Default value is set to the same value as alert-threshold input. This value must be equal or larger than alert-threshold value.

alert-comment-cc-users (Optional)

  • Type: String
  • Default: N/A

Comma-separated GitHub user names mentioned in alert commit comment like "@foo,@bar". These users will be mentioned in a commit comment when an alert happens. For configuring alerts, please see alert-threshold and comment-on-alert also.

external-data-json-path (Optional)

  • Type: String
  • Default: N/A

External JSON file which contains benchmark results until previous job run. When this value is set, this action updates the file content instead of generating a Git commit in GitHub Pages branch. This option is useful if you don't want to put benchmark results in GitHub Pages branch. Instead, you need to keep the JSON file persistently among job runs. One option is using a workflow cache with actions/cache action. Please read 'Minimal setup' section above.

max-items-in-chart (Optional)

  • Type: Number
  • Default: N/A

Max number of data points in a chart for avoiding too busy chart. This value must be unsigned integer larger than zero. If the number of benchmark results for some benchmark suite exceeds this value, the oldest one will be removed before storing the results to file. By default this value is empty which means there is no limit.

skip-fetch-gh-pages (Optional)

  • Type: Boolean
  • Default: false

If set to true, the workflow will skip fetching branch defined with the gh-pages-branch variable.

Action outputs

No action output is set by this action for the parent GitHub workflow.

Caveats

Run only on your branches

Please ensure that your benchmark workflow runs only on your branches. Please avoid running it on pull requests. If a branch were pushed to GitHub pages branch on a pull request, anyone who creates a pull request on your repository could modify your GitHub pages branch.

For this, you can specify a branch that runs your benchmark workflow on on: section. Or set the proper condition to if: section of step which pushes GitHub pages.

e.g. Runs on only master branch

on:
  push:
    branches:
      - master

e.g. Push when not running for a pull request

- name: Push benchmark result
  run: git push ...
  if: github.event_name != 'pull_request'

Stability of Virtual Environment

As far as watching the benchmark results of examples in this repository, the amplitude of the benchmarks is about +- 10~20%. If your benchmarks use some resources such as networks or file I/O, the amplitude might be bigger.

If the amplitude is not acceptable, please prepare a stable environment to run benchmarks. GitHub action supports self-hosted runners.

Customizing the benchmarks result page

This action creates the default index.html in the directory specified with benchmark-data-dir-path input. By default, every benchmark test case has own chart on the page. Charts are drawn with Chart.js.

If it does not fit your use case, please modify the HTML file or replace it with your favorite one. Every benchmark data is stored in window.BENCHMARK_DATA so you can create your favorite view.

Versioning

This action conforms semantic versioning 2.0.

For example, benchmark-action/github-action-benchmark@v1 means the latest version of 1.x.y. And benchmark-action/[email protected] always uses v1.0.2 even if a newer version is published.

master branch of this repository is for development and does not work as action.

Track updates of this action

To notice new version releases, please watch 'release only' at this repository. Every release will appear on your GitHub notifications page.

Future work

  • Support pull requests. Instead of updating GitHub pages, add a comment to the pull request to explain benchmark results.
  • Add more benchmark tools:
  • Allow uploading results to metrics services such as mackerel
  • Show extracted benchmark data in the output from this action
  • Add a table view in dashboard page to see all data points in table

Related actions

  • lighthouse-ci-action is an action for Lighthouse CI. If you're measuring performance of your web application, using Lighthouse CI and lighthouse-ci-action would be better than using this action.

License

the MIT License

github-action-benchmark's People

Contributors

allanjeremy avatar alvicsam avatar baronfel avatar bernedom avatar bnaya avatar cabauman avatar chinyikming avatar dependabot[bot] avatar dmathieu avatar epompeii avatar estebanborai avatar findmyway avatar herringtondarkholme avatar jofas avatar kaancfidan avatar ktbarrett avatar ktrz avatar matyasberry avatar michaelmior avatar miparnisari avatar mjochum avatar ningziwen avatar okuramasafumi avatar pksunkara avatar razican avatar rhysd avatar robobario avatar srz-zumix avatar vaeryn-uk avatar xsam avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

github-action-benchmark's Issues

Allow writing index.html, data.js without pushing to gh-pages

On our gh-pages branch we have a few different things, docs, other benchmarks, etc, and I want finer-grain control over how things are pushed to the branch. I think it makes sense to have an option that outputs these assets (edit: i.e. as html+js files, in a particular directory, without uploading them to git) to the user to let them do what they want with them.

How to process multiple benchmark files?

I have tried the GitHub action layout below but get the following error.

2021-06-09T15:56:24.8321073Z [command]/usr/bin/git -c user.name=github-action-benchmark -c [email protected] -c http.https://github.com/.extraheader= fetch origin gh-pages:gh-pages
2021-06-09T15:56:25.0151197Z From https://github.com/Levi-Armstrong/tesseract-1
2021-06-09T15:56:25.0152452Z  ! [rejected]          gh-pages   -> gh-pages  (non-fast-forward)
2021-06-09T15:56:25.0201890Z ##[error]Command 'git' failed with args '-c user.name=github-action-benchmark -c [email protected] -c http.https://github.com/.extraheader= fetch origin gh-pages:gh-pages': From https://github.com/Levi-Armstrong/tesseract-1
 ! [rejected]          gh-pages   -> gh-pages  (non-fast-forward)
     - name: Store Bullet Discrete Simple benchmark result
        uses: rhysd/github-action-benchmark@v1
        with:
          name: Bullet Discrete Simple C++ Benchmark
          tool: 'googlecpp'
          output-file-path: /home/runner/work/tesseract/tesseract/benchmarks/tesseract_collision_bullet_discrete_simple_benchmarks_results.json
          # Use personal access token instead of GITHUB_TOKEN due to https://github.community/t5/GitHub-Actions/Github-action-not-triggering-gh-pages-upon-push/td-p/26869/highlight/false
          github-token: ${{ secrets.GITHUB_TOKEN }} # GitHub API token to make a commit comment
          auto-push: false
          # Show alert with commit comment on detecting possible performance regression
          alert-threshold: '200%'
          comment-on-alert: true
          fail-on-alert: false
          alert-comment-cc-users: '@mpowelson'
          max-items-in-chart: 20

      - name: Store Bullet Discrete BVH benchmark result
        uses: rhysd/github-action-benchmark@v1
        with:
          name: Bullet Discrete BVH C++ Benchmark
          tool: 'googlecpp'
          output-file-path: /home/runner/work/tesseract/tesseract/benchmarks/tesseract_collision_bullet_discrete_bvh_benchmarks_results.json
          # Use personal access token instead of GITHUB_TOKEN due to https://github.community/t5/GitHub-Actions/Github-action-not-triggering-gh-pages-upon-push/td-p/26869/highlight/false
          github-token: ${{ secrets.GITHUB_TOKEN }} # GitHub API token to make a commit comment
          auto-push: false
          # Show alert with commit comment on detecting possible performance regression
          alert-threshold: '200%'
          comment-on-alert: true
          fail-on-alert: false
          alert-comment-cc-users: '@mpowelson'
          max-items-in-chart: 20

      - name: Store FCL Discrete BVH benchmark result
        uses: rhysd/github-action-benchmark@v1
        with:
          name: FCL Discrete BVH C++ Benchmark
          tool: 'googlecpp'
          output-file-path: /home/runner/work/tesseract/tesseract/benchmarks/tesseract_collision_fcl_discrete_bvh_benchmarks_results.json
          # Use personal access token instead of GITHUB_TOKEN due to https://github.community/t5/GitHub-Actions/Github-action-not-triggering-gh-pages-upon-push/td-p/26869/highlight/false
          github-token: ${{ secrets.GITHUB_TOKEN }} # GitHub API token to make a commit comment
          auto-push: false
          # Show alert with commit comment on detecting possible performance regression
          alert-threshold: '200%'
          comment-on-alert: true
          fail-on-alert: false
          alert-comment-cc-users: '@mpowelson'
          max-items-in-chart: 20

error could not read Username for 'https://github.com': No such device or address

Hello,

I'm struggling with this error:
image

It comes from this step:

      - name: Store benchmark result
        uses: rhysd/github-action-benchmark@v1
        with:
          name: Benchmark.js Benchmark
          tool: 'benchmarkjs'
          output-file-path: output.txt
          github-token: ${{ secrets.GITHUB_TOKEN }}
          auto-push: true
          alert-threshold: '200%'
          comment-always: true
          comment-on-alert: true
          fail-on-alert: true
          alert-comment-cc-users: '@mathieug'

This action is running on a private repository.

Thanks.

Ability to compare performance across python versions

Apart from comparing performance from changeset to changeset I'd also like to compare performance across python versions, ie py3.7, py3.8, pypy3.

With benchmark-data-dir-path I can definitely split to different pages for versions, but that would be several pages to compare manually 🤔

Feature Request: Generation of an image for readme.md

First and foremost, this is an excellent action. I love it!

I like that the action creates an interactive HTM. However, it would be great if the action could also generate an image. Afterward, the original repository could have in their readme.md a link to that image that is updated at each build (because the link would always point to the same image that is refreshed every benchmark).

Thank again

Enable upload of GHA Continuous Benchmark data into a different repository

Continuous Benchmarking only allows benchmark data upload into a branch of the same repository, with gh-pages being the default branch.
This can be undesirable for projects that want to keep benchmark data and the corresponding commits separate from the code development. The benchmark data should be stored into a different repository.

Please consider adding a feature: upload the benchmark data to a branch in a different repository.
For example, introduce a new parameter such as gh-pages-repo:

  • name: Store performance test result
    uses: benchmark-action/github-action-benchmark@v1
    with:
    ........
    gh-pages-branch: perf_data
    gh-pages-repo: github.com/user_repo

Settings gh-pages branch to current branch results in fatal Error: 'Refusing to fetch into current branch'

This action says in the documentation that if your docs build from your master branch you should simply set the gh-pages-branch to master to have it make a commit on that branch instead.

However, if you trigger the workflow while you are on the master branch itself, then because the action runs a git fetch <branch>:<branch> the action will fail with error:

/usr/bin/git -c user.name=github-action-benchmark -c [email protected] -c http.https://github.com/.extraheader= fetch origin master:master
fatal: Refusing to fetch into current branch refs/heads/master of non-bare repository
Error: Command 'git' failed with args '-c user.name=github-action-benchmark -c [email protected] -c http.https://github.com/.extraheader= fetch origin master:master': fatal: Refusing to fetch into current branch refs/heads/master of non-bare repository

See this workflow for an example.

Possible solutions include adding a field

should-fetch: true|false

to indicate whether the branch needs to be fetched before creating a commit.

Thank you for the awesome action!

No benchmark found

Hi, thanks for the cool action. I'm relatively new with actions, so may have made an obvious mistake. As far as I know the only major change is making the repo public and haven't changed the configuration, however now I am receiving a no benchmark found.

I was expecting there to possibly be a problem with the pages commit, but not the output itself not being found.

Error

##[error]No benchmark result was found in /home/runner/work/retry/retry/output.txt. Benchmark output was

I added a step before showing that output was in the above location.

Config

  benchmark:
    name: Run Go benchmark example
    runs-on: ubuntu-latest
    steps:

    - uses: actions/checkout@v2
    - uses: actions/setup-go@v1
      with:
        go-version: 1.13
      id: go
    - name: Run benchmark
      run: go test -bench . | tee output.txt
    - name: check benchmark output
      run: pwd && ls

    - name: Store benchmark result
      uses: rhysd/github-action-benchmark@v1
      with:
        name: Go Benchmark
        tool: 'go'
        output-file-path: output.txt
        github-token: ${{ secrets.GITHUB_TOKEN }}
        # Use personal access token instead of GITHUB_TOKEN due to https://github.community/t5/GitHub-Actions/Github-action-not-triggering-gh-pages-upon-push/td-p/26869/highlight/false
        # github-token: ${{ secrets.PERSONAL_GITHUB_TOKEN }}
        auto-push: true
        # Show alert with commit comment on detecting possible performance regression
        alert-threshold: '200%'
        comment-on-alert: true
        fail-on-alert: true
        alert-comment-cc-users: '@Brian-Williams'

Bench cmd

Locally and in actions the bench runs successfully

go test -bench .
goos: darwin
goarch: amd64
pkg: github.com/Brian-Williams/retry
BenchmarkDo1-8                          30000000                47.6 ns/op
BenchmarkDoWithConfigurer1-8            30000000                42.3 ns/op
BenchmarkDo2-8                          30000000                46.6 ns/op
BenchmarkDoWithConfigurer2-8            30000000                42.4 ns/op
BenchmarkDo10-8                         30000000                46.6 ns/op
BenchmarkDoWithConfigurer10-8           30000000                42.6 ns/op
BenchmarkDo100-8                        30000000                46.6 ns/op
BenchmarkDoWithConfigurer100-8          30000000                42.1 ns/op
BenchmarkDo10000-8                      30000000                46.6 ns/op
BenchmarkDoWithConfigurer10000-8        30000000                42.2 ns/op
PASS
ok      github.com/Brian-Williams/retry 14.448s

[rust] Fails to extract benchmark result

I assume there is a problem with the regex in https://github.com/rhysd/github-action-benchmark/blob/master/src/extract.ts#L181

My benchmark results look like this:

test core::builder::graph::tests::bench_create_mid_graph   ... bench:   4,720,415 ns/iter (+/- 498,541) 
test core::builder::graph::tests::bench_create_small_graph ... bench:      40,447 ns/iter (+/- 1,061) 

Please note the colons in the name. The regex /^test ([\w/]+)\s+\.\.\. bench:\s+([0-9,]+) ns\/iter \(\+\/- ([0-9,]+)\)$/; doesn't consider the colons. The fix is probably easy: [\w/:]

Difficulty with initial fetch

I'm having trouble getting started with this action. I created a gh-pages branch on a public repo, but I have an error at the start:

Run rhysd/github-action-benchmark@v1
  with:
    tool: go
    output-file-path: output.txt
    github-token: ***
    auto-push: true
    name: Benchmark
    gh-pages-branch: gh-pages
    benchmark-data-dir-path: dev/bench
    skip-fetch-gh-pages: false
    comment-always: false
    save-data-file: true
    comment-on-alert: false
    alert-threshold: 200%
    fail-on-alert: false
##[debug]Config extracted from job: [object Object]
##[debug]Benchmark result was extracted: [object Object]
##[debug]Executing Git: fetch origin gh-pages:gh-pages
/usr/bin/git -c user.name=github-action-benchmark -c [email protected] -c http.https://github.com/.extraheader= fetch origin gh-pages:gh-pages
fatal: not a git repository (or any of the parent directories): .git
##[debug]@actions/exec.exec() threw an error: Command 'git' failed with args '-c user.name=github-action-benchmark -c [email protected] -c http.https://github.com/.extraheader= fetch origin gh-pages:gh-pages': fatal: not a git repository (or any of the parent directories): .git
##[debug]: Error: The process '/usr/bin/git' failed with exit code 128

Error: No benchmark found for bench suite. Possibly mangled output from Catch2:

I'm about to set up continuous benchmarking for our project. We benchmark C++ code in a combined R/C++ project with catch2 in a docker container.

When I try to deploy the benchmark results, I get an error that I struggle to approach:

Error: No benchmark found for bench suite. Possibly mangled output from Catch2:

The benchmark results look fine, however:

Run leoholz/github-action-benchmark@v1
  with:
    name: Spectre Benchmark
    tool: catch2
    output-file-path: benchmark_result.txt
    github-token: ***
    auto-push: true
    alert-threshold: 150%
    comment-on-alert: true
    fail-on-alert: false
    alert-comment-cc-users: @bitbacchus
    gh-pages-branch: gh-pages
    benchmark-data-dir-path: dev/bench
    skip-fetch-gh-pages: false
    comment-always: false
    save-data-file: true
/usr/bin/docker exec  a9f0ac018dd04072460f5c72e60419a21237b5e40c9c55dd861053ffe2aeba52 sh -c "cat /etc/*release | grep ^ID"
Error: No benchmark found for bench suite. Possibly mangled output from Catch2:


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
benchmark is a Catch v2.13.4 host application.
Run with -? for options

-------------------------------------------------------------------------------
MinConf benchmarks
-------------------------------------------------------------------------------
../../tests/benchmark/benchmark-minconf.cpp:6
...............................................................................

benchmark name                       samples       iterations    estimated
                                     mean          low mean      high mean
                                     std dev       low std dev   high std dev
-------------------------------------------------------------------------------
MinConf optimize 3 sites, 3                                                    
species, <<5k iterations                       100             1    146.934 ms 
                                        1.42295 ms    1.42224 ms    1.42373 ms 
                                        3.80964 us    3.33283 us    4.54339 us 
                                                                               
MinConf optimize 100 sites, 139                                                
species, 5 iterations                          100             1     22.8952 s 
                                        227.471 ms    227.076 ms    227.933 ms 
                                        2.18339 ms    1.78353 ms     3.1476 ms 
                                                                               
Calculate commonness for a 100x100                                             
solution                                       100             1     35.275 ms 
                                         353.03 us     352.65 us     353.71 us 
                                        2.52869 us    1.67274 us    3.89837 us 
                                                                               

===============================================================================
test cases: 1 | 1 passed
assertions: - none -

Do you have an idea or suggestions?

Ruby support

Is Ruby support for Github action benchmarking in progress? Or would it be preferable for us to follow these instructions and make a PR?

Genericize support for other tools

In addition to runtime performance benchmark work, one thing our project would be interested in is examining how our codebase measures across time for binary size and memory consumption metrics.

It would expand the notion of the tool parameter here to become a source of any type of metric values rather than just the output from a pre-configured performance benchmark tool. Much of github-action-benchmark's behavior -- collecting historical data, creating a dashboard, publishing -- would be just as beneficial for these other types of benchmark metrics.

So specifically, could there be an extra option for tool, maybe called other, and then have the JSON format/schema expected by the GH Action documented for this other scenario, and thereby allow more flexible uses of the action?

I could still the benefit of commonly-used benchmark tools being supported out-of-the-box (example: #43), so this proposal is in addition to that, not intended as a replacement for that.

Catch2 error

I'm getting a Separator '------' does not appear after benchmark suite at line 48 when running this action for my project. The only notable difference is can see between my setup and the one in the Catch2 example is that i'm running on windows (example runs on ubuntu).
It also looks like Powershell/tee is adding an extra blank line at the bottom of my benchmark.txt file and the footer of the benchmark output is slightly different but from looking at extract.ts it doesnt look like this should be affecting things.

Config

name: Windows Build

on:
  push:
    branches:
      - master

jobs:
  benchmark:
    runs-on: windows-latest
    steps:
    - uses: actions/checkout@v2
    - name: Install Dependencies
      run: vcpkg install catch2:x64-windows eigen3:x64-windows
    - name: Configure
      run: |
        mkdir build
        cd build
        cmake .. -G "Visual Studio 16 2019" -A x64 -DCMAKE_TOOLCHAIN_FILE=C:/vcpkg/scripts/buildsystems/vcpkg.cmake
    - name: Build & run benchmarks
      run: |
        cd build
        cmake --build . --config Release --target bench
        ./bench/Release/bench.exe | tee ../benchmark_result.txt
    # Download previous benchmark results (if they exist)
    - name: Download previous benchmark data
      uses: actions/cache@v1
      with:
        path: ./cache
        key: ${{ runner.os }}-benchmark
    - name: Store benchmark result
      uses: rhysd/github-action-benchmark@v1
      with:
        name: Catch2 Benchmark
        tool: "catch2"
        output-file-path: benchmark_result.txt
        external-data-json-path: ./cache/benchmark-data.json
        # Use personal access token instead of GITHUB_TOKEN due to https://github.community/t5/GitHub-Actions/Github-action-not-triggering-gh-pages-upon-push/td-p/26869/highlight/false
        github-token: ${{ secrets.GITHUB_TOKEN }}
        # Show alert with commit comment on detecting possible performance regression
        comment-on-alert: true
        fail-on-alert: true
        alert-comment-cc-users: "@bjude"

Catch2 Output (contents of benchmark.txt)


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
bench.exe is a Catch v2.11.1 host application.
Run with -? for options

-------------------------------------------------------------------------------
MGPCG
-------------------------------------------------------------------------------
..\bench\mgpcg.cpp(11)
...............................................................................

benchmark name                                  samples       iterations    estimated
                                                mean          low mean      high mean
                                                std dev       low std dev   high std dev
-------------------------------------------------------------------------------
CG                                                        100             1     15.8709 s 
                                                   168.954 ms    163.738 ms    174.699 ms 
                                                   27.9626 ms    24.2926 ms     35.131 ms 
                                                                                          
CG1                                                       100             1     13.1955 s 
                                                   136.535 ms     134.96 ms    138.295 ms 
                                                   8.46148 ms    7.44195 ms    9.79179 ms 
                                                                                          

-------------------------------------------------------------------------------
Jacobi - Vertex
-------------------------------------------------------------------------------
..\bench\smoothing.cpp(10)
...............................................................................

benchmark name                                  samples       iterations    estimated
                                                mean          low mean      high mean
                                                std dev       low std dev   high std dev
-------------------------------------------------------------------------------
Jacobi X                                                  100             1    519.126 ms 
                                                   4.95134 ms    4.90756 ms    5.00182 ms 
                                                   238.909 us    205.329 us    281.946 us 
                                                                                          
Jacobi X1                                                 100             1    524.493 ms 
                                                    5.0776 ms    5.02235 ms    5.13908 ms 
                                                   296.858 us    259.413 us    356.647 us 
                                                                                          

===============================================================================
All tests passed (202 assertions in 2 test cases)


Crossing boundry between units in a single graph

Hey @rhysd , great work on this.
Is anything supposed to happen if some data crosses the boundry between say nanoseconds and microseconds?

In my benchmark here that has happened in the bottom two:
https://jasonwilliams.github.io/boa/dev/bench/

It looks like its become a lot slower, but actually it sped up from 1 us to 900 ns.
Unfortunately once the chart is made with a unit im guessing its fixed.

think i answered my own question
https://github.com/rhysd/github-action-benchmark/blob/master/src/default_index_html.ts#L198

Call for maintainers

As you may see, this repository has been unmaintained for more than one year. I'm no longer having motivation to maintain it because GitHub Actions does not provide an environment which is enough to measure benchmarks. When I developed this action, I noticed that the result was not stable even if the benchmark itself was stable. After some investigation, I noticed that there were some variations of CPUs. At the moment, sometimes it was Xeon Platinum 8272CL and at other times it was Xeon E5-2673 v3. My conclusion was that we needed to prepare a stable environment by ourselves with self-hosted runner. However, I don't have a machine resource for it and I want to avoid maintaining a self-hosted runner in terms of security.

With this issue, I want to call for maintainers of this project. If someone raises their hands, I'll make a new organization dedicated for this project, move the repository to it, and hand over all to them. Development can be continued there.

If no one appears after two weeks, I'll archive this project. Someone can continue development by forking this project.

Workflow fails on cron jobs

I'm getting failures when my workflow is triggered by a cron job. I get the following error

No commit information is found in payload: {
  "schedule": "0 5 * * *"
}

Is this to be expected? Looking at this code if appears that it assumes the job is being triggered by a pull request. Should it instead get it from the GITHUB_SHA environment variable?

Deploy to GitHub pages fails after updating actions/checkout to v2

After starting to use actions/checkout@v2, deploying gh-pages branch got to fail. Note that git push to the branch did not fail. So this action successfully finished and could not detect the failure. It means that gh-pages branch is updated but GitHub Pages website is not updated. Note that actions/checkout@v1 works without using a personal access token.

The deploy failure can be found in 'Settings -> GitHub Pages' section. 'Your site is having problems building: Page build failed.' message is shown when this issue occurs.

screenshot of warning

I am unable to push the pages.

fatal: could not read Username for 'https://github.com': No such device or address
##[error]Command 'git' failed with args '-c user.name=github-action-benchmark -c user.email=[email protected] -c http.https://github.com/.extraheader= fetch origin gh-pages:gh-pages': fatal: could not read Username for 'https://github.com': No such device or address

My workflow file:

 - name: Store benchmark result
      uses: rhysd/github-action-benchmark@v1
      with:
        name: Go Benchmark ${{ matrix.benchfile }}
        tool: 'go'
        output-file-path: output.txt
        # Use personal access token instead of GITHUB_TOKEN due to
        # https://github.community/t5/GitHub-Actions/Github-action-not-triggering-gh-pages-upon-push/td-p/26869/highlight/false
        github-token: ${{ secrets.GH_PERSON_TOKEN }}
        auto-push: true
        # Show alert with commit comment on detecting possible performance regression
        alert-threshold: '200%'
        fail-on-alert: true

Prefer XML format for getting results from Catch2 output

Catch2 supports multiple reporters including XML reporter (the default value is console reporter). XML reporter is preferable because it is more sold and easy to parse. Console output for human may be cosmetically changed for readability.

$ ./Catch2_bench --reporter xml | tee output.xml

I want to add support for the XML format and encourage to use it rather than console output. Console output support for Catch2 will continue to be supported since it was already released (To change this v2 release is necessary). Parsing logic can be changed by checking first line is <?xml or not though it is a bit hacky.

Output example of the XML format:

<?xml version="1.0" encoding="UTF-8"?>
<Catch name="Catch2_bench">
  <Group name="Catch2_bench">
    <TestCase name="Fibonacci" filename="/Users/rhysd/Develop/github.com/rhysd/github-action-benchmark/examples/catch2/catch2_bench.cpp" line="5">
      <BenchmarkResults name="Fibonacci 20" samples="100" resamples="100000" iterations="3" clockResolution="51" estimatedDuration="7343400">
        <!--All values in nano seconds-->
        <mean value="25557" lowerBound="24811" upperBound="26583" ci="0.95"/>
        <standardDeviation value="4429.86" lowerBound="3523.19" upperBound="5922.86" ci="0.95"/>
        <outliers variance="0.925502" lowMild="0" lowSevere="0" highMild="9" highSevere="3"/>
      </BenchmarkResults>
      <BenchmarkResults name="Fibonacci 25" samples="100" resamples="100000" iterations="1" clockResolution="51" estimatedDuration="26482200">
        <!--All values in nano seconds-->
        <mean value="282440" lowerBound="271724" upperBound="299021" ci="0.95"/>
        <standardDeviation value="66920.6" lowerBound="47609.9" upperBound="87251.2" ci="0.95"/>
        <outliers variance="0.957435" lowMild="0" lowSevere="0" highMild="0" highSevere="9"/>
      </BenchmarkResults>
      <OverallResult success="true"/>
    </TestCase>
    <OverallResults successes="0" failures="0" expectedFailures="0"/>
  </Group>
  <OverallResults successes="0" failures="0" expectedFailures="0"/>
</Catch>

xml2js seems suitable to parse XML easily.

Github Eviction Policy

I have a question regarding the retention of the benchmark result.

As far as I understood the code correctly then benchmark results are stored in ./cache/benchmark-data.json and then loaded from the github cache on the next run. I think this is a tricky idea.

But a github cache is only kept for 7 days when it is not touched anymore (see here).

So benchmark result are gone when the benchmark is not executed within these 7 days?

Concerns about reiability of GA

We've been observing large fluctuation in benchmark results on essentially empty commits. It's apparently because GitHub Actions runs benches on different machines (come to think of it, it's sensible) with different load score.

It doesn't look like GA should be used for benchmarking to me.

[Rust] Will this work with Criterion?

A lot of rust projects use Criterion which overrides cargo bench, that may output something different, would this project work with that?

What does the output need to look like?

For e.g im using
https://github.com/jasonwilliams/criterion-compare-action
which is a wrapper around https://github.com/bheisler/criterion.rs

This is the output from criterion on https://github.com/jasonwilliams/boa:

Create Realm            time:   [389.43 us 391.46 us 393.64 us]
                        change: [+2.9053% +3.3116% +3.7569%] (p = 0.00 < 0.05)
                        Performance has regressed.
Found 6 outliers among 100 measurements (6.00%)
  4 (4.00%) high mild
  2 (2.00%) high severe

Symbol Creation         time:   [476.63 us 478.43 us 480.62 us]
                        change: [-8.0982% -7.3473% -6.5933%] (p = 0.00 < 0.05)
                        Performance has improved.
Found 5 outliers among 100 measurements (5.00%)
  2 (2.00%) high mild
  3 (3.00%) high severe

     Running target\release\deps\fib-b7cfe35d42f9c87b.exe
Benchmarking fibonacci (Execution): Warming up for 3.0000 s
Warning: Unable to complete 100 samples in 5.0s. You may wish to increase target time to 21.1s or reduce sample count to 30
fibonacci (Execution)   time:   [4.0417 ms 4.0513 ms 4.0612 ms]
                        change: [-3.1531% -2.4175% -1.7071%] (p = 0.00 < 0.05)
                        Performance has improved.
Found 5 outliers among 100 measurements (5.00%)
  2 (2.00%) high mild
  3 (3.00%) high severe

     Running target\release\deps\parser-ab35171b3898e94f.exe
Expression (Parser)     time:   [15.656 us 15.673 us 15.693 us]
                        change: [-0.7893% -0.5205% -0.2658%] (p = 0.00 < 0.05)
                        Change within noise threshold.

     Running target\release\deps\string-bdac66e3ac549711.exe
Hello World (Execution) time:   [391.07 us 394.24 us 397.40 us]
                        change: [-3.0040% -2.2291% -1.5351%] (p = 0.00 < 0.05)
                        Performance has improved.
Found 13 outliers among 100 measurements (13.00%)
  1 (1.00%) high mild
  12 (12.00%) high severe

Hello World (Lexer)     time:   [1.9896 us 1.9961 us 2.0032 us]
                        change: [-3.2960% -2.6175% -2.0389%] (p = 0.00 < 0.05)
                        Performance has improved.
Found 3 outliers among 100 measurements (3.00%)
  1 (1.00%) low mild
  1 (1.00%) high mild
  1 (1.00%) high severe

Hello World (Parser)    time:   [3.8064 us 3.8102 us 3.8141 us]
                        change: [-1.0105% -0.2551% +0.3856%] (p = 0.49 > 0.05)
                        No change in performance detected.
Found 8 outliers among 100 measurements (8.00%)
  4 (4.00%) low severe
  1 (1.00%) low mild
  1 (1.00%) high mild
  2 (2.00%) high severe

https://bheisler.github.io/criterion.rs/book/user_guide/command_line_output.html

Fork opitmised for pytest-benchmark (upstream improvements?)

Hey, thanks for the great package! There was a number of additional data aspects I wanted to capture/utilise from pytest-benchmark (in particular test grouping) and so I created a fork optimised for this: https://github.com/aiidateam/github-action-benchmark, and you can see an example output here: https://aiidateam.github.io/aiida-core/dev/bench/ubuntu-18.04/django/

Now that I've just about finalised my implementation, I thought it would be good to feedback, since I sure at least some of this can be upstreamed to here 😄

I've outlined the changes in the README (and also the commit history is pretty readable), but I'll copy it here:

  1. More metadata is saved about the benchmark run, for later comparison:

    • CPU data (cores, processors, speed) is specifically saved, per commit, in the cpu key (uses systeminformation npm package).
    • The python version is extracted from the pytest-benchmark data in an extra key
    • A metadata action option is available to save additional data
    • This data is all shown in the data point's tooltip
  2. The group name is saved for each test (see pytest-benchmark markers), or null if no group is given.
    In the web-page rendering, tests are then arranged by the group they are in, which can be given a sub-heading, description, etc, and also a group can be "consolidated" into a single chart (with handling of differing data points).

  3. A new render-json-path allows for a JSON file to be copied, which is used to configure the rendered web-page, e.g. for certain test suites and groups:

     {
         "suites": {
             "name": {
                 "header": "Test Suite Title",
                 "description": "Description of test suite."
             }
         },
         "groups": {
             "group1": {
                 "header": "Group 1 Title",
                 "description": "Description of group 1.",
                 "single_chart": true,
                 "xAxis": "date",
                 "backgroundFill": false
             }
         }
     }
  4. Split original index.html into multiple HTML/JS files in the src/assets folder. This allows for easier testing and development of the output web-page.
    This has additionally allowed for:

    • Adding npm run serve, for local development of output web-page (using light-server)
    • Adding overwrite-assets option, to specify whether any existing assets should be overridden during a commit to gh-pages.
  5. Improve formatting of charts:

    • Color cycling for consolidated charts
    • For legend, extract common test name prefix as title
    • Data point tooltips: rounding values to 5 significant figures and better formatting of dates etc.
    • Addition of the chartjs-plugin-zoom and a "Reset Zoom" button.
  6. Add commit-msg-append option , useful for adding e.g. [ci skip] to commit message, but not having it as part of the test suite key in the data JSON.

  7. Removed capture of commit author/committer, since it can be obtained from the commit id/url, and just bloats the data JSON.

  8. Renamed max-items-in-chart -> max-data-items, to better describe its function of truncating the saved data during a commit.

Private repos fail

I have a test repo that passes fine on public repos, but fails on private ones. Any help?

/usr/bin/git -c user.name=github-action-benchmark -c [email protected] -c http.https://github.com/.extraheader= fetch origin gh-pages:gh-pages
fatal: could not read Username for 'https://github.com': No such device or address
##[error]Command 'git' failed with args '-c user.name=github-action-benchmark -c [email protected] -c http.https://github.com/.extraheader= fetch origin gh-pages:gh-pages': fatal: could not read Username for 'https://github.com': No such device or address
: Error: The process '/usr/bin/git' failed with exit code 128

Alert when performance is improved

Note this is a feature request.

When configuring the action, it would be nice to have the ability specify an option that shows an alert if the performance is improved by the defined threshold.

Also, thanks for this action—it's great!

Saving the benchmark outputs to a different repository

Hello,

First of all, thank you for making this cool action.

I can see that it possible to upload a benchmark output to a gh-pages branch on a repository. I do not have access to github pages, but I was wondering if it is possible to upload the benchmark output to a second repository instead?

Cheers

R interface?

Hi @rhysd my student @LooDaHu wants to try to get https://github.com/analyticalmonk/Rperform working with your software, but the docs say that user-defined tools are not yet supported. can you help explain how to get started?

Also can you explain how the authentication works? (how do we grant access for pushing benchmark data to gh-pages branch?)

Thanks

Allow choice of benchmark stat used for `pytest`

pytest-benchmark automatically computes a fairly comprehensive set of stats across multiple runs of each benchmark, including minimum, mean, median, etc. runtime, and Operations Per Second (calculated as the inverse of the mean runtime).

It's commonly recommended that benchmark comparisons use the minimum runtime, as it is more stable than other statistics. However, the actions are currently hardcoded to use the ops statistic.

Is it possible to make this configurable?

(This request may apply more widely than pytest, but I'm not familiar with the other output formats that are handled)

Question: Does this action support alerts on pull requests?

I've successfully configured this action and everything is running very nicely on the main branch. I'm keen to also run this action on pull requests and receive alerts when there are benchmark regressions.

I updated my action config to run on PRs, however, it fails as follows:

0s
Run rhysd/github-action-benchmark@v1
  with:
    tool: benchmarkjs
    output-file-path: benchmark/output.txt
    comment-on-alert: true
    alert-comment-cc-users: @colineberhardt
    auto-push: true
    name: Benchmark
    gh-pages-branch: gh-pages
    benchmark-data-dir-path: dev/bench
    skip-fetch-gh-pages: false
    comment-always: false
    save-data-file: true
    alert-threshold: 200%
    fail-on-alert: false
Error: 'auto-push' is enabled but 'github-token' is not set. Please give API token to push GitHub pages branch to remote

/see ColinEberhardt/assemblyscript-regex#21

Any ideas?

[bug]it doesn't work with output of table driven benchmarks in go

the output is

goos: darwin
goarch: amd64
pkg: github.com/0chain/gosdk/zboxcore/sdk
cpu: Intel(R) Core(TM) i5-1038NG7 CPU @ 2.00GHz
BenchmarkChunkedUploadFormBuilder/10M_64K-8         	      39	 312026046 ns/op	264405427 B/op	 1799151 allocs/op
BenchmarkChunkedUploadFormBuilder/10M_6M-8          	     318	  38583357 ns/op	35552045 B/op	   30195 allocs/op
BenchmarkChunkedUploadFormBuilder/10M_64K_NoHash-8  	      37	 305542242 ns/op	264406763 B/op	 1799159 allocs/op
BenchmarkChunkedUploadFormBuilder/10M_6M__NoHash-8  	     315	  39228720 ns/op	35551235 B/op	   30194 allocs/op
BenchmarkChunkedUploadFormBuilder/100M_64K-8        	       4	3097868954 ns/op	2665191370 B/op	18111513 allocs/op
BenchmarkChunkedUploadFormBuilder/100M_6M-8         	      32	 371133831 ns/op	343483354 B/op	  216628 allocs/op
BenchmarkChunkedUploadFormBuilder/100M_64K_NoHash-8 	       4	2947383724 ns/op	2665200902 B/op	18111571 allocs/op
BenchmarkChunkedUploadFormBuilder/100M_6M__NoHash-8 	      31	 349546589 ns/op	343483543 B/op	  216629 allocs/op
BenchmarkChunkedUploadFormBuilder/500M_64K-8        	       1	15473948734 ns/op	13335867688 B/op	90618221 allocs/op
BenchmarkChunkedUploadFormBuilder/500M_6M-8         	       6	1757071474 ns/op	1700784817 B/op	  977624 allocs/op
BenchmarkChunkedUploadFormBuilder/500M_64K_NoHash-8 	       1	14786519545 ns/op	13335866840 B/op	90618212 allocs/op
BenchmarkChunkedUploadFormBuilder/500M_6M__NoHash-8 	       6	1775155434 ns/op	1700785812 B/op	  977628 allocs/op
BenchmarkChunkedUploadFormBuilder/1G_64K-8          	       1	31321023689 ns/op	27328158144 B/op	185675100 allocs/op
BenchmarkChunkedUploadFormBuilder/1G_60M-8

https://github.com/rhysd/github-action-benchmark/blob/a1914d7dcbe14d006e4b5f12c7ff303a82a411f1/src/extract.ts#L211
const reExtract = /^(Benchmark\w+)(-\d+)?\s+(\d+)\s+([0-9.]+)\s+(.+)$/; does not work

BUG: Should trim test names from both ends.

The new commit turns normal test names into names ending with a string of spaces because of this regex change:

const reExtract = /^test (.+)\s+\.\.\. bench:\s+([0-9,]+) ns\/iter \(\+\/- ([0-9,]+)\)$/;

Although this is done to allow spaces in test names, whitespaces wrapping the name should be stripped (the number of spaces will follow the longest test name since the ... markers are all justified).

For example, my cargo bench report has this:

test bench_engine_new          ... bench:     211,834 ns/iter (+/- 70,126)
test bench_engine_new_raw      ... bench:         197 ns/iter (+/- 18)
test bench_engine_new_raw_core ... bench:         196 ns/iter (+/- 31)
test bench_engine_register_fn  ... bench:         493 ns/iter (+/- 82)

Now test names are turned into "ench_engine_new ", "bench_engine_new_raw ", "bench_engine_new_raw_core", "bench_engine_register_fn ".

That's because regex is greedy and (.+) will match spaces up to the last one, leaving the last one only for \s+.

Obviously this also breaks compatibility with all previous reports due to names ending with strings of spaces.

Feature Request: Auto-updated PR comment

This is a great action! ❤️ When I push many commits to a PR, I would not like to receive a separate comment for every PR but instead a single, always-update comment on the PR page ... Would this be possible? :-)

Benchmark not found (Criterion)

Hi there, I have experienced an issue similar to that of #5 but in Criterion rather than in Go. In particular, in my repo, I have a criterion bench that runs with the following output (using --output-format bencher).

Gnuplot not found, using plotters backend
test inv_prod/default/8 ... bench:         139 ns/iter (+/- 6)
test inv_prod/prod_of_inv/8 ... bench:          87 ns/iter (+/- 4)
test inv_prod/default/16 ... bench:         223 ns/iter (+/- 15)
test inv_prod/prod_of_inv/16 ... bench:         110 ns/iter (+/- 7)
test inv_prod/default/32 ... bench:         301 ns/iter (+/- 20)
test inv_prod/prod_of_inv/32 ... bench:         163 ns/iter (+/- 8)
test inv_prod/default/64 ... bench:         454 ns/iter (+/- 25)
test inv_prod/prod_of_inv/64 ... bench:         257 ns/iter (+/- 9)
test inv_prod/default/128 ... bench:         744 ns/iter (+/- 44)
test inv_prod/prod_of_inv/128 ... bench:         441 ns/iter (+/- 19)
test inv_prod/default/256 ... bench:        1489 ns/iter (+/- 83)
test inv_prod/prod_of_inv/256 ... bench:         908 ns/iter (+/- 41)
test inv_prod/default/512 ... bench:        2613 ns/iter (+/- 153)
test inv_prod/prod_of_inv/512 ... bench:        1841 ns/iter (+/- 114)

I have the following workflow:

name: Benchmark
on: ["push", "pull_request"]

jobs:
  benchmark:
    name: Performance regression check
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      # Install Rust (stable)
      - uses: actions-rs/toolchain@v1
        with:
          profile: minimal
          toolchain: stable
          override: true

      # Run benchmark, storing in output.txt
      - name: Run benchmark
        run: cargo bench -- --output-format bencher | tee output.txt
      # Get old benches (if any)
      - name: Download previous benchmark data
        uses: actions/cache@v1
        with:
          path: ./cache
          key: ${{ runner.os }}-benchmark
      - name: Store benchmark result
        uses: rhysd/[email protected]
        with:
          tool: 'cargo'
          output-file-path: output.txt
          external-data-json-path: ./cache/benchmark-data.json
          fail-on-alert: true

And it fails with No benchmark result was found in /home/runner/work/stabchain/stabchain/output.txt. Benchmark output was 'Gnuplot not found, using plotters backend ...

I have confirmed before that the output is correctly written and that the action is able to read it, so the issue is probably with the parsing.

From looking at the source, it seems like this error can be thrown only in this line. In particular it should only be thrown when there are no benches in the file.

Now, what is really confusing me is that I ran the code in extractCargoResult on the bench output here, and it seems to be parsing it correctly.

Any ideas on what is going wrong? At the moment my best guess is some sort of version error but I might be horribly wrong.

No need to use a personal access token anymore for Github Pages

As discussed in the recent comments in this page: https://github.community/t5/GitHub-Actions/Github-action-not-triggering-gh-pages-upon-push/td-p/26869, it is not needed anymore to use a personal access token to push to Github Pages, and the standard GitHub Token works.
I also tested it and indeed this seems to work.

I suggest, therefore, to simplify the README removing the need of setting up a personal access token.

BTW, thanks for the great work on this action!

Custom type with combined bigger/smaller is better

In addition to customBiggerIsBetter and customSmallerIsBetter it would be nice to just have a simple custom type where the JSON output would include "better": "bigger" or "better": "smaller" so that a single benchmark could make use of both. For example, I might want to measure both memory use (smaller is better) and throughput (bigger is better) for a single benchmark. While I could potentially save the results to a file and split them apart into two separate benchmark outputs, it would be simpler if this was not necessary.

EDIT: Having a quick look at the current code structure, I can see this probably isn't easy to do but it still would be nice :)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.