(d time.Duration)
| 130 | } |
| 131 | |
| 132 | func durationToString(d time.Duration) string { |
| 133 | if d < 0 { |
| 134 | return d.String() |
| 135 | } |
| 136 | ud := uint64(d) |
| 137 | val := float64(ud) |
| 138 | unit := "" |
| 139 | if ud < uint64(60*time.Second) { |
| 140 | switch { |
| 141 | case ud < uint64(time.Microsecond): |
| 142 | unit = "ns" |
| 143 | case ud < uint64(time.Millisecond): |
| 144 | val = val / 1000 |
| 145 | unit = "us" |
| 146 | case ud < uint64(time.Second): |
| 147 | val = val / (1000 * 1000) |
| 148 | unit = "ms" |
| 149 | default: |
| 150 | val = val / (1000 * 1000 * 1000) |
| 151 | unit = "s" |
| 152 | } |
| 153 | |
| 154 | result := strconv.FormatFloat(val, 'f', 3, 64) |
| 155 | return result + unit |
| 156 | } |
| 157 | |
| 158 | return d.String() |
| 159 | } |
| 160 | |
| 161 | func protoToString(proto EthrProtocol) string { |
| 162 | switch proto { |
no outgoing calls
no test coverage detected