-
Notifications
You must be signed in to change notification settings - Fork 3
/
Makefile
51 lines (42 loc) · 1.3 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
# Variables for coverage and profiling files
COVERAGE_FILE := coverage.out
COVERAGE_HTML := coverage.html
CPU_PROFILE := cpu.prof
MEM_PROFILE := mem.prof
# Default target runs tests with race conditions
.PHONY: all
all: test
# Test with race detection, coverage report generation
.PHONY: test
test:
go test ./... -v -race -covermode=atomic -coverprofile=$(COVERAGE_FILE)
go tool cover -html=$(COVERAGE_FILE) -o $(COVERAGE_HTML)
# Test without race detection, coverage report generation
.PHONY: test-no-race
test-no-race:
go test ./... -v -covermode=atomic -coverprofile=$(COVERAGE_FILE)
go tool cover -html=$(COVERAGE_FILE) -o $(COVERAGE_HTML)
# Format the code
.PHONY: format
format:
go fmt ./...
# Run benchmarks with memory allocation statistics
.PHONY: bench
bench:
go test ./... -bench . -benchmem -cpu=1
# Generate CPU and memory profiles while running benchmarks
.PHONY: profile-bench
profile-bench:
go test ./... -bench . -cpuprofile=$(CPU_PROFILE) -memprofile=$(MEM_PROFILE) -cpu=1
# Generate CPU profiling report
.PHONY: cpu-report
cpu-report:
go tool pprof $(CPU_PROFILE)
# Generate memory profiling report
.PHONY: mem-report
mem-report:
go tool pprof $(MEM_PROFILE)
# Clean up profiling and coverage files
.PHONY: clean
clean:
rm -f $(COVERAGE_FILE) $(COVERAGE_HTML) $(CPU_PROFILE) $(MEM_PROFILE)