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

benchmark

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 3, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ComparisonTable

func ComparisonTable(results []*BenchmarkResult) string

ComparisonTable generates a markdown comparison table from benchmark results.

func PrintResult

func PrintResult(r *BenchmarkResult)

PrintResult prints a formatted benchmark result to stdout.

func SaveResults

func SaveResults(results []*BenchmarkResult, path string) error

SaveResults saves benchmark results to a JSON file.

Types

type Benchmark

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

Benchmark runs performance comparisons and generates formatted results. Measures requests/sec, latency percentiles, bytes transferred, and error rates.

func NewBenchmark

func NewBenchmark(logger *slog.Logger) *Benchmark

NewBenchmark creates a new benchmark runner.

func (*Benchmark) Run

Run executes a benchmark with the given configuration.

type BenchmarkConfig

type BenchmarkConfig struct {
	URL         string
	Concurrency int
	Duration    time.Duration
	Requests    int
	Headers     map[string]string
}

BenchmarkConfig configures a benchmark run.

func DefaultBenchmarkConfig

func DefaultBenchmarkConfig(url string) *BenchmarkConfig

DefaultBenchmarkConfig returns a sensible default configuration.

type BenchmarkResult

type BenchmarkResult struct {
	Tool        string        `json:"tool"`
	URL         string        `json:"url"`
	Concurrency int           `json:"concurrency"`
	Duration    time.Duration `json:"duration"`
	TotalReqs   int64         `json:"total_requests"`
	SuccessReqs int64         `json:"success_requests"`
	FailedReqs  int64         `json:"failed_requests"`
	ReqsPerSec  float64       `json:"requests_per_second"`
	AvgLatency  time.Duration `json:"avg_latency"`
	P50Latency  time.Duration `json:"p50_latency"`
	P95Latency  time.Duration `json:"p95_latency"`
	P99Latency  time.Duration `json:"p99_latency"`
	MinLatency  time.Duration `json:"min_latency"`
	MaxLatency  time.Duration `json:"max_latency"`
	BytesRecv   int64         `json:"bytes_received"`
	Throughput  float64       `json:"throughput_mbps"`
	ErrorRate   float64       `json:"error_rate"`
}

BenchmarkResult holds the results of a benchmark run.

Jump to

Keyboard shortcuts

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