There is hash_test.go
How to run each benchmark once to see the list of them
➜ go test -run=. -bench=. -benchtime=1x .
goos: linux
goarch: amd64
pkg: github.com/example/benchmark
cpu: 11th Gen Intel(R) Core(TM) i7-1165G7 @ 2.80GHz
Benchmark/load=RAM/hash=sha1-8 1 35781627 ns/op 33556616 B/op 8 allocs/op
Benchmark/load=RAM/hash=sha256-8 1 22204713 ns/op 33554600 B/op 4 allocs/op
Benchmark/load=RAM/hash=sha512-8 1 52675641 ns/op 33554720 B/op 3 allocs/op
Benchmark/load=CPU/hash=sha1-8 1 30481283 ns/op 1048720 B/op 4 allocs/op
Benchmark/load=CPU/hash=sha256-8 1 18132268 ns/op 1048736 B/op 3 allocs/op
Benchmark/load=CPU/hash=sha512-8 1 47242309 ns/op 1048864 B/op 3 allocs/op
PASS
ok github.com/example/benchmark 0.212s
How to generate results
➜ go test -run='.' -bench="." -count=20 > result.txt
...
How to summarize results
➜ go run golang.org/x/perf/cmd/benchstat@latest -col=/hash result.txt
goos: linux
goarch: amd64
pkg: github.com/example/benchmark
cpu: 11th Gen Intel(R) Core(TM) i7-1165G7 @ 2.80GHz
│ sha1 │ sha256 │ sha512 │
│ sec/op │ sec/op vs base │ sec/op vs base │
/load=RAM-8 43.01m ± 23% 27.12m ± 1% -36.95% (p=0.000 n=20) 65.82m ± 1% +53.03% (p=0.000 n=20)
/load=CPU-8 36.60m ± 2% 22.21m ± 1% -39.33% (p=0.000 n=20) 60.62m ± 1% +65.62% (p=0.000 n=20)
geomean 39.68m 24.54m -38.15% 63.17m +59.20%
│ sha1 │ sha256 │ sha512 │
│ B/op │ B/op vs base │ B/op vs base │
/load=RAM-8 32.00Mi ± 0% 32.00Mi ± 0% +0.00% (p=0.000 n=20) 32.00Mi ± 0% +0.00% (p=0.000 n=20)
/load=CPU-8 1.000Mi ± 0% 1.000Mi ± 0% +0.00% (p=0.000 n=20) 1.000Mi ± 0% +0.00% (p=0.000 n=20)
geomean 5.657Mi 5.657Mi +0.00% 5.657Mi +0.00%
│ sha1 │ sha256 │ sha512 │
│ allocs/op │ allocs/op vs base │ allocs/op vs base │
/load=RAM-8 2.000 ± 0% 2.000 ± 0% ~ (p=1.000 n=20) ¹ 2.000 ± 0% ~ (p=1.000 n=20) ¹
/load=CPU-8 2.000 ± 0% 2.000 ± 0% ~ (p=1.000 n=20) ¹ 2.000 ± 0% ~ (p=1.000 n=20) ¹
geomean 2.000 2.000 +0.00% 2.000 +0.00%
¹ all samples are equal
Alternative way to render results