erlang time handling (in calendar.erl and erlang.erl)
Ulf Wiger (AL/EAB)
Mon Jan 31 13:46:11 CET 2005
On January 31 2005 11:28, Matthias Lang wrote:
> Rant Mode On.
> This clock fudging is my #2 pet peeve about Erlang.
> In Erlang, now() tries to solve all timing problems---it promises to
> track real time while still preserving intervals. For good measure, it
> also promises to return "continuously increasing" values (more
> commonly called "strictly increasing").
> The result is that nothing behaves when the user makes a dramatic
> adjustment to the time (1). Timeouts and intervals are off by 1% (2)
> and timestamps can be off by an arbitrarily large amount for an
> arbitrarily long time (3).
> Solutions? It's probably too late to fix now() since there's a lot of
> code out there depending on various, mutually incompatible aspects of
> its behaviour.
One thing that could be done, AFAIKT, is to fix the obvious dilemma
that erlang:now() is the _only_ time function available that offers
sub-second precision. I don't think presenting time down to millisecond
level creates any portability problems.
After that, I'm not aware of any good reasons to use erlang:now(),
perhaps apart from the nice feature that it is guaranteed to
produce increasing values. OTOH, this guarantee is offered by
ets:update_counter() as well.
> (2) This is particularly annoying when your system enters "Spinal
> Tap Emulation Mode" during a customer's stress testing, e.g.
> claiming that the load on a signalling link is 101%
So you mean that without this 1% adjustment made by erlang:now(),
you could measure the load on a signalling link with a margin of
error of less than 1%?
> Rant Mode Off.
More information about the erlang-questions