Skip to content

Feat examples update #10

Feat examples update

Feat examples update #10

name: ⏱ Benchmarks
on:
pull_request:
jobs:
benchmarks:
runs-on: ubuntu-latest
env:
DISPLAY: ':99.0'
defaults:
run:
shell: bash
steps:
- name: Install dependencies
run: |
sudo apt-get update -y
sudo apt-get install -y libasound2-dev libgl1-mesa-dev libxcursor-dev libxi-dev libxinerama-dev libxrandr-dev libxxf86vm-dev
- name: Xvfb
run: |
Xvfb :99 -screen 0 1024x768x24 > /dev/null 2>&1 &
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.23'
- name: Setup benchstats
run: |
go get golang.org/x/perf/cmd/benchstat
go install golang.org/x/perf/cmd/benchstat
- name: Run benchmarks
id: benchmarks
run: |
go test -run='^$' -bench=. -count=10 test/benchmarks_test.go | grep -v "XGB:" > /tmp/benchmarks.txt
echo "results<<EOF" >> "$GITHUB_OUTPUT"
cat /tmp/benchmarks.txt >> "$GITHUB_OUTPUT"
echo "EOF" >> "$GITHUB_OUTPUT"
- name: Run benchmarks diff
id: benchmarks-diff
run: |
benchstat test/results.txt /tmp/benchmarks.txt > /tmp/benchmarks-diff.txt
echo "results<<EOF" >> "$GITHUB_OUTPUT"
cat /tmp/benchmarks-diff.txt >> "$GITHUB_OUTPUT"
echo "EOF" >> "$GITHUB_OUTPUT"
- name: Comment PR with benchmark results
uses: thollander/actions-comment-pull-request@v2
with:
message: |
### Benchmarks
<details>
<summary>Diff</summary>
```
${{ steps.benchmarks-diff.outputs.results }}
```
</details>
<details>
<summary>Results</summary>
```
${{ steps.benchmarks.outputs.results }}
```
</details>
comment_tag: benchmarks