diff --git a/consts.go b/consts.go new file mode 100644 index 0000000..5bed223 --- /dev/null +++ b/consts.go @@ -0,0 +1,8 @@ +package gwp + +import "time" + +const ( + defaultProgressUpdatePeriod = time.Second + defaultCalculateEtaPeriod = time.Minute +) diff --git a/gwp.go b/gwp.go index 6a1a27c..c94e853 100644 --- a/gwp.go +++ b/gwp.go @@ -37,16 +37,14 @@ func New(threadCount int) *WorkerPool { var prevPos int prevTime := time.Now() - const calculateEtaPeriod = time.Minute - - tickerUpdateText := time.NewTicker(time.Second) - tickerCalculateEta := time.NewTicker(calculateEtaPeriod) + tickerUpdateText := time.NewTicker(defaultProgressUpdatePeriod) + tickerCalculateEta := time.NewTicker(defaultCalculateEtaPeriod) defer func() { tickerUpdateText.Stop() tickerCalculateEta.Stop() }() - var currentSpeed float64 // items per sec + var currentSpeed float64 // jobs per sec fmt.Fprintf(os.Stderr, endLine) for {