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

James Hague james.hague@REDACTED
Fri Feb 20 15:22:43 CET 2009


>>I have a graphical application that runs at a fixed frame rate (60
>>frames per second).  The processing takes up part of the frame, then I
>>need to make sure that roughly 16,667 microseconds have passed before
>
> milliseconds, right?

No, microseconds.  It's more or less 16 milliseconds between updates.
I could live with good millisecond accuracy.

I'm still investigating alternatives.  My code communicates with an
external graphical client, and I could roll the timing into the client
easily enough (just block if updates are coming closet than 16ms
apart).  If that doesn't work I'll look at writing a linked-in driver
(which I've done before, and sure doesn't excite me...).

>But per my previous message, that should only happen if you manage to
>call it more than once per microsecond - unless gettimeofday() returns
>bizarre numbers.

On my MacBook, using a now/0 loop for a delay runs about 25% faster
than it should, so I'm clearly getting more than one call in per
microsecond, at least sometimes.



More information about the erlang-questions mailing list