benchmark

package
v0.0.0-...-b45fe33 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 17, 2024 License: MIT Imports: 28 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidSuiteType = errors.New("invalid suite type")

ErrInvalidSuiteType is returned when an unsupported SuiteType is provided.

Functions

func GetMemoryUsage

func GetMemoryUsage() uint64

GetMemoryUsage captures the current memory usage in bytes.

Types

type DummySuite

type DummySuite struct {
	// contains filtered or unexported fields
}

DummySuite represents the benchmarking suite with buffer reuse and lighter LatencyHistogram.

func NewDummySuite

func NewDummySuite(fdb *fdb.FDB, latencySampling int) *DummySuite

NewDummySuite initializes the DummySuite with buffer reuse and latency sampling settings.

func (*DummySuite) AcquireClient

func (ds *DummySuite) AcquireClient() (*net.UDPConn, error)

AcquireClient creates and returns a new UDP client.

func (*DummySuite) RunReadBenchmark

func (ds *DummySuite) RunReadBenchmark(ctx context.Context, numClients int, numMessagesPerClient int, report *Report) error

RunReadBenchmark benchmarks reading messages from the Dummy server.

func (*DummySuite) RunWriteBenchmark

func (ds *DummySuite) RunWriteBenchmark(ctx context.Context, numClients int, numMessagesPerClient int, report *Report) error

RunWriteBenchmark benchmarks writing messages through the Dummy server.

func (*DummySuite) Start

func (ds *DummySuite) Start(ctx context.Context) error

Start starts the Dummy server for benchmarking.

func (*DummySuite) Stop

func (ds *DummySuite) Stop(ctx context.Context) error

Stop stops the Dummy server and closes the client connection and stream.

type QuicSuite

type QuicSuite struct {
	// contains filtered or unexported fields
}

QuicSuite represents the QUIC-specific benchmark suite.

func NewQuicSuite

func NewQuicSuite(fdb *fdb.FDB, latencySampling int) *QuicSuite

NewQuicSuite initializes the QuicSuite with buffer reuse and latency sampling settings.

func (*QuicSuite) AcquireClient

func (qs *QuicSuite) AcquireClient(ctx context.Context) (quic.Connection, quic.Stream, error)

AcquireClient sets up a QUIC client and stream.

func (*QuicSuite) RunReadBenchmark

func (qs *QuicSuite) RunReadBenchmark(ctx context.Context, numClients int, numMessagesPerClient int, report *Report) error

RunReadBenchmark benchmarks reading messages from the QUIC server.

func (*QuicSuite) RunWriteBenchmark

func (qs *QuicSuite) RunWriteBenchmark(ctx context.Context, numClients int, numMessagesPerClient int, report *Report) error

RunWriteBenchmark benchmarks writing messages through the QUIC server.

func (*QuicSuite) Start

func (qs *QuicSuite) Start(ctx context.Context) error

Start starts the QUIC server for benchmarking.

func (*QuicSuite) Stop

func (qs *QuicSuite) Stop(ctx context.Context) error

Stop stops the QUIC server and closes the client connection and stream.

type Report

type Report struct {
	TotalClients      int             `json:"total_clients"`
	MessagesPerClient int             `json:"messages_per_client"`
	TotalMessages     int             `json:"total_messages"`
	SuccessMessages   int             `json:"success_messages"`
	FailedMessages    int             `json:"failed_messages"`
	TotalDuration     time.Duration   `json:"total_duration"`
	AvgLatency        time.Duration   `json:"avg_latency"`
	Throughput        float64         `json:"throughput"` // Messages per second
	MemoryUsed        uint64          `json:"memory_used"`
	LatencyHistogram  []time.Duration `json:"latency_histogram"`
	Jitter            float64         `json:"jitter"`          // Latency jitter (standard deviation)
	LatencyStdDev     float64         `json:"latency_std_dev"` // Standard deviation of latencies
	P50Latency        time.Duration   `json:"p50_latency"`     // 50th percentile (median)
	P90Latency        time.Duration   `json:"p90_latency"`     // 90th percentile
	P99Latency        time.Duration   `json:"p99_latency"`     // 99th percentile
}

Report holds the results of the benchmark.

func NewReport

func NewReport() *Report

NewReport creates a new benchmark report.

func (*Report) ExportToJSON

func (r *Report) ExportToJSON(filename string) error

ExportToJSON exports the benchmark report to a JSON file.

func (*Report) Finalize

func (r *Report) Finalize()

Finalize aggregates the latency data and updates the benchmark report.

func (*Report) PrintReport

func (r *Report) PrintReport()

PrintReport prints the benchmark report to the console.

type SuiteManager

type SuiteManager struct {
	Suites map[SuiteType]TransportSuite
	// contains filtered or unexported fields
}

SuiteManager manages multiple benchmarking suites for different transport types.

func NewSuiteManager

func NewSuiteManager(fdb *fdb.FDB) *SuiteManager

NewSuiteManager creates a new SuiteManager capable of managing multiple transport-specific suites.

func (*SuiteManager) RegisterSuite

func (sm *SuiteManager) RegisterSuite(suiteType SuiteType, suite TransportSuite)

RegisterSuite registers a transport-specific suite with the manager.

func (*SuiteManager) RunReadBenchmark

func (sm *SuiteManager) RunReadBenchmark(ctx context.Context, suiteType SuiteType, numClients int, numMessagesPerClient int, report *Report) error

RunReadBenchmark executes the read benchmarking logic for the specified SuiteType.

