Documentation
¶
Overview ¶
Package speedtest measures network throughput and latency between the caller and a gospeedtest server. The same package is used by the CLI and the embedded web client (the web client speaks the same HTTP protocol from JavaScript).
Protocol:
GET /ping -> 204 No Content, used for RTT samples. GET /download?bytes=N -> N bytes of incompressible random data. POST /upload -> drains the body, replies with the byte count.
All three are plain HTTP so a stock load balancer or reverse proxy works without special handling.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
ServerURL string // base URL, e.g. "http://localhost:8080"
HTTPClient *http.Client // optional; one is built if nil
PingSamples int // default 10
TestDuration time.Duration // per phase, default 10s
Streams int // parallel HTTP streams per phase, default 4
ChunkBytes int64 // bytes per request in download/upload, default 25 MiB
SampleEvery time.Duration // how often to emit a Sample, default 100ms
}
Config controls a full test run. Zero values get sensible defaults.
type Result ¶
type Result struct {
PingMs float64 `json:"ping_ms"`
JitterMs float64 `json:"jitter_ms"`
DownloadMbps float64 `json:"download_mbps"`
UploadMbps float64 `json:"upload_mbps"`
BytesDown int64 `json:"bytes_down"`
BytesUp int64 `json:"bytes_up"`
Duration time.Duration `json:"duration"`
StartedAt time.Time `json:"started_at"`
}
Result is the final summary of one test.
type Sample ¶
type Sample struct {
Phase Phase
Elapsed time.Duration // time since the phase began
Bytes int64 // cumulative bytes for download/upload
Mbps float64 // instantaneous bits/sec, megabits
PingMs float64 // most-recent RTT for the ping phase
}
Sample is a snapshot emitted while a phase is in progress.
Click to show internal directories.
Click to hide internal directories.