diff --git a/size_test.go b/size_test.go index 9931199..5bdaddd 100644 --- a/size_test.go +++ b/size_test.go @@ -140,6 +140,18 @@ func TestRAMInBytes(t *testing.T) { assertError(t, RAMInBytes, "32bm") } +func BenchmarkParseSize(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, s := range []string{ + "", "32", "32b", "32 B", "32k", "32.5 K", "32kb", "32 Kb", + "32.8Mb", "32.9Gb", "32.777Tb", "32Pb", "0.3Mb", "-1", + } { + FromHumanSize(s) + RAMInBytes(s) + } + } +} + func assertEquals(t *testing.T, expected, actual interface{}) { if expected != actual { t.Errorf("Expected '%v' but got '%v'", expected, actual)