MCPcopy
hub / github.com/julienschmidt/httprouter / BenchmarkAllowed

Function BenchmarkAllowed

router_test.go:219–238  ·  view source on GitHub ↗
(b *testing.B)

Source from the content-addressed store, hash-verified

217}
218
219func BenchmarkAllowed(b *testing.B) {
220 handlerFunc := func(_ http.ResponseWriter, _ *http.Request, _ Params) {}
221
222 router := New()
223 router.POST("/path", handlerFunc)
224 router.GET("/path", handlerFunc)
225
226 b.Run("Global", func(b *testing.B) {
227 b.ReportAllocs()
228 for i := 0; i < b.N; i++ {
229 _ = router.allowed("*", http.MethodOptions)
230 }
231 })
232 b.Run("Path", func(b *testing.B) {
233 b.ReportAllocs()
234 for i := 0; i < b.N; i++ {
235 _ = router.allowed("/path", http.MethodOptions)
236 }
237 })
238}
239
240func TestRouterOPTIONS(t *testing.T) {
241 handlerFunc := func(_ http.ResponseWriter, _ *http.Request, _ Params) {}

Callers

nothing calls this directly

Calls 4

NewFunction · 0.85
POSTMethod · 0.80
GETMethod · 0.80
allowedMethod · 0.80

Tested by

no test coverage detected