Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
74 changes: 74 additions & 0 deletions .github/workflows/benchmark.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
name: Benchmark

on:
push:
branches:
- main
pull_request:
branches:
- main

permissions:
contents: read

# Ensure scripts are run with pipefail. See:
# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#exit-codes-and-error-action-preference
defaults:
run:
shell: bash

jobs:
benchmark:
runs-on: ubuntu-latest
# runs-on:
# - 'self-hosted'
# - '1ES.Pool=TypeScript-1ES-GitHub-Large'
# - '1ES.ImageOverride=mariner-2.0'

steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
submodules: true
filter: blob:none # https://github.blog/2020-12-21-get-up-to-speed-with-partial-clone-and-shallow-clone/
fetch-depth: 0 # Default is 1; need to set to 0 to get the benefits of blob:none.
- uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0
- uses: actions/setup-go@41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed # v5.1.0
with:
go-version: '>=1.23.0'

- run: npm ci

- name: Run benchmark
run: go test -run='^$' -bench=. -benchmem -count=10 ./... | tee new.txt

- name: Switch to parent commit
run: git switch --detach HEAD^1

- run: npm ci

- run: git submodule update --init --recursive

- name: Run benchmark
run: go test -run='^$' -bench=. -benchmem -count=10 ./... | tee old.txt

- run: go install golang.org/x/perf/cmd/benchstat@latest

- name: Compare benchmarks
run: benchstat old.txt new.txt | tee benchstat.txt

- uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3
with:
name: benchmarks
path: |
old.txt
new.txt
benchstat.txt

- name: Create step summary
run: |
echo "See $GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID for more info."
echo "# Benchmark Results" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
cat benchstat.txt >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY