mirror of
https://github.com/rclone/rclone.git
synced 2024-11-22 16:34:30 +01:00
parent
e59acd16c6
commit
97fc3b9046
@ -214,7 +214,10 @@ func (acc *Account) averageLoop() {
|
|||||||
acc.values.mu.Lock()
|
acc.values.mu.Lock()
|
||||||
// Add average of last second.
|
// Add average of last second.
|
||||||
elapsed := now.Sub(acc.values.lpTime).Seconds()
|
elapsed := now.Sub(acc.values.lpTime).Seconds()
|
||||||
avg := float64(acc.values.lpBytes) / elapsed
|
avg := 0.0
|
||||||
|
if elapsed > 0 {
|
||||||
|
avg = float64(acc.values.lpBytes) / elapsed
|
||||||
|
}
|
||||||
// Soft start the moving average
|
// Soft start the moving average
|
||||||
if period < averagePeriod {
|
if period < averagePeriod {
|
||||||
period++
|
period++
|
||||||
@ -442,7 +445,11 @@ func (acc *Account) speed() (bps, current float64) {
|
|||||||
}
|
}
|
||||||
// Calculate speed from first read.
|
// Calculate speed from first read.
|
||||||
total := float64(time.Now().Sub(acc.values.start)) / float64(time.Second)
|
total := float64(time.Now().Sub(acc.values.start)) / float64(time.Second)
|
||||||
bps = float64(acc.values.bytes) / total
|
if total > 0 {
|
||||||
|
bps = float64(acc.values.bytes) / total
|
||||||
|
} else {
|
||||||
|
bps = 0.0
|
||||||
|
}
|
||||||
current = acc.values.avg
|
current = acc.values.avg
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user