Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/gohugoio/hugo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/media
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2021-03-11 12:07:56 +0300
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2021-03-11 12:08:51 +0300
commit4d24e2a3261d8c7dc0395db3ac4de89ebb0974a5 (patch)
treeb6f6314bf482426d2d1b4855bb085d5bdb3f0f4d /media
parent18074d0c2375cc4bf4d7933dd4206cb878a23d1c (diff)
media: Add a basic benchmark
Diffstat (limited to 'media')
-rw-r--r--media/mediaType_test.go23
1 files changed, 23 insertions, 0 deletions
diff --git a/media/mediaType_test.go b/media/mediaType_test.go
index 4526c1e06..a846ac6ad 100644
--- a/media/mediaType_test.go
+++ b/media/mediaType_test.go
@@ -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")
+
+ }
+}