@@ -124,10 +124,37 @@ cd tests/contract
124124go test ./...
125125```
126126
127- ## License
127+ ## Benchmarking
128128
129- [ Add License Information ]
129+ Performance benchmarks are located in the following packages:
130130
131- ## Contributing
131+ - ` internal/kernel/ ` - ExtProc Process() lifecycle benchmarks
132+ - ` internal/executor/ ` - Policy chain execution benchmarks
133+ - ` internal/pkg/cel/ ` - CEL expression evaluation benchmarks
132134
133- See [ CONTRIBUTING.md] ( CONTRIBUTING.md ) for development guidelines.
135+ ### Running Benchmarks
136+
137+ ``` bash
138+ # Run all benchmarks with memory allocation stats
139+ go test -bench=. -benchmem -count=5 ./internal/kernel/ -run=^$
140+ go test -bench=. -benchmem -count=5 ./internal/executor/ -run=^$
141+ go test -bench=. -benchmem -count=5 ./internal/pkg/cel/ -run=^$
142+
143+ # Run specific benchmark
144+ go test -bench=BenchmarkProcess/NoPolicies -benchmem -count=5 ./internal/kernel/ -run=^$
145+ go test -bench=BenchmarkProcess/1Policy -benchmem -count=5 ./internal/kernel/ -run=^$
146+
147+ # Generate CPU profile for optimization
148+ go test -bench=BenchmarkProcess -benchmem -cpuprofile=cpu.prof ./internal/kernel/ -run=^$
149+ go tool pprof -http=:8080 cpu.prof
150+
151+ # Generate memory profile
152+ go test -bench=BenchmarkProcess -benchmem -memprofile=mem.prof ./internal/kernel/ -run=^$
153+ go tool pprof -http=:8080 mem.prof
154+
155+ # Compare benchmarks (requires benchstat: go install golang.org/x/perf/cmd/benchstat@latest)
156+ go test -bench=. -benchmem -count=10 ./internal/kernel/ -run=^$ > old.txt
157+ # Make changes...
158+ go test -bench=. -benchmem -count=10 ./internal/kernel/ -run=^$ > new.txt
159+ benchstat old.txt new.txt
160+ ```
0 commit comments