| 112 | } |
| 113 | |
| 114 | func 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 | |
| 132 | func BenchmarkBind_Query(b *testing.B) { |
| 133 | e := New() |