MCPcopy
hub / github.com/grafana/dskit / BenchmarkHandleRPC_StreamRoundTrip

Function BenchmarkHandleRPC_StreamRoundTrip

middleware/grpc_stats_bench_test.go:77–98  ·  view source on GitHub ↗

BenchmarkHandleRPC_StreamRoundTrip simulates a full streaming round-trip: Begin, N×(InPayload + OutPayload), End — matching QueryStream traffic.

(b *testing.B)

Source from the content-addressed store, hash-verified

75// BenchmarkHandleRPC_StreamRoundTrip simulates a full streaming round-trip:
76// Begin, N×(InPayload + OutPayload), End — matching QueryStream traffic.
77func BenchmarkHandleRPC_StreamRoundTrip(b *testing.B) {
78 h := newBenchStatsHandler(b)
79 const method = "/cortex.Querier/QueryStream"
80 const msgsPerStream = 50 // typical number of chunks per query
81
82 ctx := h.TagRPC(context.Background(), &stats.RPCTagInfo{FullMethodName: method})
83
84 inPayload := &stats.InPayload{WireLength: 512}
85 outPayload := &stats.OutPayload{WireLength: 8192}
86
87 b.ResetTimer()
88 b.ReportAllocs()
89
90 for i := 0; i < b.N; i++ {
91 h.HandleRPC(ctx, &stats.Begin{})
92 for j := 0; j < msgsPerStream; j++ {
93 h.HandleRPC(ctx, inPayload)
94 h.HandleRPC(ctx, outPayload)
95 }
96 h.HandleRPC(ctx, &stats.End{})
97 }
98}

Callers

nothing calls this directly

Calls 3

newBenchStatsHandlerFunction · 0.85
TagRPCMethod · 0.45
HandleRPCMethod · 0.45

Tested by

no test coverage detected