MCPcopy
hub / github.com/yusing/godoxy / BenchmarkEntrypoint

Function BenchmarkEntrypoint

internal/entrypoint/entrypoint_benchmark_test.go:111–152  ·  view source on GitHub ↗
(b *testing.B)

Source from the content-addressed store, hash-verified

109}
110
111func BenchmarkEntrypoint(b *testing.B) {
112 ep := NewTestEntrypoint(b, nil)
113 req := http.Request{
114 Method: http.MethodGet,
115 URL: &url.URL{Path: "/", RawPath: "/"},
116 Host: "test.domain.tld",
117 }
118 ep.SetFindRouteDomains([]string{})
119
120 r, err := route.NewStartedTestRoute(b, &route.Route{
121 Alias: "test",
122 Scheme: routeTypes.SchemeHTTP,
123 Host: "localhost",
124 Port: route.Port{
125 Listening: 18080,
126 Proxy: 8080,
127 },
128 HealthCheck: types.HealthCheckConfig{
129 Disable: true,
130 },
131 })
132
133 require.NoError(b, err)
134 require.False(b, r.ShouldExclude())
135
136 r.(types.ReverseProxyRoute).ReverseProxy().Transport = noopTransport{}
137
138 var w noopResponseWriter
139
140 server, ok := ep.GetServer(":18080")
141 if !ok {
142 b.Fatal("server not found")
143 }
144
145 b.ResetTimer()
146 for b.Loop() {
147 server.ServeHTTP(&w, &req)
148 if w.statusCode != http.StatusOK {
149 b.Fatalf("status code is not 200: %d", w.statusCode)
150 }
151 }
152}
153
154func benchmarkFindRoute(b *testing.B, aliases []string, host string) {
155 ep := NewTestEntrypoint(b, nil)

Callers

nothing calls this directly

Calls 7

NewStartedTestRouteFunction · 0.92
NewTestEntrypointFunction · 0.85
SetFindRouteDomainsMethod · 0.80
GetServerMethod · 0.80
ShouldExcludeMethod · 0.65
ReverseProxyMethod · 0.65
ServeHTTPMethod · 0.65

Tested by

no test coverage detected