timetrack

package
v0.9.3 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2021 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package timetrack tracks the progress and estimates completion of a task.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Estimator

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

Estimator estimates the completion of a task.

func Start

func Start() Estimator

Start returns an Estimator object.

func (Estimator) Completed

func (v Estimator) Completed(total float64) (totalTime time.Duration, speed float64)

Completed computes the duration and speed (total per second).

func (Estimator) Estimate

func (v Estimator) Estimate(completed, total float64) (Timings, bool)

Estimate estimates the completion of a task given the current progress as indicated by ration of completed/total.

type Throttle

type Throttle int64

Throttle throttles UI updates to a specific interval.

func (*Throttle) Reset

func (t *Throttle) Reset()

Reset resets the throttle.

func (*Throttle) ShouldOutput

func (t *Throttle) ShouldOutput(interval time.Duration) bool

ShouldOutput returns true if it's ok to produce output given the for a given time interval.

type Timings

type Timings struct {
	PercentComplete  float64
	EstimatedEndTime time.Time
	Remaining        time.Duration
	SpeedPerSecond   float64
}

Timings returns task progress and timings.

Jump to

Keyboard shortcuts

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