Skip to content

Instantly share code, notes, and snippets.

@taotetek
Created June 6, 2015 14:30
Show Gist options
  • Save taotetek/350c91bb9810ea1729ca to your computer and use it in GitHub Desktop.
Save taotetek/350c91bb9810ea1729ca to your computer and use it in GitHub Desktop.
playing around
BenchmarkSetGetMutex 2000000 668 ns/op
func BenchmarkSetGetMutex(b *testing.B) {
w := &WithMutex{value: 0, m: &sync.Mutex{}}
for i := 0; i < b.N; i++ {
go func() {
w.Set(i)
n := w.Get()
if n != i {
panic("wrong number")
}
}()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment