Created
August 21, 2015 18:41
-
-
Save j16r/a62a577586d9e65518f2 to your computer and use it in GitHub Desktop.
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
| package sets | |
| import "testing" | |
| func BenchmarkUnitSet(b *testing.B) { | |
| for i := 0; i < b.N; i++ { | |
| values := make(map[int]struct{}) | |
| for j := 0; j < 1000; j++ { | |
| values[j] = struct{}{} | |
| } | |
| for j := 0; j < 1000; j++ { | |
| _ = values[j] | |
| } | |
| } | |
| } | |
| func BenchmarkBoolSet(b *testing.B) { | |
| for i := 0; i < b.N; i++ { | |
| values := make(map[int]bool) | |
| for j := 0; j < 1000; j++ { | |
| values[j] = true | |
| } | |
| for j := 0; j < 1000; j++ { | |
| _ = values[j] | |
| } | |
| } | |
| } |
Author
j16r
commented
Aug 21, 2015
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment