I haven't used Heroku. It's possible that Heroku has a problem running a benchmark using the go test
command; there may be a problem with the temporary directory.
Command go
Test packages
'Go test' recompiles each package along with any files with names
matching the file pattern "*test.go". Files whose names begin with
"" (including "_test.go") or "." are ignored. These additional files
can contain test functions, benchmark functions, and example
functions. See 'go help testfunc' for more. Each listed package causes
the execution of a separate test binary.
The package is built in a temporary directory so it does not interfere
with the non-test installation.
Try running the benchmark tests in a program. For example,
package main
import (
"fmt"
"math"
"testing"
)
// a function to be benchmarked
func Area(r float64) float64 {
return math.Pi * r * r
}
// benchmark function
func BenchmarkArea(b *testing.B) {
r := 42.0
for i := 0; i < b.N; i++ {
_ = Area(r)
}
}
func main() {
br := testing.Benchmark(BenchmarkArea)
fmt.Println(br.String() + br.MemString())
}
Output:
2000000000 1.21 ns/op 0 B/op 0 allocs/op
Package testing
func Benchmark
func Benchmark(f func(b *B)) BenchmarkResult
Benchmark benchmarks a single function. Useful for creating custom
benchmarks that do not use the "go test" command.