Skip to content

Commit 0eb1ec1

Browse files
.github: run benchmarks in CI environment
1 parent aee0221 commit 0eb1ec1

File tree

2 files changed

+28
-3
lines changed

2 files changed

+28
-3
lines changed

.github/workflows/benchmark.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: Go
2+
3+
on:
4+
push:
5+
branches:
6+
- 'main'
7+
8+
jobs:
9+
benchmark:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v2
13+
14+
- name: Setup Go
15+
uses: actions/setup-go@v2
16+
with:
17+
go-version: 1.18.x
18+
19+
- name: Run benchmarks
20+
run: |
21+
go install golang.org/x/perf/cmd/benchstat@latest
22+
make benchcmp count=1

Makefile

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
SHELL = /bin/bash
2+
13
dstdir := $(CURDIR)
24
srcdir := $(CURDIR)/build
35

@@ -16,10 +18,11 @@ build: $(targets)
1618

1719
count ?= 5
1820
bench ?= .
21+
pkg ?= ...
1922
benchcmp:
20-
go test -v -run _ -count $(count) -bench $(bench) ./$(pkg) -tags purego | tee /tmp/bench-$(pkg)-purego.txt
21-
go test -v -run _ -count $(count) -bench $(bench) ./$(pkg) | tee /tmp/bench-$(pkg)-asm.txt
22-
benchstat /tmp/bench-$(pkg)-{purego,asm}.txt
23+
go test -v -run _ -count $(count) -bench $(bench) ./$(pkg) -tags purego > /tmp/bench-$(subst .,dot,$(pkg))-purego.txt
24+
go test -v -run _ -count $(count) -bench $(bench) ./$(pkg) > /tmp/bench-$(subst .,dot,$(pkg))-asm.txt
25+
benchstat /tmp/bench-$(subst .,dot,$(pkg))-{purego,asm}.txt
2326

2427
$(dstdir)/%_amd64.s $(dstdir)/%_amd64.go: $(srcdir)/%_asm.go $(internal)
2528
cd build && go run $(patsubst $(CURDIR)/build/%,%,$<) \

0 commit comments

Comments
 (0)