[erlang-questions] Lockfree now()
Fri Jul 13 14:00:33 CEST 2012
On 07/13/2012 10:35 AM, Erik Søe Sørensen wrote:
> Oh, but you do have a choice between more than one time source in Erlang:
> now() - as known, for microsecond-precision and uniqueness
> erlang:universaltime() and friends - for second-precision and YMD-HMS
> os:timestamp() - for microsecond-precision but without uniqueness and
> time correction.
I didn't know that. Not that I ever looked thoroughly...
> For many places where you could use now() but simply need a timestamp
> for logging or the like, os:timestamp() might be more appropriate and
> a bit more lightweight. Its return type is compatible with that of now().
I just replaced calendar:now_to_datetime(erlang:now()) with
erlang:universaltime() in logging code and gained 13% performance. And
that machine is only dual-core.
More information about the erlang-questions