Reputation: 4664
I am trying to create a suite of benchmark tests
https://play.golang.org/p/uWWITU-WKaL
package main
import (
"fmt"
"testing"
)
func runall(a, b string) (bool, error) {
return true, nil
}
func main() {
bench := []testing.InternalBenchmark{
{
F: Benchmark_Dev,
},
}
tests := []testing.InternalTest{
{
F: Test_Dev,
},
}
testing.Main(runall, tests, bench, nil)
}
func Test_Dev(t *testing.T) {
fmt.Println("Test_Dev")
}
func Benchmark_Dev(b *testing.B) {
fmt.Println("Benchmark_Dev")
b.ReportAllocs()
for i := 0; i < b.N; i++ {
res := i % 10
fmt.Println(res)
}
}
I see Tests are run fine, but the benchmarks are never run.
Upvotes: 4
Views: 3936
Reputation: 3537
If you read "About" on Go Playground:
If the program contains tests or examples and no main function, the service runs the tests. Benchmarks will likely not be supported since the program runs in a sandboxed environment with limited resources.
You will find your answer
Upvotes: 7