correct movingAverageSpeed
Vladimir Bauer
6 years ago
| 82 | 82 | return d.FormatMsg(d.msg) |
| 83 | 83 | } |
| 84 | 84 | |
| 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 | } | |
| 86 | 90 | |
| 91 | d.msg = d.producer(speed) | |
| 87 | 92 | return d.FormatMsg(d.msg) |
| 88 | 93 | } |
| 89 | 94 | |
| 92 | 97 | for _, wd := range wdd { |
| 93 | 98 | workDuration = wd |
| 94 | 99 | } |
| 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) { | |
| 97 | 102 | return |
| 98 | 103 | } |
| 99 | d.average.Add(speed) | |
| 104 | d.average.Add(durPerByte) | |
| 100 | 105 | } |
| 101 | 106 | |
| 102 | 107 | func (d *movingAverageSpeed) OnCompleteMessage(msg string) { |