speedtest

package
v0.1.9 Latest Latest
Warning

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

Go to latest
Published: Jun 8, 2026 License: MIT Imports: 11 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Mbps

func Mbps(bytes int64, d time.Duration) float64

Mbps converts a byte count over a duration into megabits per second.

Types

type Client

type Client struct {
	HTTP     *http.Client
	DownURL  string
	UpURL    string
	TraceURL string
}

Client holds endpoint URLs and the HTTP client used for measurement.

func NewClient

func NewClient() *Client

NewClient returns a Client pointed at Cloudflare with sane HTTP defaults.

func (*Client) Run

func (c *Client) Run(cfg Config, progress ProgressFunc) (Result, error)

Run executes the configured measurements and returns a populated Result. Latency runs first, then download and/or upload per cfg flags.

type Config

type Config struct {
	Streams      int
	Duration     time.Duration
	DownloadOnly bool
	UploadOnly   bool
}

Config holds tunable run parameters.

type Phase

type Phase string

Phase identifies which measurement is in progress.

const (
	PhaseLatency  Phase = "latency"
	PhaseDownload Phase = "download"
	PhaseUpload   Phase = "upload"
)

type Progress

type Progress struct {
	Phase Phase
	Mbps  float64
}

Progress is reported to the callback as bytes flow.

type ProgressFunc

type ProgressFunc func(Progress)

ProgressFunc receives live progress; may be nil.

type Result

type Result struct {
	Timestamp    time.Time     `json:"timestamp"`
	ServerColo   string        `json:"server_colo"`
	Latency      time.Duration `json:"latency_ns"`
	Jitter       time.Duration `json:"jitter_ns"`
	DownloadMbps float64       `json:"download_mbps"`
	UploadMbps   float64       `json:"upload_mbps"`
}

Result is the single contract between measurement and consumers.

Jump to

Keyboard shortcuts

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