mirror of
https://github.com/gohugoio/hugo.git
synced 2024-11-21 20:46:30 -05:00
media: Add a basic benchmark
This commit is contained in:
parent
18074d0c23
commit
4d24e2a326
1 changed files with 23 additions and 0 deletions
|
@ -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")
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue