Re: Displaying time
Re: Displaying time
- Subject: Re: Displaying time
- From: Graham Cox <email@hidden>
- Date: Fri, 22 Aug 2008 23:53:14 +1000
On 22 Aug 2008, at 11:39 pm, Negm-Awad Amin wrote:
I think, that a higher event-frequency is not neccessary. He should
use an interval of close to one second (something like 0.99
seconds). In his timer method he simply waits in a loop for the
"tick tack" and displays the result. So he will not have a constant
phase shift (except of the drawing interval).
Why wait in a loop? While it's doing that you're just burning up CPU
time for no good reason, stealing cycles from the rest of the app, and
it's more complex. Just set the timer rate to the acceptable delay you
want. It's a straightforward application of Nyquist's Sampling Theorem
- sample at twice the fastest event you want to capture, which is 1
second. Thus, go at twice per second, plus a little bit to avoid
getting locked into a constant delay (or faster still). The CPU will
sleep between firings and a few Hz isn't a big deal, so this is far
simpler and plays nicer.
If the system becomes busy (his application doesn't sound like
that), he maybe misses a second. That is acceptable if the system is
busy.
Says you, maybe it isn't acceptable to the OP?
Graham
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden