[erlang-bugs] erlang:monotonic_time() is negative

Rapsey rapsey@REDACTED
Tue Sep 1 15:51:12 CEST 2015


Oh ok. Thanks for the explanation.


Sergej

On Tue, Sep 1, 2015 at 3:43 PM, Jesper Louis Andersen <
jesper.louis.andersen@REDACTED> wrote:

>
> On Tue, Sep 1, 2015 at 2:20 PM, Sergej Jurečko <sergej.jurecko@REDACTED>
> wrote:
>
>> Using 18.0.3 on OS X 10.10.5. I even tried rebooting the machine to check
>> if the time turns negative after a while, but it seems it is always
>> negative.
>>
>> erlang:monotonic_time().
>> -576460736152226213
>>
>
> This is the normal behavior. In order to use the full 60 bit signed value,
> it is custom to start at a negative number when starting a new Erlang node:
>
> 1> os:type().
> {unix,freebsd}
> 2> erlang:monotonic_time().
> -576460743520961806
>
> 1> os:type().
> {unix,sunos}
> 2> erlang:monotonic_time().
> -576460744933281955
>
> And so on. You can only use monotonic_time() for doing checks relative to
> itself, as in:
>
> B = erlang:monotonic_time(),
> do_work(),
> E = erlang:monotonic_time(),
> Elapsed = erlang:convert_time_unit(E - B, native, micro_seconds),
> ...
>
> As Loic writes, check the document on time and time correction.
>
>
>
> --
> J.
>
> _______________________________________________
> erlang-bugs mailing list
> erlang-bugs@REDACTED
> http://erlang.org/mailman/listinfo/erlang-bugs
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-bugs/attachments/20150901/c5130b02/attachment.htm>


More information about the erlang-bugs mailing list