benchrunner

package
v0.0.0-...-9e5a5ea Latest Latest
Warning

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

Go to latest
Published: Jan 31, 2024 License: MIT Imports: 34 Imported by: 0

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

View Source
const (
	RunCmdDial   = "dial"
	RunCmdListen = "listen"
	RunCmdReport = "report"
)

Variables

This section is empty.

Functions

func PrintMetricStats

func PrintMetricStats(metricsMapping map[string][]Metric, activeStreams uint32)

print metrics as markdown table

func Run

func Run(ctx context.Context, cfg RunnerConfig, args ...string) error

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

func ReadCsvMetrics(filepath string) ([]Metric, error)

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) Start

func (c *MetricCollector) Start(ctx context.Context, interval time.Duration, cb func(Metric))

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 CollectMetrics(ctx context.Context, interval time.Duration, cb func(Metric)) MetricTracker

func NewCSVMetricTracker

func NewCSVMetricTracker(ctx context.Context, interval time.Duration, filepath string) MetricTracker

func NewNoopMetricTracker

func NewNoopMetricTracker(context.Context, time.Duration) MetricTracker

func NewStdoutMetricTracker

func NewStdoutMetricTracker(ctx context.Context, interval time.Duration) MetricTracker

type RunnerConfig

type RunnerConfig struct {
	Transport      string
	ProfilePort    int
	MetricInterval time.Duration
	MetricOutput   string

	ListenPort     int
	ListenInsecure bool
	ListenSeed     int64

	DialConnections int
	DialStreams     int
}

Jump to

Keyboard shortcuts

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