benchmark
v1.85.0
Documentation
pkg.go.dev ↗Package benchmark implements the building blocks to setup end-to-end gRPC benchmarks.
Constants
PreloadMsgSizeHeader
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.
UnconstrainedStreamingDelayHeader
const UnconstrainedStreamingDelayHeader = "unconstrained-streaming-delay"
UnconstrainedStreamingDelayHeader is used to pass the maximum amount of time the server should sleep between consecutive RPC responses.
UnconstrainedStreamingHeader
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
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.
DoStreamingRoundTrip
func DoStreamingRoundTrip(stream testgrpc.BenchmarkService_StreamingCallClient, reqSize, respSize int) error
DoStreamingRoundTrip performs a round trip for a single streaming rpc.
DoStreamingRoundTripPreloaded
func DoStreamingRoundTripPreloaded(stream testgrpc.BenchmarkService_StreamingCallClient, req any) error
DoStreamingRoundTripPreloaded performs a round trip for a single streaming rpc with preloaded payload.
DoUnaryCall
func DoUnaryCall(tc testgrpc.BenchmarkServiceClient, reqSize, respSize int) error
DoUnaryCall performs a unary RPC with given stub and request and response sizes.
NewClientConn
func NewClientConn(addr string, opts ...grpc.DialOption) *grpc.ClientConn
NewClientConn creates a gRPC client connection to addr.
NewClientConnWithContext
func NewClientConnWithContext(_ context.Context, addr string, opts ...grpc.DialOption) *grpc.ClientConn
NewClientConnWithContext creates a gRPC client connection to addr using ctx.
NewPayload
func NewPayload(t testpb.PayloadType, size int) *testpb.Payload
NewPayload creates a payload with the given type and size.
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
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.