From 406886b51f88d29f771dea395aecda652ebbe8de Mon Sep 17 00:00:00 2001 From: Ilya Tocar <ilya.tocar@intel.com> Date: Mon, 7 May 2018 16:18:11 -0500 Subject: [PATCH] net: make IPString benchmarks more representative. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We were spending more time in duffcopy than in the String method. Avoid creating a copy of test struct to make benchmark measure performance of String() itself. IPString/IPv4-8 113ns ± 0% 57ns ± 1% -49.83% (p=0.000 n=8+10) IPString/IPv6-8 972ns ± 1% 915ns ± 1% -5.88% (p=0.000 n=9+10) Change-Id: I5ceff2caa1b8288c43f0cf6c6b3809ca523af1fa Reviewed-on: https://go-review.googlesource.com/111881 Run-TryBot: Ilya Tocar <ilya.tocar@intel.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> --- src/net/ip_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/net/ip_test.go b/src/net/ip_test.go index 60329e9cfe..95dd109e28 100644 --- a/src/net/ip_test.go +++ b/src/net/ip_test.go @@ -129,7 +129,7 @@ func TestMarshalEmptyIP(t *testing.T) { } } -var ipStringTests = []struct { +var ipStringTests = []*struct { in IP // see RFC 791 and RFC 4291 str string // see RFC 791, RFC 4291 and RFC 5952 byt []byte -- 2.30.9