one math.Round less
Vladimir Bauer
6 years ago
| 76 | 76 | func (d *movingAverageSpeed) Decor(st *Statistics) string { |
| 77 | 77 | if !st.Completed { |
| 78 | 78 | var speed float64 |
| 79 | if v := math.Round(d.average.Value()); v != 0 { | |
| 80 | speed = 1 / time.Duration(v).Seconds() | |
| 79 | if v := d.average.Value(); v < 0 { | |
| 80 | speed = 1 / v | |
| 81 | 81 | } |
| 82 | d.msg = d.producer(speed) | |
| 82 | d.msg = d.producer(speed * 1e9) | |
| 83 | 83 | } |
| 84 | 84 | return d.FormatMsg(d.msg) |
| 85 | 85 | } |
| 145 | 145 | |
| 146 | 146 | func (d *averageSpeed) Decor(st *Statistics) string { |
| 147 | 147 | if !st.Completed { |
| 148 | speed := float64(st.Current) / time.Since(d.startTime).Seconds() | |
| 149 | d.msg = d.producer(speed) | |
| 148 | speed := float64(st.Current) / float64(time.Since(d.startTime)) | |
| 149 | d.msg = d.producer(speed * 1e9) | |
| 150 | 150 | } |
| 151 | 151 | |
| 152 | 152 | return d.FormatMsg(d.msg) |