[erlang-questions] os:timestamp/0 and erlang:now/0
Fri Mar 13 22:19:59 CET 2015
I'm glad you've found the right path. :)
The benchmark you came up with might be interesting to the temporally
obsessed on this list (such as myself) if you think it is worth posting.
You may have stumbled onto something unexpected or surprising that would
be worth analysing further. However, micro-benchmarking can often result
in learning as much or more about micro-benchmarking than the target
under the microscope.
On Fri, Mar 13, 2015 at 8:43 PM, Karolis Petrauskas <k.petrauskas@REDACTED>
> On Fri, Mar 13, 2015 at 9:41 PM, Darach Ennis <darach@REDACTED> wrote:
> > Hi Karolis,
> > Out of curiosity, why are you comparing os:timestamp() to erlang:now()?
> I found a bug in my software, related to the system time. Then I
> noticed mismatch of time values in the log messages and log
> timestamps. I expected that erlang:now() >= os:timestamp() at any
> point in time, but that rendered to be false. That's why I decided to
> ask this question here. My bugfix ended up by not using system time in
> that place at all.
> > There is a possibility that frequent calls to erlang:now() runs ahead of
> > clock as it must deliver unique values (guaranteed) whereas
> > does not have this property. This alone may produce the behaviour you are
> > seeing independent of other variables (eg: +c).
> Yes, but I observe the opposite.
> > I wouldn't have considered either to be reasonably or easily comparable
> > against
> > each other. However, comparing one fun to precedent values returned by
> > same fun should exhibit the relative behaviour you desire and correlate
> > you
> > expect. But comparing os:timestamp to erlang:now doesn't seem supportable
> > as they behave differently by design.
> Yes, that was the cause for the bug. I was taking system time
> (erlang:now()), truncating milliseconds from it and therefore got
> rounding errors increased to unexpected level. The following
> investigation is just because of curiosity.
> > Hence, curious as to your use case and why you are comparing these two
> > distinct functions.
> > Cheers,
> > Darach.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the erlang-questions