rounded returns nanos rounded to the nearest microsecond.
(nanos int64)
| 160 | |
| 161 | // rounded returns nanos rounded to the nearest microsecond. |
| 162 | func rounded(nanos int64) int64 { |
| 163 | dur := time.Duration(nanos) * time.Nanosecond |
| 164 | v := dur.Round(time.Microsecond).Nanoseconds() |
| 165 | // Near the boundaries of int64 will return the argument unchanged. Check |
| 166 | // for those cases and truncate instead of round so that we never have nanos. |
| 167 | if m := v % nanosInMicro; m != 0 { |
| 168 | v -= m |
| 169 | } |
| 170 | return v |
| 171 | } |
| 172 | |
| 173 | // Compare returns an integer representing the relative length of two Durations. |
| 174 | // The result will be 0 if d==x, -1 if d < x, and +1 if d > x. |
no test coverage detected