Quantcast

What is the value of time_ns() before it wraps?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

What is the value of time_ns() before it wraps?

Jeffrey Sarnoff
The help says "Get the time in nanoseconds. The time corresponding to 0 is undefined, and wraps every 5.8 years." I want to know the largest UInt64 value that time_ns() can return: the (nonzero) value which would be followed by 0x01%UInt64.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: What is the value of time_ns() before it wraps?

Jeffrey Sarnoff
On Thursday, November 24, 2016 at 11:30:36 PM UTC-5, Jeffrey Sarnoff wrote:
> The help says "Get the time in nanoseconds. The time corresponding to 0 is undefined, and wraps every 5.8 years." I want to know the largest UInt64 value that time_ns() can return: the (nonzero) value which would be followed by 0x01%UInt64.

Doing the math results in 0x028a4486a830c000 (5.8 years of nanoseconds).  That seems an unlikely max value -- which prompts this question.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: What is the value of time_ns() before it wraps?

Yichao Yu
On Fri, Nov 25, 2016 at 1:56 AM, Jeffrey Sarnoff
<[hidden email]> wrote:
> On Thursday, November 24, 2016 at 11:30:36 PM UTC-5, Jeffrey Sarnoff wrote:
>> The help says "Get the time in nanoseconds. The time corresponding to 0 is undefined, and wraps every 5.8 years." I want to know the largest UInt64 value that time_ns() can return: the (nonzero) value which would be followed by 0x01%UInt64.
>
> Doing the math results in 0x028a4486a830c000 (5.8 years of nanoseconds).  That seems an unlikely max value -- which prompts this question.


The doc string is very old.
https://github.com/JuliaLang/julia/commit/5e627b214c3601c5772530878b64693e7b66be15
And I'm not sure if it is accurate anymore. It is very likely platform
dependent. On Linux it's using clock_gettime(CLOCK_MONOTONIC) and I
didn't find anything that suggests it'll wrap around that fast on
64bits or 32bits.

"The time corresponding to 0 is undefined" also does not mean the
value followed by 1 is the max value. It is 0, just that it does not
represent any particular time, neither does any other values it
returns.

This function also does not give ns precision. So most likely it'll
never return 1

Finally, please stop posting to this list and use
https://discourse.julialang.org/ instead.
Loading...