grpc: Index | Files | Directories

package benchmark

import ""

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


Package Files



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.

func DoByteBufStreamingRoundTrip Uses

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

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

func DoStreamingRoundTrip Uses

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

DoStreamingRoundTrip performs a round trip for a single streaming rpc.

func DoUnaryCall Uses

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

DoUnaryCall performs an unary RPC with given stub and request and response sizes.

func NewClientConn Uses

func NewClientConn(addr string, opts ...grpc.DialOption) *grpc.ClientConn

NewClientConn creates a gRPC client connection to addr.

func NewClientConnWithContext Uses

func NewClientConnWithContext(ctx context.Context, addr string, opts ...grpc.DialOption) *grpc.ClientConn

NewClientConnWithContext creates a gRPC client connection to addr using ctx.

func NewPayload Uses

func NewPayload(t testpb.PayloadType, size int) *testpb.Payload

NewPayload creates a payload with the given type and size.

func StartServer Uses

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.

type ServerInfo Uses

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

    // Listener is the network listener for the server to use
    Listener net.Listener

ServerInfo contains the information to create a gRPC benchmark server.


benchmainPackage main provides benchmark with setting flags.
benchresultTo format the benchmark result: go run benchmark/benchresult/main.go resultfile
clientPackage main provides a client used for benchmarking.
flagsPackage flags provide convenience types and routines to accept specific types of flag values on the command line.
latencyPackage latency provides wrappers for net.Conn, net.Listener, and net.Dialers, designed to interoperate to inject real-world latency into network connections.
serverPackage main provides a server used for benchmarking.
statsPackage stats tracks the statistics associated with benchmark runs.
workerBinary worker implements the benchmark worker that can turn into a benchmark client or server.

Package benchmark imports 11 packages (graph) and is imported by 170 packages. Updated 2021-01-13. Refresh now. Tools for package owners.