Just a quick note regarding an aspect of Go benchmark output that was confusing to me. If you run any Go benchmark you might notice each benchmark name has a number added to it, for example -4 in the output below.

$ go test -run NONE -bench K crypto/sha1
goos: darwin
goarch: amd64
pkg: crypto/sha1
BenchmarkHash1K-4   	 1000000	      1268 ns/op	 807.11 MB/s
BenchmarkHash8K-4   	  200000	      8383 ns/op	 977.14 MB/s
PASS
ok  	crypto/sha1	3.051s

It was unclear to me what this value actually means, but some digging in the testing package source code reveals that this is the GOMAXPROCS value for that benchmark execution. So for example, we observe the value change if we set GOMAXPROCS through the environment.

$ GOMAXPROCS=2 go test -run NONE -bench K crypto/sha1
goos: darwin
goarch: amd64
pkg: crypto/sha1
BenchmarkHash1K-2   	 1000000	      1298 ns/op	 788.68 MB/s
BenchmarkHash8K-2   	  200000	      8146 ns/op	1005.54 MB/s
PASS
ok  	crypto/sha1	3.027s

Alternatively we can set multiple possible values via the -cpu flag of go test.

$ go test -run NONE -bench K -cpu 1,2,3 crypto/sha1
goos: darwin
goarch: amd64
pkg: crypto/sha1
BenchmarkHash1K     	 1000000	      1305 ns/op	 784.60 MB/s
BenchmarkHash1K-2   	 1000000	      1281 ns/op	 798.84 MB/s
BenchmarkHash1K-3   	 1000000	      1308 ns/op	 782.33 MB/s
BenchmarkHash8K     	  200000	      8257 ns/op	 992.07 MB/s
BenchmarkHash8K-2   	  200000	      8263 ns/op	 991.34 MB/s
BenchmarkHash8K-3   	  200000	      8552 ns/op	 957.86 MB/s
PASS
ok  	crypto/sha1	9.240s

Note that when GOMAXPROCS=1 no suffix is added.