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

Function BenchmarkReadMemoryUsage

credentials/alts/internal/conn/record_test.go:397–411  ·  view source on GitHub ↗

BenchmarkReadMemoryUsage measures the allocations per ALTS connection. Run this with: go test -bench=BenchmarkReadMemoryUsage -benchmem

(b *testing.B)

Source from the content-addressed store, hash-verified

395// BenchmarkReadMemoryUsage measures the allocations per ALTS connection.
396// Run this with: go test -bench=BenchmarkReadMemoryUsage -benchmem
397func BenchmarkReadMemoryUsage(b *testing.B) {
398 b.ReportAllocs()
399 data := []byte(strings.Repeat("d", 257))
400 readBuf := make([]byte, 1024)
401
402 for b.Loop() {
403 clientConn, serverConn := newConnPair(rekeyRecordProtocol, nil, nil)
404 b.StopTimer()
405 clientConn.Write(data)
406 b.StartTimer()
407 if _, err := serverConn.Read(readBuf); err != nil {
408 b.Fatalf("Write failed: %v", err)
409 }
410 }
411}
412
413type noopConn struct {
414 net.Conn

Callers

nothing calls this directly

Calls 4

newConnPairFunction · 0.85
WriteMethod · 0.65
ReadMethod · 0.65
FatalfMethod · 0.65

Tested by

no test coverage detected