hugo

Unnamed repository; edit this file 'description' to name the repository.

git clone git://git.shimmy1996.com/hugo.git
commit 4d24e2a3261d8c7dc0395db3ac4de89ebb0974a5
parent 18074d0c2375cc4bf4d7933dd4206cb878a23d1c
Author: Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Date:   Thu, 11 Mar 2021 10:07:56 +0100

media: Add a basic benchmark

Diffstat:
Mmedia/mediaType_test.go | 23+++++++++++++++++++++++
1 file changed, 23 insertions(+), 0 deletions(-)
diff --git 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")
+
+	}
+}