PrivatecurrentPrivatecurrentShort label describing the operation. Freely mutable so callers can relabel between phases.
Free-form trailing text, e.g. the item currently being processed.
PrivateminPrivate ReadonlytimerEstimated seconds remaining based on the current rate, or undefined when it cannot be
computed yet (no rate, unknown total, or already complete). Self-corrects as the total grows.
True while no meaningful total is known yet, in which case progress cannot be expressed as a fraction and a renderer should fall back to an indeterminate animation.
Completed units per second since the clock started.
Completion ratio in the [0, 1] range, clamped so a lagging total (the total can jump up as
new work is discovered) never produces a ratio above 1.
Time column for a gauge: the time the task is running. Estimates (ETA) and throughput rates fluctuate too much across the phases of a run to be meaningful; a climbing elapsed time is always accurate and keeps visibly moving while a long phase runs.
Integer milestone index for throttling output, e.g. milestone(10) returns 0..10 as
progress passes each 10% mark.
Record the latest progress. Either argument may be omitted to leave it unchanged. The source is
expected to report a total that can grow as more work is discovered; the most recent reading
is always kept.
Optionalvalue: numberOptionaltotal: numberReset the gauge to zero for a fresh progression (e.g. a new phase of work): clears the counts, applies a new lower bound for the total and restarts the clock so throughput and ETA are scoped to the new progression.
(Re)start the elapsed-time clock used for throughput and ETA.
Plain, colourless one-line summary suitable for forward-printing output, e.g.
62% (248/400) · 0:35 elapsed.
Tracks the numbers behind a long-running operation and derives presentation-ready metrics from them: completion ratio, percentage, throughput, ETA and elapsed time.
The tracker is the model behind ProgressBar but is independent of any rendering: it can be used on its own to compute progress figures, or shared with a bar so the bar and another consumer (a logger, a status line, …) present identical numbers.
It is built for sources whose total is discovered incrementally —
report(value, total)simply overwrites the latest reading, andtotalmay grow over time. The visual ratio is always clamped to[0, 1], and ProgressTrackerOptions.minTotal provides a floor so the bar does not look complete before the real amount of work is known.Example