bmEncode benchmarks encoding a Protocol Buffer message containing mSize bytes.
(b *testing.B, mSize int)
| 346 | // bmEncode benchmarks encoding a Protocol Buffer message containing mSize |
| 347 | // bytes. |
| 348 | func bmEncode(b *testing.B, mSize int) { |
| 349 | cdc := getCodec(protoenc.Name) |
| 350 | msg := &perfpb.Buffer{Body: make([]byte, mSize)} |
| 351 | encodeData, _ := encode(cdc, msg) |
| 352 | encodedSz := int64(len(encodeData)) |
| 353 | b.ReportAllocs() |
| 354 | b.ResetTimer() |
| 355 | for i := 0; i < b.N; i++ { |
| 356 | encode(cdc, msg) |
| 357 | } |
| 358 | b.SetBytes(encodedSz) |
| 359 | } |
| 360 | |
| 361 | func BenchmarkEncode1B(b *testing.B) { |
| 362 | bmEncode(b, 1) |
no test coverage detected