From 475ccfe0ba71894b4962ea8fa465773ae7e78e8a Mon Sep 17 00:00:00 2001 From: onyx-and-iris Date: Sun, 1 Dec 2024 21:14:30 +0000 Subject: [PATCH] add bench to makefile --- day-01/benchmark | 13 +++++++++++-- day-01/makefile | 5 ++++- scaffold.sh | 5 ++++- 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/day-01/benchmark b/day-01/benchmark index 424ca50..7878e5a 100644 --- a/day-01/benchmark +++ b/day-01/benchmark @@ -2,5 +2,14 @@ goos: linux goarch: amd64 pkg: github.com/onyx-and-iris/aoc2024/day-01 cpu: Intel(R) Core(TM) i7-8700K CPU @ 3.70GHz -BenchmarkMain-12 1000000000 0.001628 ns/op -ok github.com/onyx-and-iris/aoc2024/day-01 0.015s +BenchmarkMain-12 1000000000 0.001576 ns/op +BenchmarkMain-12 1000000000 0.001731 ns/op +BenchmarkMain-12 1000000000 0.001616 ns/op +BenchmarkMain-12 1000000000 0.001597 ns/op +BenchmarkMain-12 1000000000 0.001559 ns/op +BenchmarkMain-12 1000000000 0.001657 ns/op +BenchmarkMain-12 1000000000 0.001542 ns/op +BenchmarkMain-12 1000000000 0.001561 ns/op +BenchmarkMain-12 1000000000 0.001574 ns/op +BenchmarkMain-12 1000000000 0.001582 ns/op +ok github.com/onyx-and-iris/aoc2024/day-01 0.126s diff --git a/day-01/makefile b/day-01/makefile index 30f75ca..508fcb3 100644 --- a/day-01/makefile +++ b/day-01/makefile @@ -8,7 +8,7 @@ EXE := $(BIN_DIR)/$(program) .DEFAULT_GOAL := build -.PHONY: fmt vet build clean +.PHONY: fmt vet build bench clean fmt: $(GO) fmt ./... @@ -18,6 +18,9 @@ vet: fmt build: vet | $(BIN_DIR) $(GO) build -o $(EXE) . +bench: + $(GO) test . -test.count=10 -bench=. > benchmark + $(BIN_DIR): @mkdir -p $@ diff --git a/scaffold.sh b/scaffold.sh index a4436be..028c5b7 100755 --- a/scaffold.sh +++ b/scaffold.sh @@ -21,7 +21,7 @@ EXE := \$(BIN_DIR)/\$(program) .DEFAULT_GOAL := build -.PHONY: fmt vet build clean +.PHONY: fmt vet build bench clean fmt: \$(GO) fmt ./... @@ -31,6 +31,9 @@ vet: fmt build: vet | \$(BIN_DIR) \$(GO) build -o \$(EXE) ./\$(SRC_DIR) +bench: + \$(GO) test . -test.count=10 -bench=. > benchmark + \$(BIN_DIR): @mkdir -p \$@