"test/git@developer.sourcefind.cn:change/sglang.git" did not exist on "36a6b8dbfcd0fefd38e4391a93b2c496a3d77ccf"
Commit 4d677ee3 authored by Michael Yang's avatar Michael Yang
Browse files

no divide by zero

parent 7ea90587
...@@ -105,7 +105,12 @@ func (b *Bar) percent() float64 { ...@@ -105,7 +105,12 @@ func (b *Bar) percent() float64 {
} }
func (b *Bar) rate() float64 { func (b *Bar) rate() float64 {
return (float64(b.currentValue) - float64(b.initialValue)) / b.elapsed().Seconds() elapsed := b.elapsed()
if elapsed.Seconds() > 0 {
return (float64(b.currentValue) - float64(b.initialValue)) / elapsed.Seconds()
}
return 0
} }
func (b *Bar) elapsed() time.Duration { func (b *Bar) elapsed() time.Duration {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment