Skip to content

Commit b9a0497

Browse files
authored
clarify that time_ns is monotonic (#57129)
1 parent 208560b commit b9a0497

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

base/Base_compiler.jl

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -188,8 +188,12 @@ end
188188
"""
189189
time_ns()::UInt64
190190
191-
Get the time in nanoseconds relative to some arbitrary time in the past. The primary use is for measuring the elapsed time
192-
between two moments in time.
191+
Get the time in nanoseconds relative to some machine-specific arbitrary time in the past.
192+
The primary use is for measuring elapsed times during program execution. The return value is guaranteed to
193+
be monotonic (mod 2⁶⁴) while the system is running, and is unaffected by clock drift or changes to local calendar time,
194+
but it may change arbitrarily across system reboots or suspensions.
195+
196+
(Although the returned time is always in nanoseconds, the timing resolution is platform-dependent.)
193197
"""
194198
time_ns() = ccall(:jl_hrtime, UInt64, ())
195199

0 commit comments

Comments
 (0)