From d57436af57ba7dd373d0246a3d85dfc2f3e91d22 Mon Sep 17 00:00:00 2001 From: Alex Peters Date: Mon, 8 Jan 2024 09:01:30 +0100 Subject: [PATCH] Add benchmark --- pkg/endpoints/endponts_bench_test.go | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 pkg/endpoints/endponts_bench_test.go diff --git a/pkg/endpoints/endponts_bench_test.go b/pkg/endpoints/endponts_bench_test.go new file mode 100644 index 00000000..d101c9a7 --- /dev/null +++ b/pkg/endpoints/endponts_bench_test.go @@ -0,0 +1,20 @@ +package endpoints + +import ( + "context" + "testing" +) + +func BenchmarkEndpointGroup(b *testing.B) { + e := newEndpointGroup() + e.setIPs(map[string]struct{}{"10.0.0.1": {}}, map[string]int32{"testPort": 1}) + b.ResetTimer() + b.RunParallel(func(pb *testing.PB) { + for pb.Next() { + _, err := e.getBestHost(context.Background(), "testPort") + if err != nil { + b.Fatal(err) + } + } + }) +}