MCPcopy Index your code
hub / github.com/labstack/echo / BenchmarkBind_JSON

Function BenchmarkBind_JSON

perf_bench_test.go:114–130  ·  view source on GitHub ↗
(b *testing.B)

Source from the content-addressed store, hash-verified

112}
113
114func BenchmarkBind_JSON(b *testing.B) {
115 e := New()
116 body := `{"id":1,"name":"Jon Snow","email":"jon@winterfell.north","age":24,"active":true}`
117 e.POST("/", func(c *Context) error {
118 var t bindTarget
119 return c.Bind(&t)
120 })
121 b.ReportAllocs()
122 b.ResetTimer()
123 w := &nopResponseWriter{}
124 for i := 0; i < b.N; i++ {
125 w.h = nil
126 req := httptest.NewRequest(http.MethodPost, "/", strings.NewReader(body))
127 req.Header.Set(HeaderContentType, MIMEApplicationJSON)
128 e.ServeHTTP(w, req)
129 }
130}
131
132func BenchmarkBind_Query(b *testing.B) {
133 e := New()

Callers

nothing calls this directly

Calls 5

NewFunction · 0.85
SetMethod · 0.80
ServeHTTPMethod · 0.80
BindMethod · 0.65
POSTMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…