Documentation ¶
Index ¶
- Variables
- type Conn
- type MeasureThroughputOpt
- func WithDialer(d NetDialer) MeasureThroughputOpt
- func WithMaxBytes(n int) MeasureThroughputOpt
- func WithMaxDuration(d time.Duration) MeasureThroughputOpt
- func WithMinIterations(n int) MeasureThroughputOpt
- func WithTime(f func() time.Time) MeasureThroughputOpt
- func WithTolerance(frac float64) MeasureThroughputOpt
- type NetConn
- type NetDialer
- type Reporter
- type Server
- type ThroughputInfo
Constants ¶
This section is empty.
Variables ¶
var ErrNoDataReceived = errors.New("no data received")
ErrNoDataReceived is returned if Conn.Recv saw no data.
Functions ¶
This section is empty.
Types ¶
type Conn ¶
type Conn struct {
// contains filtered or unexported fields
}
A Conn can receive and send random data.
type MeasureThroughputOpt ¶
type MeasureThroughputOpt func(*measureThroughputOpts) error
A MeasureThroughputOpt can be provided to MeasureThroughput.
func WithDialer ¶
func WithDialer(d NetDialer) MeasureThroughputOpt
func WithMaxBytes ¶
func WithMaxBytes(n int) MeasureThroughputOpt
WithMaxBytes sets a cap on the total number of bytes to send. The hope is to never hit this hard limit, but that the tolerance criterion is fulfilled first. The default is 1 GiB.
func WithMaxDuration ¶
func WithMaxDuration(d time.Duration) MeasureThroughputOpt
WithMaxDuration sets a cap on the duration of a single connection. This should be at most what the connection timeout is on the server. The default is 10s.
func WithMinIterations ¶
func WithMinIterations(n int) MeasureThroughputOpt
WithMinIterations adjusts the number of bytes per iteration so that `WithMaxBytes` is not hit until, at least, this many iterations. The default is 8.
func WithTime ¶
func WithTime(f func() time.Time) MeasureThroughputOpt
func WithTolerance ¶
func WithTolerance(frac float64) MeasureThroughputOpt
WithTolerance sets the tolerated relative error of the last iteration. If the latest send/receive measurement is within this tolerance, measurements stop. A value in [0, 1]. The default is 5%.
type NetConn ¶
type NetConn interface { io.Closer io.Reader io.Writer CloseWrite() error SetReadDeadline(time.Time) error SetWriteDeadline(time.Time) error }
A NetConn is what we can wrap. `*net.TCPConn` implements this.
type Reporter ¶
type Reporter interface { // ServedCharGen2P is called when a connection is closed. Either // there is throughput information, or an error. ServedCharGen2P(net.Conn, *ThroughputInfo, error) }
A Reporter hooks into various connection state changes. Implementations must be safe for concurrent use.
type Server ¶
type Server struct { // Reporter is an optional result handler. Normally, only the // client is interested in the outcome, so this can be nil. Reporter Reporter // MaxConns is the maximum number of simultaneous connections. // This will create a backlog if we're over quota, which pushes // back through the kernel to TCP clients. The default is 10. MaxConns int // ConnContext is a factory function for creating a per-connection // context. This is useful to set a timeout. ConnContext func(context.Context, net.Conn) context.Context }
A Server listens for incoming connections and handles processing them.
type ThroughputInfo ¶
type ThroughputInfo struct { // DialDuration is how long connecting to the remote peer took. DialDuration time.Duration // NumWrittenBytes is the number of (payload) bytes sent. Protocol // headers are not included. NumWrittenBytes int // WriteDuration is how long it took to send the data, including // closing the send endpoint. WriteDuration time.Duration // NumReadBytes is the number of (payload) bytes // received. Protocol headers are not included. NumReadBytes int // ReadDuration is how long it took to receive the data, counting // from after closing the send endpoint. ReadDuration time.Duration // ReadLatency is how long after closing the send endpoint the // first received block was ready. This is a rough estimate of // latency, but depends on the internal receive buffer size. ReadLatency time.Duration // WorstAccuracy describes the worst acceptable relative error for // the write and read throughput of the last iteration. // `DialDuration` and `FirstReadLatency` are not considered as // they normally have much higher variances. A value in [0, 1]. WorstAccuracy float64 }
A ThroughputInfo contains various measurements from a throughput test.
func MeasureThroughput ¶
func MeasureThroughput(ctx context.Context, network, addr string, opts ...MeasureThroughputOpt) (*ThroughputInfo, error)
MeasureThroughput dials, sends and receives a Conn. Reports summary statistics.
Directories ¶
Path | Synopsis |
---|---|
cmd
|
|
chargen2pd
Command chargen2pd implements a 2-phase character generator service.
|
Command chargen2pd implements a 2-phase character generator service. |