Codebase list golang-github-vbauerster-mpb / 3d5bb10
correct movingAverageSpeed Vladimir Bauer 6 years ago
1 changed file(s) with 9 addition(s) and 4 deletion(s). Raw diff Collapse all Expand all
8282 return d.FormatMsg(d.msg)
8383 }
8484
85 d.msg = d.producer(d.average.Value())
85 var speed float64
86 if v := math.Round(d.average.Value()); v != 0 {
87 current := float64(st.Current)
88 speed = current / (current * time.Duration(v).Seconds())
89 }
8690
91 d.msg = d.producer(speed)
8792 return d.FormatMsg(d.msg)
8893 }
8994
9297 for _, wd := range wdd {
9398 workDuration = wd
9499 }
95 speed := float64(n) / workDuration.Seconds() / 1000
96 if math.IsInf(speed, 0) || math.IsNaN(speed) {
100 durPerByte := float64(workDuration) / float64(n)
101 if math.IsInf(durPerByte, 0) || math.IsNaN(durPerByte) {
97102 return
98103 }
99 d.average.Add(speed)
104 d.average.Add(durPerByte)
100105 }
101106
102107 func (d *movingAverageSpeed) OnCompleteMessage(msg string) {