benchmark

package
v0.7.6 Latest Latest
Warning

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

Go to latest
Published: Apr 2, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BenchmarkMetrics

type BenchmarkMetrics struct {
	StartTime     time.Time
	FirstByteTime time.Time
	EndTime       time.Time

	TotalBytes    int64
	BytesReceived atomic.Int64

	RetryCount    atomic.Int32
	ConnectionMax atomic.Int32
	ConnectionSum atomic.Int64
	SampleCount   atomic.Int64

	// Memory tracking
	StartMemAlloc uint64
	PeakMemAlloc  uint64
}

BenchmarkMetrics collects performance metrics during download

func NewBenchmarkMetrics

func NewBenchmarkMetrics() *BenchmarkMetrics

NewBenchmarkMetrics creates a new metrics collector

func (*BenchmarkMetrics) Finish

func (bm *BenchmarkMetrics) Finish(totalBytes int64)

Finish marks the download as complete and captures final stats

func (*BenchmarkMetrics) GetResults

func (bm *BenchmarkMetrics) GetResults() BenchmarkResults

GetResults returns the computed metrics

func (*BenchmarkMetrics) RecordBytes

func (bm *BenchmarkMetrics) RecordBytes(n int64)

RecordBytes adds to the total bytes received

func (*BenchmarkMetrics) RecordConnections

func (bm *BenchmarkMetrics) RecordConnections(count int32)

RecordConnections samples the current connection count

func (*BenchmarkMetrics) RecordFirstByte

func (bm *BenchmarkMetrics) RecordFirstByte()

RecordFirstByte marks when the first byte was received

func (*BenchmarkMetrics) RecordRetry

func (bm *BenchmarkMetrics) RecordRetry()

RecordRetry increments the retry counter

type BenchmarkResults

type BenchmarkResults struct {
	TotalTime      time.Duration
	TTFB           time.Duration
	ThroughputMBps float64
	TotalBytes     int64
	RetryCount     int
	MaxConnections int
	AvgConnections float64
	MemoryUsedMB   float64
}

BenchmarkResults holds the final computed metrics

func (BenchmarkResults) String

func (br BenchmarkResults) String() string

String returns a formatted summary of the results

Jump to

Keyboard shortcuts

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