(b *testing.B)
| 82 | } |
| 83 | |
| 84 | func BenchmarkEncodeMap(b *testing.B) { |
| 85 | buf := [128]byte{} |
| 86 | msg := struct { |
| 87 | M map[string]string |
| 88 | }{ |
| 89 | M: map[string]string{ |
| 90 | "hello": "world", |
| 91 | }, |
| 92 | } |
| 93 | |
| 94 | size := Size(msg) |
| 95 | data := buf[:size] |
| 96 | b.SetBytes(int64(size)) |
| 97 | |
| 98 | for range b.N { |
| 99 | if _, err := MarshalTo(data, msg); err != nil { |
| 100 | b.Fatal(err) |
| 101 | } |
| 102 | } |
| 103 | } |
| 104 | |
| 105 | func BenchmarkEncodeSlice(b *testing.B) { |
| 106 | buf := [128]byte{} |