media: Add a basic benchmark

This commit is contained in:
Bjørn Erik Pedersen 2021-03-11 10:07:56 +01:00
parent 18074d0c23
commit 4d24e2a326
No known key found for this signature in database
GPG key ID: 330E6E2BD4859D8F

View file

@ -233,3 +233,26 @@ func TestDecodeTypes(t *testing.T) {
}
}
}
func BenchmarkTypeOps(b *testing.B) {
mt := MPEGType
mts := DefaultTypes
for i := 0; i < b.N; i++ {
_ = mt.FullSuffix()
_ = mt.IsZero()
c, err := mt.MarshalJSON()
if c == nil || err != nil {
b.Fatal("failed")
}
_ = mt.String()
_ = mt.Suffix()
_ = mt.Suffixes
_ = mt.Type()
_ = mts.BySuffix("xml")
_, _ = mts.GetByMainSubType("application", "xml")
_, _ = mts.GetBySuffix("xml")
_, _ = mts.GetByType("application")
_, _ = mts.GetFirstBySuffix("xml")
}
}