Skip to content

Instantly share code, notes, and snippets.

@blanchonvincent
Created July 5, 2019 08:44
Show Gist options
  • Save blanchonvincent/54d67c73e61c08e97eab39c8ccba364c to your computer and use it in GitHub Desktop.
Save blanchonvincent/54d67c73e61c08e97eab39c8ccba364c to your computer and use it in GitHub Desktop.
medium - test package - benchmark with custom metric
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