I'm actually struggling to come up with a toy example that identically reproduces the results. I wonder if there are some compiler optimizations happening here.
The example isn't a lot of source, but has some IP and code that's not exactly in a state I wish to post publicly (rough draft). Is there somewhere I can post privately? If not, I can continue to try to reproduce with a non-IPish example. On Thursday, 10 November 2016 17:08:15 UTC-8, Dave Cheney wrote: > > Can you post a runable sample so that other can try to reproduce your > issue? > > On Friday, 11 November 2016 12:06:21 UTC+11, Evan Digby wrote: >> >> 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.