Created
June 6, 2015 14:30
-
-
Save taotetek/350c91bb9810ea1729ca to your computer and use it in GitHub Desktop.
playing around
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
BenchmarkSetGetMutex 2000000 668 ns/op |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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