BenchmarkReadMemoryUsage measures the allocations per ALTS connection. Run this with: go test -bench=BenchmarkReadMemoryUsage -benchmem
(b *testing.B)
| 395 | // BenchmarkReadMemoryUsage measures the allocations per ALTS connection. |
| 396 | // Run this with: go test -bench=BenchmarkReadMemoryUsage -benchmem |
| 397 | func 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 | |
| 413 | type noopConn struct { |
| 414 | net.Conn |
nothing calls this directly
no test coverage detected