| 1 |
name: Benchmark |
| 2 |
on: |
| 3 |
push: |
| 4 |
branches: |
| 5 |
- main |
| 6 |
workflow_dispatch: |
| 7 |
|
| 8 |
# Declare default permissions as read only. |
| 9 |
permissions: read-all |
| 10 |
|
| 11 |
env: |
| 12 |
DEFAULT_GO_VERSION: "~1.26.0" |
| 13 |
jobs: |
| 14 |
# Related issue: https://github.com/CodSpeedHQ/codspeed-go/issues/51 |
| 15 |
sharding-benchmark: |
| 16 |
name: Sharding benchmarks |
| 17 |
runs-on: ubuntu-latest |
| 18 |
outputs: |
| 19 |
shards: ${{ steps.sharding.outputs.shards }} |
| 20 |
steps: |
| 21 |
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 |
| 22 |
- id: sharding |
| 23 |
run: | |
| 24 |
echo "shards=$(make print-sharded-benchmarks)" >> $GITHUB_OUTPUT |
| 25 |
|
| 26 |
benchmark: |
| 27 |
needs: sharding-benchmark |
| 28 |
permissions: |
| 29 |
contents: write # required for pushing to gh-pages branch |
| 30 |
name: Benchmarks |
| 31 |
runs-on: oracle-bare-metal-64cpu-1024gb-x86-64-ubuntu-24 |
| 32 |
strategy: |
| 33 |
matrix: |
| 34 |
shard: ${{ fromJson(needs.sharding-benchmark.outputs.shards) }} |
| 35 |
steps: |
| 36 |
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 |
| 37 |
- uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6.4.0 |
| 38 |
with: |
| 39 |
go-version: ${{ env.DEFAULT_GO_VERSION }} |
| 40 |
check-latest: true |
| 41 |
cache-dependency-path: "**/go.sum" |
| 42 |
- name: Run the benchmarks |
| 43 |
uses: CodSpeedHQ/action@d872884a306dd4853acf0f584f4b706cf0cc72a2 # v4.13.0 |
| 44 |
with: |
| 45 |
mode: walltime |
| 46 |
allow-empty: true |
| 47 |
# CodSpeed overrides the default benchtime if we don't explicitly specify it. |
| 48 |
# Having this would avoid running benchmark for more than 1 hour. |
| 49 |
# |
| 50 |
# The benchtime is adjusted to 500 ms to speed up the benchmark time. |
| 51 |
# Per https://github.com/open-telemetry/community/issues/2331#issuecomment-2356403352 |
| 52 |
run: make benchmark/${{matrix.shard}} ARGS=-benchtime=500ms |