plotting

package
v0.0.0-...-7cc9995 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2024 License: MIT Imports: 16 Imported by: 0

Documentation

Overview

Package plotting provides functions and structures for plotting measurement data collected from running an experiment.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CSVPlot

func CSVPlot(filename string, headers []string, plot func() plotter.XYer) error

CSVPlot writes to a CSV file.

func GonumPlot

func GonumPlot(filename, xlabel, ylabel string, f func(plt *plot.Plot) error) error

GonumPlot sets up a gonum/plot and calls f to add data.

func TimeAndAverage

func TimeAndAverage(groups []MeasurementGroup, getValue func(Measurement) (float64, uint64)) plotter.XYer

TimeAndAverage returns a struct that yields (x, y) points where x is the time, and y is the average value of each group. The getValue function must return the value and sample count for the given measurement.

Types

type ClientLatencyPlot

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

ClientLatencyPlot plots client latency measurements.

func NewClientLatencyPlot

func NewClientLatencyPlot() ClientLatencyPlot

NewClientLatencyPlot returns a new client latency plotter.

func (*ClientLatencyPlot) Add

func (p *ClientLatencyPlot) Add(measurement any)

Add adds a measurement to the plot.

func (*ClientLatencyPlot) PlotAverage

func (p *ClientLatencyPlot) PlotAverage(filename string, measurementInterval time.Duration) (err error)

PlotAverage plots the average latency of all clients within each measurement interval.

type Measurement

type Measurement interface {
	GetEvent() *types.Event
}

Measurement is an object with a types.Event getter.

type MeasurementGroup

type MeasurementGroup struct {
	Time         time.Duration // The beginning of the time interval
	Measurements []Measurement
}

MeasurementGroup is a collection of measurements that were taken within a time interval.

func GroupByTimeInterval

func GroupByTimeInterval(startTimes *StartTimes, m MeasurementMap, interval time.Duration) []MeasurementGroup

GroupByTimeInterval merges all measurements from all client/replica ids into groups based on the time interval that the measurement was taken in. The StartTimes object is used to calculate which time interval a measurement falls in.

type MeasurementMap

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

MeasurementMap is a map that stores lists Measurement objects associated with the ID of the client/replica where they where taken.

func NewMeasurementMap

func NewMeasurementMap() MeasurementMap

NewMeasurementMap constructs a new MeasurementMap

func (*MeasurementMap) Add

func (m *MeasurementMap) Add(id uint32, measurement Measurement)

Add adds a measurement to the map.

func (*MeasurementMap) Get

func (m *MeasurementMap) Get(id uint32) (measurements []Measurement, ok bool)

Get returns the list of measurements associated with the specified client/replica id.

func (*MeasurementMap) NumIDs

func (m *MeasurementMap) NumIDs() int

NumIDs returns the number of client/replica IDs that are registered in the map.

type Plotter

type Plotter interface {
	// Adds a measurement to the plotter.
	Add(any)
}

Plotter processes measurements from a reader.

type Reader

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

Reader reads measurements from JSON.

func NewReader

func NewReader(rd io.Reader, plotters ...Plotter) *Reader

NewReader returns a new reader that reads from the specified source and adds measurements to the plotters.

func (*Reader) ReadAll

func (r *Reader) ReadAll() error

ReadAll reads all measurements in the source.

type StartTimes

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

StartTimes collects the start times for each client or replica.

func NewStartTimes

func NewStartTimes() StartTimes

NewStartTimes returns a new StartTimes instance.

func (*StartTimes) Add

func (s *StartTimes) Add(msg any)

Add adds an event.

func (*StartTimes) Client

func (s *StartTimes) Client(id uint32) (t time.Time, ok bool)

Client returns the start time of the client with the specified id.

func (*StartTimes) ClientOffset

func (s *StartTimes) ClientOffset(id uint32, t time.Time) (offset time.Duration, ok bool)

ClientOffset returns the time offset from the client's start time.

func (*StartTimes) Replica

func (s *StartTimes) Replica(id uint32) (t time.Time, ok bool)

Replica returns the start time of the replica with the specified id.

func (*StartTimes) ReplicaOffset

func (s *StartTimes) ReplicaOffset(id uint32, t time.Time) (offset time.Duration, ok bool)

ReplicaOffset returns the time offset from the replica's start time.

type ThroughputPlot

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

ThroughputPlot is a plotter that plots throughput vs time.

func NewThroughputPlot

func NewThroughputPlot() ThroughputPlot

NewThroughputPlot returns a new throughput plotter.

func (*ThroughputPlot) Add

func (p *ThroughputPlot) Add(measurement any)

Add adds a measurement to the plotter.

func (*ThroughputPlot) PlotAverage

func (p *ThroughputPlot) PlotAverage(filename string, measurementInterval time.Duration) (err error)

PlotAverage plots the average throughput of all replicas at specified time intervals.

type ThroughputVSLatencyPlot

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

ThroughputVSLatencyPlot is a plotter that plots throughput vs time.

func NewThroughputVSLatencyPlot

func NewThroughputVSLatencyPlot() ThroughputVSLatencyPlot

NewThroughputVSLatencyPlot returns a new throughput plotter.

func (*ThroughputVSLatencyPlot) Add

func (p *ThroughputVSLatencyPlot) Add(measurement any)

Add adds a measurement to the plotter.

func (*ThroughputVSLatencyPlot) PlotAverage

func (p *ThroughputVSLatencyPlot) PlotAverage(filename string, measurementInterval time.Duration) (err error)

PlotAverage plots the average throughput of all replicas at specified time intervals.

Jump to

Keyboard shortcuts

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