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

Function Benchmark_Bind_Query_Default

bind_test.go:1074–1099  ·  view source on GitHub ↗

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

(b *testing.B)

Source from the content-addressed store, hash-verified

1072
1073// go test -v -run=^$ -bench=Benchmark_Bind_Query_Default -benchmem -count=4
1074func Benchmark_Bind_Query_Default(b *testing.B) {
1075 var err error
1076
1077 app := New()
1078 c := app.AcquireCtx(&fasthttp.RequestCtx{})
1079
1080 type Query struct {
1081 Name string `query:"name,default:tom"`
1082 Hobby []string `query:"hobby,default:football|basketball"`
1083 ID int `query:"id,default:1"`
1084 }
1085 c.Request().SetBody([]byte(``))
1086 c.Request().Header.SetContentType("")
1087 c.Request().URI().SetQueryString("")
1088 q := new(Query)
1089 b.ReportAllocs()
1090 for b.Loop() {
1091 *q = Query{}
1092 err = c.Bind().Query(q)
1093 }
1094
1095 require.NoError(b, err)
1096 require.Equal(b, "tom", q.Name)
1097 require.Equal(b, 1, q.ID)
1098 require.Len(b, q.Hobby, 2)
1099}
1100
1101// go test -v -run=^$ -bench=Benchmark_Bind_Query_Map -benchmem -count=4
1102func Benchmark_Bind_Query_Map(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