-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
121 lines (98 loc) · 3.7 KB
/
Makefile
File metadata and controls
121 lines (98 loc) · 3.7 KB
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
.PHONY: test bench bench-count bench-variance race lint clean build
# Default target
all: test
# Build all packages
build:
go build ./...
# Run all tests
test:
go test ./...
# =============================================================================
# Benchmarks - All
# =============================================================================
# Run all benchmarks with memory stats
bench:
go test -bench=. -benchmem ./internal/...
# Run benchmarks with multiple iterations (for variance analysis)
bench-count:
go test -bench=. -benchmem -count=10 ./internal/...
# Run specific benchmark with variance check
bench-variance:
@echo "Running benchmarks 10 times for variance analysis..."
go test -bench=. -count=10 ./internal/... | tee bench_results.txt
@echo ""
@echo "Analyze with: benchstat bench_results.txt"
# =============================================================================
# Benchmarks - By Category
# =============================================================================
# Cancel benchmarks (context vs atomic)
bench-cancel:
go test -bench=BenchmarkCancel -benchmem ./internal/cancel
# Tick benchmarks (ticker implementations)
bench-tick:
go test -bench=BenchmarkTick -benchmem ./internal/tick
# Queue benchmarks (single goroutine)
bench-queue:
go test -bench=BenchmarkQueue -benchmem ./internal/queue
# Pipeline benchmarks (2-goroutine SPSC)
bench-pipeline:
go test -bench=BenchmarkPipeline -benchmem ./internal/combined
# MPSC benchmarks (multiple producers, channel contention)
bench-mpsc:
go test -bench=BenchmarkMPSC -benchmem ./internal/combined
# go-lock-free-ring comparison benchmarks
bench-lfr:
go test -bench=BenchmarkLFR -benchmem ./internal/combined
# Combined loop benchmarks (cancel + tick + queue)
bench-combined:
go test -bench=BenchmarkCombined -benchmem ./internal/combined
# =============================================================================
# Testing & Quality
# =============================================================================
# Run tests with race detector
race:
go test -race ./...
# Run linter
lint:
golangci-lint run ./...
# Run benchmarks with race detector (slower)
bench-race:
go test -race -bench=. -benchtime=100ms ./internal/...
# Clean build artifacts
clean:
rm -f bench_results.txt
rm -f *.prof
rm -f *.test
# Quick sanity check
check: build test race
@echo "All checks passed!"
# =============================================================================
# Help
# =============================================================================
help:
@echo "Available targets:"
@echo ""
@echo "Build & Test:"
@echo " build - Build all packages"
@echo " test - Run all tests"
@echo " race - Run tests with race detector"
@echo " lint - Run golangci-lint"
@echo " check - Run build, test, and race"
@echo ""
@echo "All Benchmarks:"
@echo " bench - Run all benchmarks with memory stats"
@echo " bench-count - Run benchmarks 10 times (for variance)"
@echo " bench-variance - Run benchmarks and save for benchstat"
@echo " bench-race - Run benchmarks with race detector"
@echo ""
@echo "Category Benchmarks:"
@echo " bench-cancel - Cancel check: context vs atomic"
@echo " bench-tick - Tick check: ticker implementations"
@echo " bench-queue - Queue: single goroutine push+pop"
@echo " bench-pipeline - Pipeline: 2-goroutine SPSC producer/consumer"
@echo " bench-mpsc - MPSC: N producers -> 1 consumer (channel contention)"
@echo " bench-lfr - go-lock-free-ring comparison (SPSC vs MPSC)"
@echo " bench-combined - Combined loop: cancel + tick + queue"
@echo ""
@echo "Cleanup:"
@echo " clean - Remove generated files"