Documentation
¶
Index ¶
- Constants
- Variables
- type Config
- type Emitter
- type HumanReadable
- func (HumanReadable) OnConnect(server string)
- func (e HumanReadable) OnDebug(msg string)
- func (HumanReadable) OnError(err error)
- func (HumanReadable) OnMeasurement(id int, m model.WireMeasurement)
- func (HumanReadable) OnResult(r Result)
- func (HumanReadable) OnStart(server string, kind spec.SubtestKind)
- func (HumanReadable) OnStreamComplete(streamID int, server string)
- func (HumanReadable) OnSummary(results map[spec.SubtestKind]Result)
- type Locator
- type Result
- type Throughput1Client
Constants ¶
const ( // DefaultWebSocketHandshakeTimeout is the default timeout used by the client // for the WebSocket handshake. DefaultWebSocketHandshakeTimeout = 5 * time.Second // DefaultStreams is the default number of streams for a new client. DefaultStreams = 2 // DefaultLength is the default test duration for a new client. DefaultLength = 5 * time.Second // DefaultScheme is the default WebSocket scheme for a new Client. DefaultScheme = "wss" )
Variables ¶
var ( // ErrNoTargets is returned if all Locate targets have been tried. ErrNoTargets = errors.New("no targets available") )
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
// Server is the server to connect to. If empty, the server is obtained by
// querying the configured Locator.
Server string
// Scheme is the WebSocket scheme used to connect to the server (ws or wss).
Scheme string
// NumStreams is the number of streams that will be spawned by this client to run a
// download or an upload test.
NumStreams int
// Length is the duration of the test.
Length time.Duration
// Delay is the delay between each stream.
Delay time.Duration
// CongestionControl is the congestion control algorithm to request from the server.
CongestionControl string
// MeasurementID is the manually configured Measurement ID ("mid") to pass to the server.
MeasurementID string
// Emitter is the interface used to emit the results of the test. It can be overridden
// to provide a custom output.
Emitter Emitter
// NoVerify disables the TLS certificate verification.
NoVerify bool
// ByteLimit is the maximum number of bytes to download or upload. If set to 0, the
// limit is disabled.
ByteLimit int
}
Config is the configuration for a Client.
type Emitter ¶
type Emitter interface {
// OnStart is called when a stream starts.
OnStart(server string, kind spec.SubtestKind)
// OnConnect is called when the WebSocket connection is established.
OnConnect(server string)
// OnMeasurement is called on received Measurement objects.
OnMeasurement(id int, m model.WireMeasurement)
// OnResult is called when the aggregate result is ready.
OnResult(Result)
// OnError is called on errors.
OnError(err error)
// OnStreamComplete is called after a stream completes.
OnStreamComplete(streamID int, server string)
// OnDebug is called to print debug information.
OnDebug(msg string)
// OnSummary is called to print summary information.
OnSummary(results map[spec.SubtestKind]Result)
}
Emitter is an interface for emitting results.
type HumanReadable ¶
type HumanReadable struct {
Debug bool
}
HumanReadable prints human-readable output to stdout. It can be configured to include debug output, too.
func (HumanReadable) OnConnect ¶
func (HumanReadable) OnConnect(server string)
OnConnect is called when the connection to the server is established.
func (HumanReadable) OnDebug ¶
func (e HumanReadable) OnDebug(msg string)
OnDebug is called to print debug information.
func (HumanReadable) OnMeasurement ¶
func (HumanReadable) OnMeasurement(id int, m model.WireMeasurement)
OnMeasurement is called on received Measurement objects.
func (HumanReadable) OnResult ¶
func (HumanReadable) OnResult(r Result)
OnResult prints the aggregate result.
func (HumanReadable) OnStart ¶
func (HumanReadable) OnStart(server string, kind spec.SubtestKind)
OnStart is called when the stream starts and prints the subtest and server hostname.
func (HumanReadable) OnStreamComplete ¶ added in v0.4.7
func (HumanReadable) OnStreamComplete(streamID int, server string)
OnStreamComplete is called after a stream completes.
func (HumanReadable) OnSummary ¶ added in v0.4.7
func (HumanReadable) OnSummary(results map[spec.SubtestKind]Result)
type Result ¶
type Result struct {
// Subtest is the subtest this Result refers to.
Subtest spec.SubtestKind
// Goodput is the average number of application-level bits per second that
// have been transferred so far across all the streams.
Goodput float64
// Throughput is the average number of network-level bits per second that
// have been transferred so far across all the streams.
Throughput float64
// Elapsed is the total time elapsed since the test started.
Elapsed time.Duration
// RTT is the latest RTT value from TCPInfo from any stream.
RTT uint32
// MinRTT is the minimum of RTT values observed across all the streams.
MinRTT uint32
// Streams is the number of streams used in the test.
Streams int
// ByteLimit is the byte limit used in the test.
ByteLimit int
// Length is the length of the test.
Length time.Duration
// CongestionControl is the congestion control used in the test.
CongestionControl string
}
Result contains the aggregate metrics collected during the test.
type Throughput1Client ¶
type Throughput1Client struct {
// ClientName is the name of the client sent to the server as part of the user-agent.
ClientName string
// ClientVersion is the version of the client sent to the server as part of the user-agent.
ClientVersion string
// contains filtered or unexported fields
}
Throughput1Client is a client for the throughput1 protocol.
func New ¶
func New(clientName, clientVersion string, config Config) *Throughput1Client
New returns a new Throughput1Client with the provided client name, version and config. It panics if clientName or clientVersion are empty.
func (*Throughput1Client) Download ¶
func (c *Throughput1Client) Download(ctx context.Context)
Download runs a download test using the settings configured for this client.
func (*Throughput1Client) PrintSummary ¶ added in v0.4.7
func (c *Throughput1Client) PrintSummary()
PrintSummary emits a summary via the configured emitter
func (*Throughput1Client) Upload ¶
func (c *Throughput1Client) Upload(ctx context.Context)
Upload runs an upload test using the settings configured for this client.