MCPcopy Create free account
hub / github.com/auxten/postgresql-parser / rounded

Function rounded

pkg/util/duration/duration.go:137–146  ·  view source on GitHub ↗

rounded returns nanos rounded to the nearest microsecond.

(nanos int64)

Source from the content-addressed store, hash-verified

135
136// rounded returns nanos rounded to the nearest microsecond.
137func 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.

Callers 4

MakeDurationFunction · 0.85
SetNanosMethod · 0.85
roundMethod · 0.85
roundedMethod · 0.85

Calls 1

RoundMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…