MCPcopy
hub / github.com/danielgtaylor/huma / BenchmarkValidate_Complex

Function BenchmarkValidate_Complex

bench_test.go:116–150  ·  view source on GitHub ↗
(b *testing.B)

Source from the content-addressed store, hash-verified

114}
115
116func BenchmarkValidate_Complex(b *testing.B) {
117 registry := huma.NewMapRegistry("#/components/schemas/", huma.DefaultSchemaNamer)
118 s := huma.SchemaFromType(registry, reflect.TypeFor[BenchComplex]())
119
120 input := map[string]any{
121 "string": "Hello World",
122 "int": 500,
123 "float": 0.5,
124 "bool": true,
125 "time": time.Now().Format(time.RFC3339),
126 "slice": []any{"a", "b", "c"},
127 "sub": map[string]any{
128 "id": 5,
129 "name": "Testing",
130 },
131 "sub_slice": []any{
132 map[string]any{"id": 1, "name": "One"},
133 map[string]any{"id": 2, "name": "Two"},
134 },
135 "map": map[string]any{
136 "key1": map[string]any{"id": 10, "name": "Ten"},
137 },
138 }
139
140 pb := huma.NewPathBuffer(make([]byte, 0, 256), 0)
141 res := &huma.ValidateResult{}
142
143 b.ResetTimer()
144 b.ReportAllocs()
145 for i := 0; i < b.N; i++ {
146 pb.Reset()
147 res.Reset()
148 huma.Validate(registry, s, pb, huma.ModeWriteToServer, input, res)
149 }
150}
151
152func BenchmarkRegister(b *testing.B) {
153 _, api := humatest.New(b, huma.DefaultConfig("Test API", "1.0.0"))

Callers

nothing calls this directly

Calls 3

ResetMethod · 0.95
ResetMethod · 0.95
ValidateMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…