erlang:now() in erlang 4.9.1 on Linux

Pekka.Hedqvist <>
Wed Apr 19 06:30:58 CEST 2000


When trying to measure time we get really weird values from the
'erlang:now()' when two successive calls to it are done with less than
100 microseconds between the two calls. The values are far too low; 0,
1 microseconds are reported even when maybe 60-80 has passed. If the
calls are made further apart timewise they suddenly jump up to
reasonable represent the passed time (when > ~100 micro has passed).

For example, calling gettimeofday() in Linux directly every ~7 
microseconds also returns ~7 micro each time. 

Looking at the erl_time_sup.c one sees that it builds without
gethrtime() (since its not available in plain Linux) and with the
'CORRECT_USING_TIMES' defined. 'erlang:now()' results in a call to
get_tolerant_timeofday(void) which does a number of things, some
regarding internal erlang timing etc.

I asume (hopefully) that the get_tolerant_timeofday(void) does the
right things regarding Erlangs internal view of time, but is its
side-effect on functions like erlang:now() really desirable?  
If so, how is one to measure time in a way that avoids these "jumps"?  
Write a linked in driver calling gettimeofday() directly etc..?

Ideas, oppinions?

/pekka



More information about the erlang-questions mailing list