| 1 |
SHELL = /bin/bash |
| 2 |
|
| 3 |
dstdir := $(CURDIR) |
| 4 |
srcdir := $(CURDIR)/build |
| 5 |
|
| 6 |
sources := $(wildcard \ |
| 7 |
$(srcdir)/*_asm.go \ |
| 8 |
$(srcdir)/*/*_asm.go \ |
| 9 |
) |
| 10 |
|
| 11 |
targets := \ |
| 12 |
$(patsubst $(srcdir)/%_asm.go,$(dstdir)/%_amd64.s,$(sources)) \ |
| 13 |
$(patsubst $(srcdir)/%_asm.go,$(dstdir)/%_amd64.go,$(sources)) |
| 14 |
|
| 15 |
internal := $(wildcard $(srcdir)/internal/*/*.go) |
| 16 |
|
| 17 |
build: $(targets) |
| 18 |
|
| 19 |
count ?= 5 |
| 20 |
bench ?= . |
| 21 |
pkg ?= ... |
| 22 |
benchcmp: |
| 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 |
| 26 |
|
| 27 |
$(dstdir)/%_amd64.s $(dstdir)/%_amd64.go: $(srcdir)/%_asm.go $(internal) |
| 28 |
cd build && go run $(patsubst $(CURDIR)/build/%,%,$<) \ |
| 29 |
-pkg $(notdir $(realpath $(dir $<))) \ |
| 30 |
-out ../$(patsubst $(CURDIR)/%,%,$(patsubst $(srcdir)/%_asm.go,$(dstdir)/%_amd64.s,$<)) \ |
| 31 |
-stubs ../$(patsubst $(CURDIR)/%,%,$(patsubst $(srcdir)/%_asm.go,$(dstdir)/%_amd64.go,$<)) |
| 32 |
go fmt $(dstdir)/$(*)_amd64.go |
| 33 |
|
| 34 |
.PHONY: build benchmp |