b := make([]byte, 0, max)
return ip.appendTo4(b), nil
default:
- max := len("ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff%enp5s0")
- b := make([]byte, 0, max)
if ip.Is4In6() {
+ max := len("::ffff:255.255.255.255%enp5s0")
+ b := make([]byte, 0, max)
return ip.appendTo4In6(b), nil
}
+ max := len("ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff%enp5s0")
+ b := make([]byte, 0, max)
return ip.appendTo6(b), nil
}
-
}
// UnmarshalText implements the encoding.TextUnmarshaler interface.
}
}
-func BenchmarkIPMarshalText(b *testing.B) {
- b.ReportAllocs()
- ip := MustParseAddr("66.55.44.33")
- for i := 0; i < b.N; i++ {
- sinkBytes, _ = ip.MarshalText()
+func BenchmarkAddrMarshalText(b *testing.B) {
+ for _, test := range parseBenchInputs {
+ ip := MustParseAddr(test.ip)
+ b.Run(test.name, func(b *testing.B) {
+ b.ReportAllocs()
+ for i := 0; i < b.N; i++ {
+ sinkBytes, _ = ip.MarshalText()
+ }
+ })
}
}