mirror of
https://github.com/coredns/coredns.git
synced 2026-08-20 23:08:28 -04:00
plugin/forward: fast-path string comparison in isAllowedDomain (#8385)
* test: add benchmark cases for Request IP/Port and parseRequest Signed-off-by: Manuel Rüger <manuel@rueg.eu> * test(kubernetes): add BenchmarkServices and BenchmarkServicesHeadless Signed-off-by: Manuel Rüger <manuel@rueg.eu> * perf(forward): fast-path string comparison in isAllowedDomain Signed-off-by: Manuel Rüger <manuel@rueg.eu> --------- Signed-off-by: Manuel Rüger <manuel@rueg.eu>
This commit is contained in:
@@ -381,3 +381,23 @@ func TestRequestClear(t *testing.T) {
|
||||
t.Errorf("Expected st.port to be cleared after Clear")
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkRequestIP(b *testing.B) {
|
||||
st := testRequest()
|
||||
b.ReportAllocs()
|
||||
|
||||
for b.Loop() {
|
||||
st.Clear()
|
||||
_ = st.IP()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkRequestPort(b *testing.B) {
|
||||
st := testRequest()
|
||||
b.ReportAllocs()
|
||||
|
||||
for b.Loop() {
|
||||
st.Clear()
|
||||
_ = st.Port()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user