-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
49 lines (40 loc) · 959 Bytes
/
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
BENCH_DIR ?= bench
BUILD_DIR ?= build
SRC_FILES := $(shell find . -name "*.go")
all: lint cover build
.PHONY: all
bench: $(BENCH_DIR)/Marshal.txt $(BENCH_DIR)/Unmarshal.txt
.PHONY: bench
$(BENCH_DIR)/%.txt: $(SRC_FILES)
@mkdir -p $(BENCH_DIR)
go test \
-bench=Benchmark$* \
-run=^$$ \
-benchmem \
-cpuprofile=$(BENCH_DIR)/$*.cpuprof \
-memprofile=$(BENCH_DIR)/$*.memprof \
-trace=$(BENCH_DIR)/$*.trace \
| tee $@
@echo
benchstat $@
@echo
@echo "View benchmark profiles with:"
@echo " go tool pprof -http=:8081 $(BENCH_DIR)/$*.cpuprof"
@echo " go tool pprof -http=:8082 $(BENCH_DIR)/$*.memprof"
build: \
$(BUILD_DIR)/roundtrip \
$(BUILD_DIR)/unmarshal
$(BUILD_DIR)/%: $(SRC_FILES)
go build -trimpath -o $@ ./cmd/$*
lint:
golangci-lint run ./...
.PHONY: lint
cover:
go test -coverprofile=coverage.out ./...
.PHONY: cover
coverhtml: cover
go tool cover -html=coverage.out
.PHONY: coverhtml
test:
go test ./...
.PHONY: test