diff options
Diffstat (limited to 'libgo/go/mime/type_test.go')
-rw-r--r-- | libgo/go/mime/type_test.go | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/libgo/go/mime/type_test.go b/libgo/go/mime/type_test.go index 48735ef4470..de5c700faaf 100644 --- a/libgo/go/mime/type_test.go +++ b/libgo/go/mime/type_test.go @@ -149,3 +149,43 @@ func TestLookupMallocs(t *testing.T) { t.Errorf("allocs = %v; want 0", n) } } + +func BenchmarkTypeByExtension(b *testing.B) { + initMime() + b.ResetTimer() + + for _, ext := range []string{ + ".html", + ".HTML", + ".unused", + } { + b.Run(ext, func(b *testing.B) { + b.RunParallel(func(pb *testing.PB) { + for pb.Next() { + TypeByExtension(ext) + } + }) + }) + } +} + +func BenchmarkExtensionsByType(b *testing.B) { + initMime() + b.ResetTimer() + + for _, typ := range []string{ + "text/html", + "text/html; charset=utf-8", + "application/octet-stream", + } { + b.Run(typ, func(b *testing.B) { + b.RunParallel(func(pb *testing.PB) { + for pb.Next() { + if _, err := ExtensionsByType(typ); err != nil { + b.Fatal(err) + } + } + }) + }) + } +} |