-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
39 lines (30 loc) · 964 Bytes
/
Makefile
File metadata and controls
39 lines (30 loc) · 964 Bytes
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
GOROOT := $(shell go env GOROOT)
BENCHDIR := benchmarks
TIMESTAMP := $(shell date -u +"%Y%m%dT%H%M%SZ")
GO_TEST_BENCH := go test -bench=. -benchmem -count=6
.PHONY: wasm
wasm:
env GOOS=js GOARCH=wasm go build -o ants_again.wasm github.com/rafibayer/ants-again
cp -f $(GOROOT)/lib/wasm/wasm_exec.js .
.PHONY: serve
serve: wasm
py -m http.server 8080
.PHONY: dotcpu
dotcpu:
go tool pprof -dot cpu.prof > cpu.dot
.PHONY: bench
bench:
@mkdir -p $(BENCHDIR)
@echo "Running benchmarks..."
@$(GO_TEST_BENCH) > $(BENCHDIR)/bench_$(TIMESTAMP).txt
@echo "Benchmark saved to $(BENCHDIR)/bench_$(TIMESTAMP).txt"
.PHONY: compare
compare:
@latest=$$(ls -1t $(BENCHDIR)/bench_*.txt | head -n 2 | tail -n 1); \
newest=$$(ls -1t $(BENCHDIR)/bench_*.txt | head -n 1); \
if [ -n "$$latest" ] && [ -n "$$newest" ]; then \
echo "Comparing $$latest -> $$newest"; \
benchstat $$latest $$newest; \
else \
echo "Need at least 2 benchmark files to compare"; \
fi