speedPerSecond
Vladimir Bauer
6 years ago
| 22 | 22 | io.WriteString(st, self.perSecond) |
| 23 | 23 | } |
| 24 | 24 | |
| 25 | func sizePerSecond(sizeT fmt.Formatter) fmt.Formatter { | |
| 25 | func speedPerSecond(sizeT fmt.Formatter) fmt.Formatter { | |
| 26 | 26 | return &speedType{ |
| 27 | 27 | sizeT: sizeT, |
| 28 | 28 | perSecond: perSecond, |
| 94 | 94 | |
| 95 | 95 | switch d.unit { |
| 96 | 96 | case UnitKiB: |
| 97 | d.msg = fmt.Sprintf(d.fmt, SizeB1024(math.Round(speed))) | |
| 97 | d.msg = fmt.Sprintf(d.fmt, speedPerSecond(SizeB1024(math.Round(speed)))) | |
| 98 | 98 | case UnitKB: |
| 99 | d.msg = fmt.Sprintf(d.fmt, SizeB1000(math.Round(speed))) | |
| 99 | d.msg = fmt.Sprintf(d.fmt, speedPerSecond(SizeB1000(math.Round(speed)))) | |
| 100 | 100 | default: |
| 101 | 101 | d.msg = fmt.Sprintf(d.fmt, speed) |
| 102 | 102 | } |
| 184 | 184 | |
| 185 | 185 | switch d.unit { |
| 186 | 186 | case UnitKiB: |
| 187 | d.msg = fmt.Sprintf(d.fmt, sizePerSecond(SizeB1024(math.Round(speed)))) | |
| 187 | d.msg = fmt.Sprintf(d.fmt, speedPerSecond(SizeB1024(math.Round(speed)))) | |
| 188 | 188 | case UnitKB: |
| 189 | d.msg = fmt.Sprintf(d.fmt, sizePerSecond(SizeB1000(math.Round(speed)))) | |
| 189 | d.msg = fmt.Sprintf(d.fmt, speedPerSecond(SizeB1000(math.Round(speed)))) | |
| 190 | 190 | default: |
| 191 | 191 | d.msg = fmt.Sprintf(d.fmt, speed) |
| 192 | 192 | } |