Is it expected that if multiple sub-benchmarks are run in the same 
benchmark, the cost of the setup will impact the results from the first 
benchmark but not the second?

func BenchmarkIntersection(b *testing.B) {
        // Long setup -- ~5.5 seconds

b.Run("basic 1", func(b *testing.B) {
for i := 0; i < b.N; i++ {
// Do benchmark stuff
}
})
b.Run("basic 2", func(b *testing.B) {
for i := 0; i < b.N; i++ {
// Do benchmark stuff (EXACTLY THE SAME AS TEST 1)
}
})
}

Results in:

BenchmarkIntersection/basic_1-4               1 5521938867 ns/op
BenchmarkIntersection/basic_2-4       200000000         8.89 ns/op

Am I doing this wrong?

I don't see an issue raised against this--should I be raising one?


-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to