MCPcopy
hub / github.com/gofiber/fiber / Benchmark_Bind_Query

Function Benchmark_Bind_Query

bind_test.go:1047–1071  ·  view source on GitHub ↗

go test -v -run=^$ -bench=Benchmark_Bind_Query -benchmem -count=4

(b *testing.B)

Source from the content-addressed store, hash-verified

1045
1046// go test -v -run=^$ -bench=Benchmark_Bind_Query -benchmem -count=4
1047func Benchmark_Bind_Query(b *testing.B) {
1048 var err error
1049
1050 app := New()
1051 c := app.AcquireCtx(&fasthttp.RequestCtx{})
1052
1053 type Query struct {
1054 Name string
1055 Hobby []string
1056 ID int
1057 }
1058 c.Request().SetBody([]byte(``))
1059 c.Request().Header.SetContentType("")
1060 c.Request().URI().SetQueryString("id=1&name=tom&hobby=basketball&hobby=football")
1061 q := new(Query)
1062 b.ReportAllocs()
1063 for b.Loop() {
1064 err = c.Bind().Query(q)
1065 }
1066
1067 require.NoError(b, err)
1068 require.Equal(b, "tom", q.Name)
1069 require.Equal(b, 1, q.ID)
1070 require.Len(b, q.Hobby, 2)
1071}
1072
1073// go test -v -run=^$ -bench=Benchmark_Bind_Query_Default -benchmem -count=4
1074func Benchmark_Bind_Query_Default(b *testing.B) {

Callers

nothing calls this directly

Calls 7

AcquireCtxMethod · 0.80
URIMethod · 0.80
NewFunction · 0.70
RequestMethod · 0.65
QueryMethod · 0.65
BindMethod · 0.65
LenMethod · 0.65

Tested by

no test coverage detected