(b *testing.B)
| 27 | } |
| 28 | |
| 29 | func 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 | |
| 53 | func BenchmarkDecodeStdlib(b *testing.B) { |
| 54 | b.ReportAllocs() |
nothing calls this directly
no test coverage detected