package benchmark
import "google.golang.org/grpc/benchmark"
Package benchmark implements the building blocks to setup end-to-end gRPC benchmarks.
Index ¶
- Constants
- func DoByteBufStreamingRoundTrip(stream testgrpc.BenchmarkService_StreamingCallClient, reqSize, _ int) error
- func DoStreamingRoundTrip(stream testgrpc.BenchmarkService_StreamingCallClient, reqSize, respSize int) error
- func DoStreamingRoundTripPreloaded(stream testgrpc.BenchmarkService_StreamingCallClient, req any) error
- func DoUnaryCall(tc testgrpc.BenchmarkServiceClient, reqSize, respSize int) error
- func NewClientConn(addr string, opts ...grpc.DialOption) *grpc.ClientConn
- func NewClientConnWithContext(_ context.Context, addr string, opts ...grpc.DialOption) *grpc.ClientConn
- func NewPayload(t testpb.PayloadType, size int) *testpb.Payload
- func StartServer(info ServerInfo, opts ...grpc.ServerOption) func()
- type ServerInfo
Constants ¶
const PreloadMsgSizeHeader = "preload-msg-size"
PreloadMsgSizeHeader indicates that the client is going to ask for a fixed response size and passes this size to the server. The server is expected to preload the response on startup.
const UnconstrainedStreamingDelayHeader = "unconstrained-streaming-delay"
UnconstrainedStreamingDelayHeader is used to pass the maximum amount of time the server should sleep between consecutive RPC responses.
const UnconstrainedStreamingHeader = "unconstrained-streaming"
UnconstrainedStreamingHeader indicates to the StreamingCall handler that its behavior should be unconstrained (constant send/receive in parallel) instead of ping-pong.
Functions ¶
func DoByteBufStreamingRoundTrip ¶
func DoByteBufStreamingRoundTrip(stream testgrpc.BenchmarkService_StreamingCallClient, reqSize, _ int) error
DoByteBufStreamingRoundTrip performs a round trip for a single streaming rpc, using a custom codec for byte buffer.
func DoStreamingRoundTrip ¶
func DoStreamingRoundTrip(stream testgrpc.BenchmarkService_StreamingCallClient, reqSize, respSize int) error
DoStreamingRoundTrip performs a round trip for a single streaming rpc.
func DoStreamingRoundTripPreloaded ¶
func DoStreamingRoundTripPreloaded(stream testgrpc.BenchmarkService_StreamingCallClient, req any) error
DoStreamingRoundTripPreloaded performs a round trip for a single streaming rpc with preloaded payload.
func DoUnaryCall ¶
func DoUnaryCall(tc testgrpc.BenchmarkServiceClient, reqSize, respSize int) error
DoUnaryCall performs a unary RPC with given stub and request and response sizes.
func NewClientConn ¶
func NewClientConn(addr string, opts ...grpc.DialOption) *grpc.ClientConn
NewClientConn creates a gRPC client connection to addr.
func NewClientConnWithContext ¶
func NewClientConnWithContext(_ context.Context, addr string, opts ...grpc.DialOption) *grpc.ClientConn
NewClientConnWithContext creates a gRPC client connection to addr using ctx.
func NewPayload ¶
func NewPayload(t testpb.PayloadType, size int) *testpb.Payload
NewPayload creates a payload with the given type and size.
func StartServer ¶
func StartServer(info ServerInfo, opts ...grpc.ServerOption) func()
StartServer starts a gRPC server serving a benchmark service according to info. It returns a function to stop the server.
Types ¶
type ServerInfo ¶
type ServerInfo struct {
// Type is the type of the server.
// It should be "protobuf" or "bytebuf".
Type string
// Metadata is an optional configuration.
// For "protobuf", it's ignored.
// For "bytebuf", it should be an int representing response size.
Metadata any
// Listener is the network listener for the server to use
Listener net.Listener
}
ServerInfo contains the information to create a gRPC benchmark server.
Source Files ¶
benchmark.go
Directories ¶
| Path | Synopsis |
|---|---|
| benchmark/benchmain | Package main provides benchmark with setting flags. |
| benchmark/benchresult | To format the benchmark result: |
| benchmark/client | Package main provides a client used for benchmarking. |
| benchmark/flags | Package flags provide convenience types and routines to accept specific types of flag values on the command line. |
| benchmark/latency | Package latency provides wrappers for net.Conn, net.Listener, and net.Dialers, designed to interoperate to inject real-world latency into network connections. |
| benchmark/primitives | |
| benchmark/server | Package main provides a server used for benchmarking. |
| benchmark/stats | Package stats tracks the statistics associated with benchmark runs. |
| benchmark/worker | Binary worker implements the benchmark worker that can turn into a benchmark client or server. |
- Version
- v1.78.0-dev
- Published
- Oct 30, 2025
- Platform
- windows/amd64
- Imports
- 14 packages
- Last checked
- 44 seconds ago –
Tools for package owners.