Documentation
¶
Overview ¶
the runner code for running a benchmarking process, either in dial or listen mode
note that this benchmark runner codebase is not written using best practices but more as a quick iteration of the original benchmark code (which itself is based on the echo example), with the goal of being able to run it as a single benchmark, as well as using the orchestraed runner script used to generate all the results in the README found in the parent folder.
This code is a fork of https://github.com/little-bear-labs/libp2p-webrtc-bench to make sure benchmarks are reproducable, and that code itself is a fork of https://github.com/libp2p/go-libp2p/blob/d5a280e6f6ca48eb99ba9140707c4fad54207c76/examples/echo/main.go
Index ¶
- Constants
- func PrintMetricStats(metricsMapping map[string][]Metric, activeStreams uint32)
- func Run(ctx context.Context, cfg RunnerConfig, args ...string) error
- type DummyMetricTracker
- type Metric
- type MetricCollector
- func (c *MetricCollector) AddBytesRead(n uint64) uint64
- func (c *MetricCollector) AddBytesWritten(n uint64) uint64
- func (c *MetricCollector) AddIncomingStream() uint32
- func (c *MetricCollector) Start(ctx context.Context, interval time.Duration, cb func(Metric))
- func (c *MetricCollector) SubIncomingStream() uint32
- type MetricTracker
- func CollectMetrics(ctx context.Context, interval time.Duration, cb func(Metric)) MetricTracker
- func NewCSVMetricTracker(ctx context.Context, interval time.Duration, filepath string) MetricTracker
- func NewNoopMetricTracker(context.Context, time.Duration) MetricTracker
- func NewStdoutMetricTracker(ctx context.Context, interval time.Duration) MetricTracker
- type RunnerConfig
Constants ¶
const ( RunCmdDial = "dial" RunCmdListen = "listen" RunCmdReport = "report" )
Variables ¶
This section is empty.
Functions ¶
func PrintMetricStats ¶
print metrics as markdown table
Types ¶
type DummyMetricTracker ¶
type DummyMetricTracker struct{}
func (DummyMetricTracker) AddBytesRead ¶
func (DummyMetricTracker) AddBytesRead(uint64) uint64
func (DummyMetricTracker) AddBytesWritten ¶
func (DummyMetricTracker) AddBytesWritten(uint64) uint64
func (DummyMetricTracker) AddIncomingStream ¶
func (DummyMetricTracker) AddIncomingStream() uint32
func (DummyMetricTracker) SubIncomingStream ¶
func (DummyMetricTracker) SubIncomingStream() uint32
type Metric ¶
type Metric struct { Timestamp int64 ActiveStreams uint32 BytesRead uint64 BytesWritten uint64 CpuPercentage uint MemoryHeapBytes uint64 }
Metric is a single metric collected by the MetricCollector.
func ReadCsvMetrics ¶
type MetricCollector ¶
type MetricCollector struct {
// contains filtered or unexported fields
}
Collects metrics each interval and writes them to a csv file.
- Incoming streams are collected manually - CPU / Memory is collected using https://github.com/shirou/gopsutil
func (*MetricCollector) AddBytesRead ¶
func (c *MetricCollector) AddBytesRead(n uint64) uint64
func (*MetricCollector) AddBytesWritten ¶
func (c *MetricCollector) AddBytesWritten(n uint64) uint64
func (*MetricCollector) AddIncomingStream ¶
func (c *MetricCollector) AddIncomingStream() uint32
func (*MetricCollector) SubIncomingStream ¶
func (c *MetricCollector) SubIncomingStream() uint32
type MetricTracker ¶
type MetricTracker interface { AddIncomingStream() uint32 SubIncomingStream() uint32 AddBytesRead(uint64) uint64 AddBytesWritten(uint64) uint64 }
func CollectMetrics ¶
func NewCSVMetricTracker ¶
func NewNoopMetricTracker ¶
func NewNoopMetricTracker(context.Context, time.Duration) MetricTracker
func NewStdoutMetricTracker ¶
func NewStdoutMetricTracker(ctx context.Context, interval time.Duration) MetricTracker