-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
241 additions
and
129 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,51 @@ | ||
tests: | ||
go test . ./... -v -race -covermode atomic -coverprofile coverage.out && go tool cover -html coverage.out -o coverage.html | ||
# Variables for coverage and profiling files | ||
COVERAGE_FILE := coverage.out | ||
COVERAGE_HTML := coverage.html | ||
CPU_PROFILE := cpu.prof | ||
MEM_PROFILE := mem.prof | ||
|
||
tests_without_race: | ||
go test . ./... -v -covermode atomic -coverprofile coverage.out && go tool cover -html coverage.out -o coverage.html | ||
# 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 . ./... | ||
go fmt ./... | ||
|
||
# Run benchmarks with memory allocation statistics | ||
.PHONY: bench | ||
bench: | ||
go test . ./... -bench . -benchmem -cpu 1 | ||
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 | ||
|
||
report_bench: | ||
go test . ./... -cpuprofile cpu.prof -memprofile mem.prof -bench . -cpu 1 | ||
# Generate CPU profiling report | ||
.PHONY: cpu-report | ||
cpu-report: | ||
go tool pprof $(CPU_PROFILE) | ||
|
||
cpu_report: | ||
go tool pprof cpu.prof | ||
# Generate memory profiling report | ||
.PHONY: mem-report | ||
mem-report: | ||
go tool pprof $(MEM_PROFILE) | ||
|
||
mem_report: | ||
go tool pprof mem.prof | ||
# Clean up profiling and coverage files | ||
.PHONY: clean | ||
clean: | ||
rm -f $(COVERAGE_FILE) $(COVERAGE_HTML) $(CPU_PROFILE) $(MEM_PROFILE) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.