MCPcopy
hub / github.com/grpc/grpc-go / bmEncode

Function bmEncode

rpc_util_test.go:348–359  ·  view source on GitHub ↗

bmEncode benchmarks encoding a Protocol Buffer message containing mSize bytes.

(b *testing.B, mSize int)

Source from the content-addressed store, hash-verified

346// bmEncode benchmarks encoding a Protocol Buffer message containing mSize
347// bytes.
348func 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
361func BenchmarkEncode1B(b *testing.B) {
362 bmEncode(b, 1)

Callers 6

BenchmarkEncode1BFunction · 0.85
BenchmarkEncode1KiBFunction · 0.85
BenchmarkEncode8KiBFunction · 0.85
BenchmarkEncode64KiBFunction · 0.85
BenchmarkEncode512KiBFunction · 0.85
BenchmarkEncode1MiBFunction · 0.85

Calls 2

getCodecFunction · 0.85
encodeFunction · 0.85

Tested by

no test coverage detected