Re: Displaying time
Re: Displaying time
- Subject: Re: Displaying time
- From: Negm-Awad Amin <email@hidden>
- Date: Fri, 22 Aug 2008 16:11:05 +0200
Sorry for sending the responds solely to Graham:
Am Fr,22.08.2008 um 15:53 schrieb Graham Cox:
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,
If he needs 1/100 precision you would prefer to set-up a timer firing
100 times in a second. Probably this will burn more performance.
stealing cycles from the rest of the app, and it's more complex.
Just set the timer rate to the acceptable delay you want.
What is it? If the acceptable delay becomes smaller, incresing the
event frequency makes your solution worse and worse.
It's a straightforward application of Nyquist's Sampling Theorem -
sample at twice the fastest event you want to capture, which is 1
second.
Nyquist's theorem can lead to a phase shift. This is the problem in
the case of the TS.
Beside this Nyquist's theorem requests an ideal filter. He doesn't
have any filter.
We have a phase-lock problem.
Thus, go at twice per second, plus a little bit to avoid getting
locked into a constant delay (or faster still).
Why not going a little bit faster then 1 second?
The CPU will sleep between firings and a few Hz isn't a big deal, so
this is far simpler and plays nicer.
If you implement a software PLL with some additional engagement, you
simply measure the gap to the "full second" and recalculate the next
interval.
This is what a analog PLL do, when it loads/unloads a ramp.
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?
If the system is busy, every timer-based solution will fail, because
the timer does not guarante nothing of none.
Graham
Cheers,
Amin Negm-Awad
_______________________________________________
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