[erlang-questions] writing a delay loop without now()

Fredrik Svahn fredrik.svahn@REDACTED
Sat Feb 21 22:23:00 CET 2009


I get the same results as James when running R12B-5 on Windows Vista. It
seems to be related to the algorithm for adjusting to sudden time changes.
When disabling it with the "+c" flag it works (almost) as expected.

C:\>"C:\Program Files\erl5.6.5\bin\erl"
Eshell V5.6.5  (abort with ^G)
1>
erlang:statistics(wall_clock),test:time(5000000),erlang:statistics(wall_clock).
{13276,3167}
2>
erlang:statistics(wall_clock),test:time(1000000),erlang:statistics(wall_clock).
{22184,640}

C:\>"C:\Program Files\erl5.6.5\bin\erl" +c
Eshell V5.6.5  (abort with ^G)
1>
erlang:statistics(wall_clock),test:time(5000000),erlang:statistics(wall_clock).
{19500,4992}
2>
erlang:statistics(wall_clock),test:time(1000000),erlang:statistics(wall_clock).
{27253,998}

(With Linux on the same machine I get the expected results no matter if I
run with or without the +c flag.)

BR /Fredrik




On Sat, Feb 21, 2009 at 5:48 PM, James Hague <james.hague@REDACTED> wrote:

> > Right, this demonstrates the dependency of timer:sleep/1...
> >
> > And as we also established, this has nothing to do with Erlang -
>
> Correct.  I just provided the numbers for os:sleep(1) and os:sleep(16)
> for reference.
>
> >
>  erlang:statistics(wall_clock),{test:time2(5000000),erlang:statistics(wall_clock)}.
> > {{1295305,5000001},{241916,5000}}
> >
> > I.e. on the order of one call every 3.9 microseconds => no now/0 bumping
> > occurs (you need to have more than one call per microsecond *on average*
> > for that to have an effect on the total).
>
> I get this:
>  {{4999999,5000000},{460636,1451}}
>
> This is using a 64-bit version of Window Vista, "Erlang (BEAM)
> emulator version 5.6.5 [smp:4] [async-threads:0]".
>
> I originally noticed this on a MacBook running OS X 10.4 (which is
> Tiger, not 10.5 Leopard), but I don't have timings yet.  I also tried
> disabling SMP on the Vista box, which gives:
> {{4999999,5000000},{153026,1247}}
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20090221/6840ebc4/attachment.htm>


More information about the erlang-questions mailing list