Help us shape the future of Go! Take the 2026 Go Developer Survey

speedtest

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Jul 28, 2026 License: MIT Imports: 17 Imported by: 0

Documentation

Overview

Package speedtest implements the throughput test used by 10000speedtest.

The China Telecom Guangdong web client drives its test with many parallel HTTP connections:

  • Download: GET <server>/shmfile/<sizeMiB>?tag=<random> -> server streams sizeMiB of octet-stream
  • Upload: POST <server>/upload?tag=<random> -> client streams a body, server sinks it

A Tester reproduces that behaviour: it opens Config.Connections parallel connections for Config.Duration and sums the bytes moved, reporting the throughput in Mbps.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Server       string
	Connections  int
	Duration     time.Duration
	DownloadSize int
	UploadSize   int
	Insecure     bool
	Chart        bool
	JSONOutput   bool
	// Interfaces binds outgoing connections to local network interfaces (by name)
	// or source IPs. Each interface runs Connections connections and the results
	// are aggregated. Empty uses the default route.
	Interfaces []string
}

Config describes a single speed-test run.

type InterfaceResult added in v0.5.0

type InterfaceResult struct {
	Interface         string
	Bytes             int64
	MegabitsPerSecond float64
}

InterfaceResult holds one interface's contribution to a stage.

type Result

type Result struct {
	Name              string
	Bytes             int64
	Elapsed           time.Duration
	MegabitsPerSecond float64
	PerInterface      []InterfaceResult
}

Result holds the measured throughput of one stage. When more than one interface is tested, PerInterface breaks the total down per interface.

type Tester

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

Tester runs download and upload stages against a configured server, over one HTTP client per configured interface.

func New

func New(config Config) (*Tester, error)

New builds a Tester with one HTTP client per configured interface. It returns an error if any interface cannot be resolved to a local address.

func (*Tester) Download

func (self *Tester) Download() Result

Download runs the download stage and returns its measured throughput.

func (*Tester) Upload

func (self *Tester) Upload() Result

Upload runs the upload stage and returns its measured throughput.

Jump to

Keyboard shortcuts

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