From 15479c49784c892f3824036880f3d054be8449c2 Mon Sep 17 00:00:00 2001 From: pompydev Date: Sat, 4 May 2024 19:00:22 +0900 Subject: [PATCH] feat: add go-bench command --- go/go.justfile | 3 +++ go/main_test.go | 15 +++++++++++++++ 2 files changed, 18 insertions(+) create mode 100644 go/main_test.go diff --git a/go/go.justfile b/go/go.justfile index f382c0f..c016bb1 100644 --- a/go/go.justfile +++ b/go/go.justfile @@ -6,3 +6,6 @@ @bench-go: build-go hyperfine './go/a < ./input.txt' + +@go-bench: + cd go && go test -bench=. diff --git a/go/main_test.go b/go/main_test.go new file mode 100644 index 0000000..2f1b34a --- /dev/null +++ b/go/main_test.go @@ -0,0 +1,15 @@ +package main + +import ( + "testing" +) + +const N int = 100_000_000 + +var num int = 10 + +func BenchmarkAdd1(b *testing.B) { + for i := 0; i < N; i++ { + _ = num * num + } +}