mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-22 04:36:42 +00:00
Update eta.go
This commit is contained in:
parent
a122dbe459
commit
09bdbf95c4
1 changed files with 3 additions and 2 deletions
|
|
@ -21,10 +21,11 @@ import "time"
|
|||
// CalculateETA calculates the estimated remaining time based on the
|
||||
// number of finished task, remaining task, and the time cost for finished task.
|
||||
func CalculateETA(done, left uint64, elapsed time.Duration) time.Duration {
|
||||
if done == 0 || elapsed.Milliseconds() == 0 {
|
||||
ms := elapsed.Milliseconds()
|
||||
if done == 0 || ms == 0 {
|
||||
return 0
|
||||
}
|
||||
|
||||
speed := float64(done) / float64(elapsed.Milliseconds())
|
||||
speed := float64(done) / float64(ms)
|
||||
return time.Duration(float64(left)/speed) * time.Millisecond
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue