I have a go test file in which I wrote a benchmark function as follows:
func BenchmarkStuff(b *testing.B) {
for i := 0; i < b.N; i++ {
stuff()
}
}
However the stuff() function requires some setup to occur every time before it runs and cleanup to occur every time after it runs. I have functions setup() and cleanup() that do this respectively. But I don't want to benchmark the setup and cleanup functions.
So where should they be called? If I call them inside BenchmarkStuff, they will be added to the results measurements. But without them, stuff() will fail.