Documentation
¶
Index ¶
- Variables
- func CreateClients(tb testing.TB, numConn int, clientConfPath string) ([]*benchmark.ViewClient, func())
- func CreateRemoteClients(numConn int, clientConfPath string) ([]*benchmark.ViewClient, func())
- func GenerateConfig(testdataDir string) error
- func MakeGRPCCaller(tb testing.TB, cli *benchmark.ViewClient, fid string, input []byte) func(ctx context.Context) error
- func MakeRemoteGRPCCaller(cli *benchmark.ViewClient, fid string, input []byte) func(ctx context.Context) error
- func MarshalWorkloadParams(params any) []byte
- func Percentile(p float64, h *stats.Histogram) int64
- func PrintHistogram(hist *stats.Histogram, duration time.Duration)
- func RunAPIBenchmark(b *testing.B, vm ViewManager, wl Workload)
- func RunAPIGRPCBenchmark(b *testing.B, wl Workload, clientConfPath string, connCounts []int)
- func RunGRPCBenchmark(b *testing.B, ccs []*benchmark.ViewClient, ...)
- func RunRemoteBenchmark(ccs []*benchmark.ViewClient, ...) *stats.Histogram
- func RunRemoteBenchmarkSuite(cfg RemoteBenchmarkConfig)
- func SetupClient(confPath string) (*benchmark.ViewClient, func(), error)
- func SetupNode(confPath string, factories ...NamedFactory) (*node.Node, error)
- func WarmupClients(ccs []*benchmark.ViewClient, ...) error
- type NamedFactory
- type RemoteBenchmarkConfig
- type ViewManager
- type Workload
Constants ¶
This section is empty.
Variables ¶
var DefaultWorkloads = []Workload{ { Name: "noop", Factory: &views.NoopViewFactory{}, }, { Name: "cpu", Factory: &views.CPUViewFactory{}, Params: &views.CPUParams{N: 200000}, }, { Name: "sign", Factory: &views.ECDSASignViewFactory{}, Params: &views.ECDSASignParams{}, }, }
DefaultWorkloads defines the standard set of benchmark workloads.
var HistogramOptions = stats.HistogramOptions{
NumBuckets: 2495,
GrowthFactor: .01,
}
HistogramOptions are the default bucket settings for latency histograms used by deadline-driven (remote) benchmarks.
Functions ¶
func CreateClients ¶ added in v0.9.0
func CreateClients(tb testing.TB, numConn int, clientConfPath string) ([]*benchmark.ViewClient, func())
CreateClients creates numConn ViewClients using the given client config path. It returns the clients and a cleanup function that closes all connections.
func CreateRemoteClients ¶ added in v0.9.0
func CreateRemoteClients(numConn int, clientConfPath string) ([]*benchmark.ViewClient, func())
CreateRemoteClients creates numConn ViewClients for remote benchmarks. Unlike CreateClients (which takes testing.TB), this panics on errors since it runs outside of `go test`.
func GenerateConfig ¶
func MakeGRPCCaller ¶ added in v0.9.0
func MakeGRPCCaller(tb testing.TB, cli *benchmark.ViewClient, fid string, input []byte) func(ctx context.Context) error
MakeGRPCCaller creates a caller function that sends a signed gRPC command for the given workload name and input. The signed command is created once and reused across all calls for efficiency.
func MakeRemoteGRPCCaller ¶ added in v0.9.0
func MakeRemoteGRPCCaller(cli *benchmark.ViewClient, fid string, input []byte) func(ctx context.Context) error
MakeRemoteGRPCCaller creates a caller function for deadline-driven (remote) benchmarks. Unlike MakeGRPCCaller (which takes testing.TB), this version panics on setup errors since it runs outside of `go test`.
func MarshalWorkloadParams ¶ added in v0.9.0
MarshalWorkloadParams marshals workload params to JSON. Returns nil if params is nil.
func Percentile ¶ added in v0.9.0
Percentile computes the given percentile (0.0–1.0) from a histogram.
func PrintHistogram ¶ added in v0.9.0
PrintHistogram formats and prints benchmark results from a histogram, including TPS and latency percentiles (p5, p95, p99).
Output format matches Go's testing.BenchmarkResult so it can be parsed by standard benchmark tooling.
func RunAPIBenchmark ¶ added in v0.9.0
func RunAPIBenchmark(b *testing.B, vm ViewManager, wl Workload)
RunAPIBenchmark runs a direct View API benchmark for a single workload against the given view manager. It creates two sub-benchmarks:
- f=0: reuses a single view instance per goroutine (measures pure view performance)
- f=1: creates a new view per invocation (measures view + factory overhead)
func RunAPIGRPCBenchmark ¶ added in v0.9.0
RunAPIGRPCBenchmark runs a gRPC View API benchmark for a single workload across multiple connection counts. It handles client creation, warmup, and cleanup.
func RunGRPCBenchmark ¶ added in v0.9.0
func RunGRPCBenchmark(b *testing.B, ccs []*benchmark.ViewClient, makeCaller func(cli *benchmark.ViewClient) func(ctx context.Context) error)
RunGRPCBenchmark runs a parallel benchmark over multiple ViewClients using round-robin caller selection. This is the core gRPC benchmark loop used by both local and remote node benchmarks.
func RunRemoteBenchmark ¶ added in v0.9.0
func RunRemoteBenchmark( ccs []*benchmark.ViewClient, makeCaller func(cli *benchmark.ViewClient) func(ctx context.Context) error, numWorker int, warmDeadline, endDeadline time.Time, ) *stats.Histogram
RunRemoteBenchmark runs a deadline-driven benchmark across multiple ViewClients. Unlike RunGRPCBenchmark (which uses testing.B), this uses explicit warmup and measurement phases with histogram-based latency collection.
It returns the merged histogram of all workers. Callers typically pass the result to PrintHistogram().
func RunRemoteBenchmarkSuite ¶ added in v0.9.0
func RunRemoteBenchmarkSuite(cfg RemoteBenchmarkConfig)
RunRemoteBenchmarkSuite runs the full remote benchmark loop: workloads × connection counts × worker counts × count.
func SetupClient ¶
func SetupClient(confPath string) (*benchmark.ViewClient, func(), error)
func WarmupClients ¶
func WarmupClients(ccs []*benchmark.ViewClient, makeCaller func(*benchmark.ViewClient) func(ctx context.Context) error) error
Types ¶
type NamedFactory ¶
type NamedFactory struct {
Name string
Factory viewregistry.Factory
}
type RemoteBenchmarkConfig ¶ added in v0.9.0
type RemoteBenchmarkConfig struct {
Workloads []Workload
ClientConfPath string
ConnCounts []int // number of gRPC connections to test
WorkerCounts []int // number of concurrent workers to test
WarmupDur time.Duration
BenchTime time.Duration
Count int // number of executions per configuration
BenchName string // prefix for output lines, e.g. "BenchmarkAPIGRPCRemote"
}
RemoteBenchmarkConfig holds all parameters for a remote benchmark suite.
type ViewManager ¶ added in v0.9.0
type ViewManager interface {
NewView(id string, in []byte) (view.View, error)
InitiateView(view view.View, ctx context.Context) (interface{}, error)
}
ViewManager is the minimal interface needed for API benchmarks. It is satisfied by the value returned from viewregistry.GetManager().