I've recently started learning Go and I'm trying to implement a map that can be used concurrently by multiple groutines. I want to be able to compare my implementation to a simple sync.Mutex-protected map, or to something like this: https://github.com/streamrail/concurrent-map/blob/master/concurrent_map.go
From using Google Caliper, I assume that a naive approach for benchmarking would allow many unwanted optimizations to trash the actual results. Are the benchmarks that use testing.B employing some of the techniques to avoid that (after all both Go and Caliper are Google projects)? If yes, are they known? If not, what's the best way to microbenchmark in Go?
Converting my comment to an answer.
Source
The following page can also be useful.
Compiler And Runtime Optimizations
Another interesting read is
Source1 Source2
I'm not a 100% sure but the following should disable optimisations ? Someone with more experience needs to confirm it.