Created
July 5, 2019 08:44
-
-
Save blanchonvincent/54d67c73e61c08e97eab39c8ccba364c to your computer and use it in GitHub Desktop.
medium - test package - benchmark with custom metric
This file contains 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 deck | |
import ( | |
"testing" | |
) | |
func BenchmarkGC(b *testing.B) { | |
b.ReportAllocs() | |
shuffled := 0 | |
for i := 0; i < b.N; i++ { | |
d := NewDeck(100) | |
_, _ = d.Draw() | |
shuffled += int(d.shuffled) | |
} | |
b.ReportMetric(float64(shuffled)/float64(b.N), "shuffle/op") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment