rounded returns nanos rounded to the nearest microsecond.
(nanos int64)
| 135 | |
| 136 | // rounded returns nanos rounded to the nearest microsecond. |
| 137 | func rounded(nanos int64) int64 { |
| 138 | dur := time.Duration(nanos) * time.Nanosecond |
| 139 | v := dur.Round(time.Microsecond).Nanoseconds() |
| 140 | // Near the boundaries of int64 will return the argument unchanged. Check |
| 141 | // for those cases and truncate instead of round so that we never have nanos. |
| 142 | if m := v % nanosInMicro; m != 0 { |
| 143 | v -= m |
| 144 | } |
| 145 | return v |
| 146 | } |
| 147 | |
| 148 | // Compare returns an integer representing the relative length of two Durations. |
| 149 | // The result will be 0 if d==x, -1 if d < x, and +1 if d > x. |
no test coverage detected
searching dependent graphs…