github.com/koko1123/flow-go-1@v0.29.6/.github/workflows/bench.yml (about)

     1  name: Benchstat
     2  on:
     3    pull_request:
     4      branches:
     5        - master
     6        - "auto-cadence-upgrade/**"
     7        - "feature/**"
     8        - "v[0-9]+.[0-9]+"
     9      paths:
    10        - ".github/workflows/bench.yml"
    11        - "fvm/**"
    12        - "engine/execution/**"
    13        - "go.sum"
    14  
    15  concurrency: 
    16    group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.run_id }}
    17    cancel-in-progress: true
    18  
    19  jobs:
    20    benchstat:
    21      name: Performance regression check
    22      runs-on: ubuntu-latest
    23      continue-on-error: true
    24      steps:
    25        - name: Set benchmark repetitions
    26          # reducing repetition will speed up execution,
    27          # but will be more inaccurate at detecting change
    28          run: echo "::set-output name=benchmark_repetitions::7"
    29          id: settings
    30  
    31        - name: Checkout
    32          uses: actions/checkout@v3
    33          with:
    34            fetch-depth: 0
    35  
    36        - name: Setup go
    37          uses: actions/setup-go@v3
    38          with:
    39            go-version: "1.19"
    40            cache: true
    41  
    42        - name: Build relic
    43          run: make crypto_setup_gopath
    44  
    45        - name: Run benchmark on current branch
    46          run: |
    47            (for i in {1..${{ steps.settings.outputs.benchmark_repetitions }}}; do go test ./fvm ./engine/execution/computation --bench . --tags relic -shuffle=on --benchmem --run ^$; done) | tee new.txt
    48  
    49        - name: Checkout base branch
    50          run: git checkout ${{ github.event.pull_request.base.sha }}
    51  
    52        - name: Run benchmark on base branch
    53          run: |
    54            (for i in {1..${{ steps.settings.outputs.benchmark_repetitions }}}; do go test ./fvm ./engine/execution/computation --bench . --tags relic -shuffle=on --benchmem --run ^$; done) | tee old.txt
    55  
    56        # see https://trstringer.com/github-actions-multiline-strings/ to see why this part is complex
    57        - name: Use benchstat for comparison
    58          run: |
    59            export PATH=$PATH:$(go env GOPATH)/bin
    60            go install golang.org/x/perf/cmd/benchstat@latest
    61            echo "BENCHSTAT<<EOF" >> $GITHUB_ENV
    62            echo "$(benchstat -html -sort delta old.txt new.txt | sed  '/<title/,/<\/style>/d' | sed 's/<!doctype html>//g')" >> $GITHUB_ENV
    63            echo "EOF" >> $GITHUB_ENV
    64  
    65        - name: Find existing comment on PR
    66          uses: peter-evans/find-comment@v1
    67          id: fc
    68          with:
    69            issue-number: ${{ github.event.pull_request.number }}
    70            comment-author: "github-actions[bot]"
    71            body-includes: "## FVM [Benchstat](https://pkg.go.dev/golang.org/x/perf/cmd/benchstat) comparison"
    72  
    73        - name: Create or update comment
    74          uses: peter-evans/create-or-update-comment@v1
    75          with:
    76            comment-id: ${{ steps.fc.outputs.comment-id }}
    77            issue-number: ${{ github.event.pull_request.number }}
    78            body: |
    79              ## FVM [Benchstat](https://pkg.go.dev/golang.org/x/perf/cmd/benchstat) comparison
    80  
    81              This branch with compared with the base branch ${{  github.event.pull_request.base.label }} commit ${{ github.event.pull_request.base.sha }}
    82  
    83              The command `(for i in {1..${{ steps.settings.outputs.benchmark_repetitions }}}; do go test ./fvm ./engine/execution/computation --bench . --tags relic -shuffle=on --benchmem --run ^$; done)` was used.
    84  
    85              <details>
    86              <summary>Collapsed results for better readability</summary>
    87              <p>
    88  
    89              ${{ env.BENCHSTAT }}
    90              
    91              </p>
    92              </details>  
    93              
    94            edit-mode: replace