MCPcopy
hub / github.com/labstack/echo / BenchmarkAllocJSONP

Function BenchmarkAllocJSONP

context_test.go:36–49  ·  view source on GitHub ↗
(b *testing.B)

Source from the content-addressed store, hash-verified

34var testUser = user{ID: 1, Name: "Jon Snow"}
35
36func BenchmarkAllocJSONP(b *testing.B) {
37 e := New()
38 e.Logger = slog.New(slog.DiscardHandler)
39 req := httptest.NewRequest(http.MethodPost, "/", strings.NewReader(userJSON))
40 rec := httptest.NewRecorder()
41 c := e.NewContext(req, rec)
42
43 b.ResetTimer()
44 b.ReportAllocs()
45
46 for i := 0; i < b.N; i++ {
47 c.JSONP(http.StatusOK, "callback", testUser)
48 }
49}
50
51func BenchmarkAllocJSON(b *testing.B) {
52 e := New()

Callers

nothing calls this directly

Calls 3

JSONPMethod · 0.95
NewFunction · 0.85
NewContextMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…