Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Stats ¶
type Stats struct {
// contains filtered or unexported fields
}
Stats tracks transfer statistics (bytes, duration, bandwidth).
func (*Stats) CurrentBandwidth ¶
CurrentBandwidth returns bytes/sec over an adaptive window:
window_age = min(time_since_oldest_in_window_sample, maxWindow) rate = (bytes_now − bytes_at_window_start) / window_age
During the first maxWindow, Stats.timeStart acts as an implicit zeroth sample at bytes=0, so the rate is meaningful from the first AddBytes call without a startup spike.
Returns 0 if not started, or past the startup window with no recent samples.
func (*Stats) Duration ¶
Duration returns the active elapsed time, excluding any intervals spent paused. Returns 0 before Start. While running, measures up to "now"; after Stop, up to the stop timestamp.
func (*Stats) Pause ¶
func (s *Stats) Pause()
Pause records an interruption timestamp. No-op if not started or already stopped.
func (*Stats) Sample ¶
func (s *Stats) Sample()
Sample records the current byte total at "now" into the live-bandwidth ring buffer. Cheap; intended to be called on a regular tick (e.g. every 100ms by progress emitters).
func (*Stats) Start ¶
func (s *Stats) Start()
Start records the start timestamp on the first call, or resumes a paused run. Subsequent calls while running are no-ops.