Skip to content

Commit

Permalink
media: Add a basic benchmark
Browse files Browse the repository at this point in the history
  • Loading branch information
bep committed Mar 11, 2021
1 parent 18074d0 commit 4d24e2a
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions media/mediaType_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")

}
}

0 comments on commit 4d24e2a

Please sign in to comment.