diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml new file mode 100644 index 00000000..def45654 --- /dev/null +++ b/.github/workflows/benchmark.yml @@ -0,0 +1,22 @@ +name: Go + +on: + push: + branches: + - 'main' + +jobs: + benchmark: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + + - name: Setup Go + uses: actions/setup-go@v2 + with: + go-version: 1.18.x + + - name: Run benchmarks + run: | + go install golang.org/x/perf/cmd/benchstat@latest + make benchcmp count=1 diff --git a/Makefile b/Makefile index 2dd5d995..933c8b3b 100644 --- a/Makefile +++ b/Makefile @@ -1,3 +1,5 @@ +SHELL = /bin/bash + dstdir := $(CURDIR) srcdir := $(CURDIR)/build @@ -16,10 +18,11 @@ build: $(targets) count ?= 5 bench ?= . +pkg ?= ... benchcmp: - go test -v -run _ -count $(count) -bench $(bench) ./$(pkg) -tags purego | tee /tmp/bench-$(pkg)-purego.txt - go test -v -run _ -count $(count) -bench $(bench) ./$(pkg) | tee /tmp/bench-$(pkg)-asm.txt - benchstat /tmp/bench-$(pkg)-{purego,asm}.txt + go test -v -run _ -count $(count) -bench $(bench) ./$(pkg) -tags purego > /tmp/bench-$(subst .,dot,$(pkg))-purego.txt + go test -v -run _ -count $(count) -bench $(bench) ./$(pkg) > /tmp/bench-$(subst .,dot,$(pkg))-asm.txt + benchstat /tmp/bench-$(subst .,dot,$(pkg))-{purego,asm}.txt $(dstdir)/%_amd64.s $(dstdir)/%_amd64.go: $(srcdir)/%_asm.go $(internal) cd build && go run $(patsubst $(CURDIR)/build/%,%,$<) \