Skip to content
Permalink
Browse files

Ensure compiler returns https://www.reddit.com/r/golang/comments/aizb…

  • Loading branch information...
kaihendry committed Jan 25, 2019
1 parent 70b94d1 commit e335c1fc0bae8b0e1f292b14ca8f6bd006d86bdf
Showing with 6 additions and 1 deletion.
  1. +6 −1 busstops_test.go
@@ -16,10 +16,15 @@ func init() {
}
}

// We need to ensure compiler actually returns the value
// A clever compiler might optimise it out, rendering our
// benchmarking results incorrect
var stop BusStop

func Benchmark_closest(b *testing.B) {
b.ResetTimer()
for n := 0; n < b.N; n++ {
bs.closest(Point{})
stop = bs.closest(Point{}) // ensure the compiler returns a value
}
}

0 comments on commit e335c1f

Please sign in to comment.
You can’t perform that action at this time.