[erlang-questions] os:timestamp/0 and erlang:now/0
Fri Mar 13 20:41:50 CET 2015
Out of curiosity, why are you comparing os:timestamp() to erlang:now()?
There is a possibility that frequent calls to erlang:now() runs ahead of the
clock as it must deliver unique values (guaranteed) whereas os:timestamp()
does not have this property. This alone may produce the behaviour you are
seeing independent of other variables (eg: +c).
I wouldn't have considered either to be reasonably or easily comparable
each other. However, comparing one fun to precedent values returned by the
same fun should exhibit the relative behaviour you desire and correlate as
expect. But comparing os:timestamp to erlang:now doesn't seem supportable
as they behave differently by design.
Hence, curious as to your use case and why you are comparing these two
On Fri, Mar 13, 2015 at 7:23 PM, Karolis Petrauskas <>
> I have specified no special arguments for time correction, at least
> explicitly. `erlang:system_info(tolerant_timeofday).` returns
> It is very likely, that the system time was adjusted. Although the
> difference between now() and os:timestamp() is not decreasing and
> varies between 9.340 and 9.387 ms (I'm observing this for a half of
> the day already).
> On Fri, Mar 13, 2015 at 9:02 PM, Fred Hebert <> wrote:
> > Do you run any arguments regarding time correction (+c) ? The doc
> > mentions:
> > +c
> > Disable compensation for sudden changes of system time.
> > Normally, erlang:now/0 will not immediately reflect sudden
> > changes in the system time, in order to keep timers (including
> > receive-after) working. Instead, the time maintained by
> > erlang:now/0 is slowly adjusted towards the new system time.
> > (Slowly means in one percent adjustments; if the time is off by
> > one minute, the time will be adjusted in 100 minutes.)
> > When the +c option is given, this slow adjustment will not
> > take place. Instead erlang:now/0 will always reflect the
> > current system time. Note that timers are based on
> > erlang:now/0. If the system time jumps, timers then time out
> > at the wrong time.
> > NOTE: You can check whether the adjustment is enabled or
> > disabled by calling
> > erlang:system_info(tolerant_timeofday).
> > It is possible that time has drifted forwards a bit and for a period of
> > time, now() returns a time lagging behind os:timestamp() because it is
> > still compensating and catching up to the absolute time change.
> erlang-questions mailing list
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the erlang-questions