aboutsummaryrefslogtreecommitdiff
path: root/plugin/etcd/msg/service_test.go
diff options
context:
space:
mode:
authorGravatar Miek Gieben <miek@miek.nl> 2018-12-07 20:09:09 +0000
committerGravatar Yong Tang <yong.tang.github@outlook.com> 2018-12-07 12:09:09 -0800
commit8a5eb58bc09d3a9ce9bbb52ccc972f6eddd6ac80 (patch)
treec2cada1a650f3c73773a0faf9fd00b594d96514d /plugin/etcd/msg/service_test.go
parent16197a1addb69dafffd5f8ffca1d00273831b583 (diff)
downloadcoredns-8a5eb58bc09d3a9ce9bbb52ccc972f6eddd6ac80.tar.gz
coredns-8a5eb58bc09d3a9ce9bbb52ccc972f6eddd6ac80.tar.zst
coredns-8a5eb58bc09d3a9ce9bbb52ccc972f6eddd6ac80.zip
msg.Service: optimize a bit (#2374)
Make the NewSRV and friends slightly smarter. Optimize the calling of targetStrip which is almost certainly not used. Added benchmark show a modest improvement: benchmark old ns/op new ns/op delta BenchmarkNewSRV-4 300 283 -5.67% Signed-off-by: Miek Gieben <miek@miek.nl>
Diffstat (limited to 'plugin/etcd/msg/service_test.go')
-rw-r--r--plugin/etcd/msg/service_test.go8
1 files changed, 8 insertions, 0 deletions
diff --git a/plugin/etcd/msg/service_test.go b/plugin/etcd/msg/service_test.go
index 5b16d2d91..2b38eeee1 100644
--- a/plugin/etcd/msg/service_test.go
+++ b/plugin/etcd/msg/service_test.go
@@ -123,3 +123,11 @@ func TestGroup(t *testing.T) {
t.Fatalf("Failure to group seventh set: %v", sx)
}
}
+
+func BenchmarkNewSRV(b *testing.B) {
+ s := &Service{Host: "www,example.org", Port: 8080}
+ for n := 0; n < b.N; n++ {
+ srv := s.NewSRV("www.example.org.", 16)
+ srv = srv
+ }
+}