MCPcopy Index your code
hub / github.com/dunglas/httpsfv / BenchmarkSerializingOfficialExamples

Function BenchmarkSerializingOfficialExamples

httpwg_test.go:224–254  ·  view source on GitHub ↗
(b *testing.B)

Source from the content-addressed store, hash-verified

222}
223
224func BenchmarkSerializingOfficialExamples(b *testing.B) {
225 file, _ := os.Open("structured-field-tests/examples.json")
226 dec := json.NewDecoder(file)
227 dec.UseNumber()
228
229 var tests []test
230 _ = dec.Decode(&tests)
231
232 var sfv []StructuredFieldValue
233
234 for _, te := range tests {
235 if te.CanFail || te.MustFail {
236 continue
237 }
238
239 switch te.HeaderType {
240 case ITEM:
241 sfv = append(sfv, valToItem(te.Expected))
242 case LIST:
243 sfv = append(sfv, valToList(te.Expected))
244 case DICTIONARY:
245 sfv = append(sfv, valToDictionary(te.Expected))
246 }
247 }
248
249 for n := 0; n < b.N; n++ {
250 for _, v := range sfv {
251 _, _ = Marshal(v)
252 }
253 }
254}
255
256func TestOfficialTestSuiteSerialization(t *testing.T) {
257 t.Parallel()

Callers

nothing calls this directly

Calls 4

valToItemFunction · 0.85
valToListFunction · 0.85
valToDictionaryFunction · 0.85
MarshalFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…