[erlang-questions] About erlang:statistics/1 and timeout values

Oscar Hellström oscar@REDACTED
Thu Apr 23 14:22:42 CEST 2009

mats cronqvist wrote:
> Oscar Hellström <oscar@REDACTED> writes:
>> Hi,
>> I was looking at statistics in the erlang module and found that
>> statistics(runtime) and statistics(wall_clock) returns something called
>> Time_Sinse_Last_Call. I assume that this is "since last call by the
>> calling process" and not a globally kept value. 
>   AFAIK, time since last call is per emulator, not per process. Thus,
>   it is worse than useless.
>   mats
Yes, you're right. The call from the spawned process probably happened
after the call from the shell process. This shows the actual behaviour:
29> spawn(fun() -> statistics(wall_clock) end), timer:sleep(10),

This is sad though, since it really does make it worse than useless. So,
back to (part of) the original question, how would we go about
decrementing a timeout value between blocking calls. I could use now
diffs, or erlang:start_timer/3... are there better ways?

BTW, what is the difference between erlang:start_timer/3 and
erlang:send_after/3. The documentation looks identical except a weird
detail in the type specification:
erlang:send_after(Time, Dest, Msg) -> TimerRef
Dest = pid() | RegName
LocalPid = pid() (of a process, alive or dead, on the local node)

Here LocalPid is never mentioned before...

erlang:start_timer(Time, Dest, Msg) -> TimerRef
Dest = LocalPid | RegName
LocalPid = pid() (of a process, alive or dead, on the local node)

This seems to want to say the same thing, but does it correctly.


Oscar Hellström, oscar@REDACTED
Office: +44 20 7655 0337
Mobile: +44 798 45 44 773
Erlang Training and Consulting Ltd

More information about the erlang-questions mailing list