-
Notifications
You must be signed in to change notification settings - Fork 37
/
Makefile
34 lines (26 loc) · 1.08 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
SHELL = /bin/bash
dstdir := $(CURDIR)
srcdir := $(CURDIR)/build
sources := $(wildcard \
$(srcdir)/*_asm.go \
$(srcdir)/*/*_asm.go \
)
targets := \
$(patsubst $(srcdir)/%_asm.go,$(dstdir)/%_amd64.s,$(sources)) \
$(patsubst $(srcdir)/%_asm.go,$(dstdir)/%_amd64.go,$(sources))
internal := $(wildcard $(srcdir)/internal/*/*.go)
build: $(targets)
count ?= 5
bench ?= .
pkg ?= ...
benchcmp:
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/%,%,$<) \
-pkg $(notdir $(realpath $(dir $<))) \
-out ../$(patsubst $(CURDIR)/%,%,$(patsubst $(srcdir)/%_asm.go,$(dstdir)/%_amd64.s,$<)) \
-stubs ../$(patsubst $(CURDIR)/%,%,$(patsubst $(srcdir)/%_asm.go,$(dstdir)/%_amd64.go,$<))
go fmt $(dstdir)/$(*)_amd64.go
.PHONY: build benchmp