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

Function BenchmarkHandleRPC_InPayload

middleware/grpc_stats_bench_test.go:36–54  ·  view source on GitHub ↗

BenchmarkHandleRPC_InPayload measures the per-message hot path for incoming payloads on a streaming RPC (the dominant case in QueryStream).

(b *testing.B)

Source from the content-addressed store, hash-verified

34// BenchmarkHandleRPC_InPayload measures the per-message hot path for incoming
35// payloads on a streaming RPC (the dominant case in QueryStream).
36func BenchmarkHandleRPC_InPayload(b *testing.B) {
37 h := newBenchStatsHandler(b)
38 const method = "/cortex.Querier/QueryStream"
39
40 // Simulate stream open: TagRPC stores the method name in ctx.
41 ctx := h.TagRPC(context.Background(), &stats.RPCTagInfo{FullMethodName: method})
42
43 // Simulate Begin (stream open).
44 h.HandleRPC(ctx, &stats.Begin{})
45
46 inPayload := &stats.InPayload{WireLength: 4096}
47
48 b.ResetTimer()
49 b.ReportAllocs()
50
51 for i := 0; i < b.N; i++ {
52 h.HandleRPC(ctx, inPayload)
53 }
54}
55
56// BenchmarkHandleRPC_OutPayload measures the per-message hot path for outgoing
57// payloads (server-side streaming responses).

Callers

nothing calls this directly

Calls 3

newBenchStatsHandlerFunction · 0.85
TagRPCMethod · 0.45
HandleRPCMethod · 0.45

Tested by

no test coverage detected