Search and commands

↑ ↓ to select · Enter to open · Esc to close

Type to search packages.

benchmark

v1.6.0
github.com/ppg/grpc-go/benchmark

Documentation

pkg.go.dev ↗

Table of contents

↓ to select · Enter to jump· Shift+Enter for source

11 matches

Top ↑

Package benchmark implements the building blocks to setup end-to-end gRPC benchmarks.

Functions

AddOne

func AddOne(features []int, featuresMaxPosition []int)

AddOne add 1 to the features slice

DoByteBufStreamingRoundTrip

func DoByteBufStreamingRoundTrip(stream testpb.BenchmarkService_StreamingCallClient, reqSize, respSize int) error

DoByteBufStreamingRoundTrip performs a round trip for a single streaming rpc, using a custom codec for byte buffer.

DoStreamingRoundTrip

func DoStreamingRoundTrip(stream testpb.BenchmarkService_StreamingCallClient, reqSize, respSize int) error

DoStreamingRoundTrip performs a round trip for a single streaming rpc.

DoUnaryCall

func DoUnaryCall(tc testpb.BenchmarkServiceClient, reqSize, respSize int) error

DoUnaryCall performs an 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.

StartServer

func StartServer(info ServerInfo, opts ...grpc.ServerOption) (string, func())

StartServer starts a gRPC server serving a benchmark service according to info. It returns its listen address and a function to stop the server.

Types

Features

type Features struct {
	EnableTrace        bool
	Latency            time.Duration
	Kbps               int
	Mtu                int
	MaxConcurrentCalls int
	ReqSizeBytes       int
	RespSizeBytes      int
	EnableCompressor   bool
}

Features contains most fields for a benchmark

Features.String

func (f Features) String() string

ServerInfo

type ServerInfo struct {
	// Addr is the address of the server.
	Addr string

	// 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 interface{}

	// Network can simulate latency
	Network *latency.Network
}

ServerInfo contains the information to create a gRPC benchmark server.

Dependency graph