func (*SuiteManager) RunWriteBenchmark

func (sm *SuiteManager) RunWriteBenchmark(ctx context.Context, suiteType SuiteType, numClients int, numMessagesPerClient int, report *Report) error

RunWriteBenchmark executes the write benchmarking logic for the specified SuiteType.

func (*SuiteManager) Start

func (sm *SuiteManager) Start(ctx context.Context, suiteType SuiteType) error

Start starts the suite for the specified SuiteType.

func (*SuiteManager) Stop

func (sm *SuiteManager) Stop(ctx context.Context, suiteType SuiteType) error

Stop stops the suite for the specified SuiteType.

type SuiteType

type SuiteType string

SuiteType represents different types of benchmarking suites (e.g., QUIC, UDS, etc.)

const (
	QUICSuite      SuiteType = "quic"
	UDSSuiteType   SuiteType = "uds" // Example for future transport suites
	TCPSuiteType   SuiteType = "tcp"
	UDPSuiteType   SuiteType = "udp"
	DummySuiteType SuiteType = "dummy"
)

type TcpSuite

type TcpSuite struct {
	// contains filtered or unexported fields
}

TcpSuite represents the benchmarking suite for TCP with buffer reuse and latency sampling.

func NewTcpSuite

func NewTcpSuite(fdb *fdb.FDB, latencySampling int) *TcpSuite

NewTcpSuite initializes the TcpSuite with buffer reuse and latency sampling settings.

func (*TcpSuite) AcquireClient

func (ts *TcpSuite) AcquireClient() (*net.TCPConn, error)

AcquireClient creates and returns a new TCP client.

func (*TcpSuite) RunReadBenchmark

func (ts *TcpSuite) RunReadBenchmark(ctx context.Context, numClients int, numMessagesPerClient int, report *Report) error

RunReadBenchmark benchmarks reading messages from the TCP server.

func (*TcpSuite) RunWriteBenchmark

func (ts *TcpSuite) RunWriteBenchmark(ctx context.Context, numClients int, numMessagesPerClient int, report *Report) error

RunWriteBenchmark benchmarks writing messages through the TCP server.

func (*TcpSuite) Start

func (ts *TcpSuite) Start(ctx context.Context) error

Start starts the TCP server for benchmarking.

func (*TcpSuite) Stop

func (ts *TcpSuite) Stop(ctx context.Context) error

Stop stops the TCP server and closes the client connection.

type TransportSuite

type TransportSuite interface {
	Start(ctx context.Context) error
	Stop(ctx context.Context) error
	RunWriteBenchmark(ctx context.Context, numClients int, numMessagesPerClient int, report *Report) error
	RunReadBenchmark(ctx context.Context, numClients int, numMessagesPerClient int, report *Report) error
}

TransportSuite defines a common interface that all transport-specific suites must implement.

type UdpSuite

type UdpSuite struct {
	// contains filtered or unexported fields
}

UdpSuite represents the benchmarking suite for UDP with buffer reuse and latency sampling.

func NewUdpSuite

func NewUdpSuite(fdb *fdb.FDB, latencySampling int) *UdpSuite

NewUdpSuite initializes the UdpSuite with buffer reuse and latency sampling settings.

func (*UdpSuite) AcquireClient

func (us *UdpSuite) AcquireClient() (*net.UDPConn, error)

AcquireClient creates and returns a new UDP client.

func (*UdpSuite) RunReadBenchmark

func (us *UdpSuite) RunReadBenchmark(ctx context.Context, numClients int, numMessagesPerClient int, report *Report) error

RunReadBenchmark benchmarks reading messages from the UDP server.

func (*UdpSuite) RunWriteBenchmark

func (us *UdpSuite) RunWriteBenchmark(ctx context.Context, numClients int, numMessagesPerClient int, report *Report) error

RunWriteBenchmark benchmarks writing messages through the UDP server.

func (*UdpSuite) Start

func (us *UdpSuite) Start(ctx context.Context) error

Start starts the UDP server for benchmarking.

func (*UdpSuite) Stop

func (us *UdpSuite) Stop(ctx context.Context) error

Stop stops the UDP server and closes the client connection.

type UdsSuite

type UdsSuite struct {
	// contains filtered or unexported fields
}

UdsSuite represents the benchmarking suite for UDS with buffer reuse and latency sampling.

func NewUdsSuite

func NewUdsSuite(fdb *fdb.FDB, latencySampling int) *UdsSuite

NewUdsSuite initializes the UdsSuite with buffer reuse and latency sampling settings.

func (*UdsSuite) AcquireClient

func (us *UdsSuite) AcquireClient() (*net.UnixConn, error)

AcquireClient creates and returns a new UDS client.

func (*UdsSuite) RunReadBenchmark

func (us *UdsSuite) RunReadBenchmark(ctx context.Context, numClients int, numMessagesPerClient int, report *Report) error

RunReadBenchmark benchmarks reading messages from the UDS server.

func (*UdsSuite) RunWriteBenchmark

func (us *UdsSuite) RunWriteBenchmark(ctx context.Context, numClients int, numMessagesPerClient int, report *Report) error

RunWriteBenchmark benchmarks writing messages through the UDS server.

func (*UdsSuite) Start

func (us *UdsSuite) Start(ctx context.Context) error

Start starts the UDS server for benchmarking.

func (*UdsSuite) Stop

func (us *UdsSuite) Stop(ctx context.Context) error

Stop stops the UDS server and closes the client connection.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL