MCPcopy
hub / github.com/go-chi/chi / BenchmarkTreeGet

Function BenchmarkTreeGet

tree_test.go:487–510  ·  view source on GitHub ↗
(b *testing.B)

Source from the content-addressed store, hash-verified

485}
486
487func BenchmarkTreeGet(b *testing.B) {
488 h1 := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {})
489 h2 := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {})
490
491 tr := &node{}
492 tr.InsertRoute(mGET, "/", h1)
493 tr.InsertRoute(mGET, "/ping", h2)
494 tr.InsertRoute(mGET, "/pingall", h2)
495 tr.InsertRoute(mGET, "/ping/{id}", h2)
496 tr.InsertRoute(mGET, "/ping/{id}/woop", h2)
497 tr.InsertRoute(mGET, "/ping/{id}/{opt}", h2)
498 tr.InsertRoute(mGET, "/pinggggg", h2)
499 tr.InsertRoute(mGET, "/hello", h1)
500
501 mctx := NewRouteContext()
502
503 b.ReportAllocs()
504 b.ResetTimer()
505
506 for i := 0; i < b.N; i++ {
507 mctx.Reset()
508 tr.FindRoute(mctx, mGET, "/ping/123/456")
509 }
510}
511
512func TestWalker(t *testing.T) {
513 r := bigMux()

Callers

nothing calls this directly

Calls 5

InsertRouteMethod · 0.95
FindRouteMethod · 0.95
NewRouteContextFunction · 0.85
HandlerFuncMethod · 0.80
ResetMethod · 0.65

Tested by

no test coverage detected