MCPcopy Create free account
hub / github.com/quay/clair / BenchmarkDecode

Function BenchmarkDecode

internal/codec/codec_test.go:29–51  ·  view source on GitHub ↗
(b *testing.B)

Source from the content-addressed store, hash-verified

27}
28
29func BenchmarkDecode(b *testing.B) {
30 b.ReportAllocs()
31 want := map[string]string{
32 "a": strings.Repeat(`A`, 2048),
33 "b": strings.Repeat(`B`, 2048),
34 "c": strings.Repeat(`C`, 2048),
35 "d": strings.Repeat(`D`, 2048),
36 }
37 got := make(map[string]string, len(want))
38 b.ResetTimer()
39
40 for i := 0; i < b.N; i++ {
41 dec := GetDecoder(JSONReader(want))
42 err := dec.Decode(&got)
43 PutDecoder(dec)
44 if err != nil {
45 b.Error(err)
46 }
47 if !cmp.Equal(got, want) {
48 b.Error(cmp.Diff(got, want))
49 }
50 }
51}
52
53func BenchmarkDecodeStdlib(b *testing.B) {
54 b.ReportAllocs()

Callers

nothing calls this directly

Calls 4

GetDecoderFunction · 0.85
JSONReaderFunction · 0.85
PutDecoderFunction · 0.85
ErrorMethod · 0.45

Tested by

no test coverage detected