-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
74 lines (56 loc) · 2.49 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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
CONF ?= .env
include $(CONF)
include Makefile.docker.mk
include Makefile.load.mk
include Makefile.migrate.mk
.DEFAULT_GOAL := default
NAME ?= mhz19-go-backend
GIT_REV ?= $(shell git rev-parse --short HEAD)
DATE ?= $(shell date +%FT%T)
OS_NAME := $(shell uname -s | tr A-Z a-z)
default: lint test build
build:
GORACE="halt_on_error=1" CGO_ENABLED=1 go build -race -o ./bin/backend ./cmd/backend
build-norace:
CGO_ENABLED=1 go build -o ./bin/backend ./cmd/backend
clean:
rm ./bin/backend
run:
GORACE="halt_on_error=1" go run -race ./cmd/backend
run-norace:
go run ./cmd/backend
seed:
go run ./cmd/seed
tidy:
go mod tidy
lint:
golangci-lint run
test:
go test -cover -race -count 1 ./...
bench:
rm -f *.prof && go test ./internal/engine -bench=^Benchmark10$$ -run=^$$ -benchmem -cpuprofile cpu.prof -memprofile=mem.prof
pprof-mem:
go tool pprof -http=:7272 mem.prof
pprof-cpu:
go tool pprof -http=:7272 cpu.prof
test-one:
go test ./internal/engine -run TestMappings -v
update:
git -C . pull && git -C ../mhz19-front pull && git -C ../device-pinger pull && make compose-build && make compose-up
# git pull && make docker-build && make docker-down && make docker-up && make docker-logs
# rm -f *.prof && go test ./internal/entities/rules -bench=^Benchmark20$$ -run=^$$ -benchmem -cpuprofile cpu.prof -memprofile=mem.prof
# rm -f *.prof && go test ./internal/counters -bench=^Benchmark30$$ -run=^$$ -benchmem -cpuprofile cpu.prof -memprofile=mem.prof
# CGO_ENABLED=1 go test -benchmem ./...
# CGO_ENABLED=1 go test -cover -race -count 1 ./...
# curl -X PUT -H "Content-Type: application/json" -d @assets/push-message.json $(REST_API_URL)/push-message
# go test -bench Benchmark10 -run=^$ -benchmem ./internal/counters -cpuprofile=cpu.prof
# go test -bench Benchmark10 -run=^$ ./internal/counters -memprofile=mem.prof
# go test -bench=. -benchmem -memprofile memprofile.out -cpuprofile profile.out
# go test -bench=^Benchmark10$ -run=^$ . -memprofile=mem.prof ./internal/counters
# go test -benchmem -run=^$ -bench "^Benchmark10$" github.com/fedulovivan/mhz19-go/internal/counters -cpuprofile=cpuprofile.prof
# go test ./internal/counters -bench=^Benchmark20$$ -run=^$$
# https://gist.github.com/ungoldman/11282441
# https://stackoverflow.com/questions/978142/how-to-benchmark-apache-with-delays
# oha --method PUT -H 'Content-Type: application/json' -D ./assets/load/create-rule.json $(REST_API_URL)/rules
# watch -n 0.5
# RUN GORACE="halt_on_error=1" CGO_ENABLED=1 GOOS=linux go build -race -o /build/backend ./cmd/backend