Re: Observing Time

2013-07-27 Thread Scott Ribe
On Jul 27, 2013, at 7:29 AM, dangerwillrobinsondan...@gmail.com wrote: k so I went and looked at sys/time.h and friends and the man page for gettimeofday() And now understand how this struct works. It's literally the same as the NSDate method timeIntervalSince1970 The only difference is

Re: Observing Time

2013-07-27 Thread dangerwillrobinsondanger
On Jul 27, 2013, at 11:37 PM, Ken Thomases k...@codeweavers.com wrote: On Jul 27, 2013, at 8:29 AM, dangerwillrobinsondan...@gmail.com wrote: Ok so I went and looked at sys/time.h and friends and the man page for gettimeofday() And now understand how this struct works. It's literally

Re: Observing Time

2013-07-27 Thread dangerwillrobinsondanger
On Jul 27, 2013, at 11:46 PM, Scott Ribe scott_r...@elevated-dev.com wrote: On Jul 27, 2013, at 7:29 AM, dangerwillrobinsondan...@gmail.com wrote: k so I went and looked at sys/time.h and friends and the man page for gettimeofday() And now understand how this struct works. It's

Re: Observing Time

2013-07-27 Thread Scott Ribe
On Jul 27, 2013, at 9:15 AM, dangerwillrobinsondan...@gmail.com wrote: But I'm avoiding NSTimer because I want to avoid being run looped in completely Why??? If the run loop on the main thread is busy, your display won't update anyway. I think you're adding a lot of complexity for 0 gain.

Re: Observing Time

2013-07-27 Thread dangerwillrobinsondanger
On 2013/07/28, at 0:38, Scott Ribe scott_r...@elevated-dev.com wrote: On Jul 27, 2013, at 9:15 AM, dangerwillrobinsondan...@gmail.com wrote: But I'm avoiding NSTimer because I want to avoid being run looped in completely Why??? If the run loop on the main thread is busy, your display

Re: Observing Time

2013-07-27 Thread Kyle Sluder
On Sat, Jul 27, 2013, at 09:16 AM, dangerwillrobinsondan...@gmail.com wrote: On 2013/07/28, at 0:38, Scott Ribe scott_r...@elevated-dev.com wrote: On Jul 27, 2013, at 9:15 AM, dangerwillrobinsondan...@gmail.com wrote: But I'm avoiding NSTimer because I want to avoid being run looped in

Re: Observing Time

2013-07-27 Thread Scott Ribe
On Jul 27, 2013, at 10:16 AM, dangerwillrobinsondan...@gmail.com wrote: Why would I add to slowing down the main thread when I can run a dispatch_timer on another thread and get the timer to fire more reliably? That doesn't make sense. What's going to slow down the main thread??? Certainly

Re: Observing Time

2013-07-27 Thread dangerwillrobinsondanger
On 2013/07/28, at 1:35, Kyle Sluder k...@ksluder.com wrote: On Sat, Jul 27, 2013, at 09:16 AM, dangerwillrobinsondan...@gmail.com wrote: On 2013/07/28, at 0:38, Scott Ribe scott_r...@elevated-dev.com wrote: On Jul 27, 2013, at 9:15 AM, dangerwillrobinsondan...@gmail.com wrote: But

Re: Observing Time

2013-07-27 Thread Scott Ribe
On Jul 27, 2013, at 5:53 PM, dangerwillrobinsondan...@gmail.com wrote: I just tried both approaches and guess which one stays right there with the menu bar clock and which one lags? dispatch timer is the winner. And it's not doing a lot. I think you must be doing something wrong. NSTimer

Re: Observing Time

2013-07-27 Thread Andy Lee
On Jul 27, 2013, at 7:53 PM, dangerwillrobinsondan...@gmail.com wrote: I just tried both approaches and guess which one stays right there with the menu bar clock and which one lags? dispatch timer is the winner. And it's not doing a lot. I built a test app for each approach to verify.

Re: Observing Time

2013-07-27 Thread dangerwillrobinsondanger
On 2013/07/28, at 8:57, Scott Ribe scott_r...@elevated-dev.com wrote: On Jul 27, 2013, at 5:53 PM, dangerwillrobinsondan...@gmail.com wrote: I just tried both approaches and guess which one stays right there with the menu bar clock and which one lags? dispatch timer is the winner. And

Re: Observing Time

2013-07-27 Thread Andy Lee
On Jul 27, 2013, at 9:43 PM, dangerwillrobinsondan...@gmail.com wrote: But with that I still see a faint lag that seems to update just a hair slower than the dispatch timer. Noticeable to me at least, I'll post a link to the sample projects in a bit. FWIW I created a quick test app using

Re: Observing Time

2013-07-27 Thread Scott Ribe
On Jul 27, 2013, at 7:43 PM, dangerwillrobinsondan...@gmail.com wrote: Hmm. Initially I did miss the method initWithFireDate:interval:target:selector:userInfo:repeats: That alone makes all the difference over the class factory methods by giving a determined start time. Now, combine that

Re: Observing Time

2013-07-27 Thread Andy Lee
On Jul 27, 2013, at 9:57 PM, Andy Lee ag...@mac.com wrote: I'm trying again, this time creating a new NSTimer each time as suggested by Scott Ribe. Will let it run a while and see if I notice any drift. Looks pretty solid after several minutes -- as I would expect. To repeat Scott's

Re: Observing Time

2013-07-27 Thread dangerwillrobinsondanger
Except for the reschedule after each fire, and the CFAbsoluteTimeGetCurrent call This is pretty much what I tried. I had done it with [[NSDate date] timeIntervalSince1970] which might be a hair longer than a CF call. I will give it a whirl with this approach and compare. At this point it's

Re: Observing Time

2013-07-27 Thread Scott Ribe
On Jul 27, 2013, at 7:57 PM, Andy Lee ag...@mac.com wrote: I'm trying again, this time creating a new NSTimer each time as suggested by Scott Ribe. Will let it run a while and see if I notice any drift. FYI, I think that's fine. You could also take the approach of using a single timer, and

Re: Observing Time

2013-07-27 Thread Andy Lee
On Jul 27, 2013, at 11:05 PM, Scott Ribe scott_r...@elevated-dev.com wrote: On Jul 27, 2013, at 7:57 PM, Andy Lee ag...@mac.com wrote: I'm trying again, this time creating a new NSTimer each time as suggested by Scott Ribe. Will let it run a while and see if I notice any drift. FYI, I

Re: Observing Time

2013-07-26 Thread Ken Thomases
On Jul 25, 2013, at 11:37 PM, dangerwillrobinsondan...@gmail.com wrote: On Jul 26, 2013, at 12:09 PM, Ken Thomases k...@codeweavers.com wrote: Also, the above code doesn't adjust the timer to fire on the second as Rick suggested. You're asking it to fire every so many seconds

Re: Observing Time

2013-07-26 Thread Scott Ribe
On Jul 26, 2013, at 7:06 AM, Ken Thomases k...@codeweavers.com wrote: On Jul 25, 2013, at 11:37 PM, dangerwillrobinsondan...@gmail.com wrote: On Jul 26, 2013, at 12:09 PM, Ken Thomases k...@codeweavers.com wrote: Also, the above code doesn't adjust the timer to fire on the second as Rick

Re: Observing Time

2013-07-26 Thread Steve Sisak
At 7:36 AM -0600 7/26/13, Scott Ribe wrote: On Jul 26, 2013, at 7:06 AM, Ken Thomases k...@codeweavers.com wrote: On Jul 25, 2013, at 11:37 PM, dangerwillrobinsondan...@gmail.com wrote: On Jul 26, 2013, at 12:09 PM, Ken Thomases k...@codeweavers.com wrote: Also, the above code doesn't

Re: Observing Time

2013-07-26 Thread dangerwillrobinsondanger
On Jul 26, 2013, at 10:06 PM, Ken Thomases k...@codeweavers.com wrote: On Jul 25, 2013, at 11:37 PM, dangerwillrobinsondan...@gmail.com wrote: On Jul 26, 2013, at 12:09 PM, Ken Thomases k...@codeweavers.com wrote: Also, the above code doesn't adjust the timer to fire on the second as Rick

Re: Observing Time

2013-07-26 Thread dangerwillrobinsondanger
On Jul 26, 2013, at 10:36 PM, Scott Ribe scott_r...@elevated-dev.com wrote: On Jul 26, 2013, at 7:06 AM, Ken Thomases k...@codeweavers.com wrote: On Jul 25, 2013, at 11:37 PM, dangerwillrobinsondan...@gmail.com wrote: On Jul 26, 2013, at 12:09 PM, Ken Thomases k...@codeweavers.com

Re: Observing Time

2013-07-26 Thread Uli Kusterer
On Jul 26, 2013, at 4:22 PM, dangerwillrobinsondan...@gmail.com wrote: On Jul 26, 2013, at 10:36 PM, Scott Ribe scott_r...@elevated-dev.com wrote: On Jul 26, 2013, at 7:06 AM, Ken Thomases k...@codeweavers.com wrote: On Jul 25, 2013, at 11:37 PM, dangerwillrobinsondan...@gmail.com

Re: Observing Time

2013-07-26 Thread Scott Ribe
On Jul 26, 2013, at 8:13 AM, Steve Sisak sgs-li...@codewell.com wrote: It's worth noting that's very energy inefficient. Once the WWDC sessions are back on line, watch the energy efficiency sessions to see what's happening with timers in Mavericks. Yes. The only place I've deployed

Re: Observing Time

2013-07-26 Thread dangerwillrobinsondanger
On 2013/07/27, at 0:26, Scott Ribe scott_r...@elevated-dev.com wrote: On Jul 26, 2013, at 8:13 AM, Steve Sisak sgs-li...@codewell.com wrote: It's worth noting that's very energy inefficient. Once the WWDC sessions are back on line, watch the energy efficiency sessions to see what's

Re: Observing Time

2013-07-26 Thread Kyle Sluder
On Jul 26, 2013, at 8:36 AM, dangerwillrobinsondan...@gmail.com wrote: On 2013/07/27, at 0:26, Scott Ribe scott_r...@elevated-dev.com wrote: On Jul 26, 2013, at 8:13 AM, Steve Sisak sgs-li...@codewell.com wrote: It's worth noting that's very energy inefficient. Once the WWDC

Re: Observing Time

2013-07-26 Thread Steve Sisak
At 12:36 AM +0900 7/27/13, dangerwillrobinsondan...@gmail.com wrote: On 2013/07/27, at 0:26, Scott Ribe scott_r...@elevated-dev.com wrote: On Jul 26, 2013, at 8:13 AM, Steve Sisak sgs-li...@codewell.com wrote: It's worth noting that's very energy inefficient. Once the WWDC sessions are

Observing Time

2013-07-25 Thread dangerwillrobinsondanger
Hi all Is there something obvious I am missing, or is there no Cocoa API for observing the current time? I've found dispatch_timer to be reasonably accurate in doing this, but naturally lagging a little. The interval is pretty reliable, but I wonder if there is a hook to the time as updated

Re: Observing Time

2013-07-25 Thread Rick Mann
On Jul 25, 2013, at 18:52 , dangerwillrobinsondan...@gmail.com wrote: I'm getting about a half second lag behind the system clock. This is actually reasonable for my purposes, but I wonder if I'm missing something that might be more in sync. You can do this using NSTimers, but you need to

Re: Observing Time

2013-07-25 Thread dangerwillrobinsondanger
On Jul 26, 2013, at 11:08 AM, Rick Mann rm...@latencyzero.com wrote: On Jul 25, 2013, at 18:52 , dangerwillrobinsondan...@gmail.com wrote: I'm getting about a half second lag behind the system clock. This is actually reasonable for my purposes, but I wonder if I'm missing something

Re: Observing Time

2013-07-25 Thread Ken Thomases
On Jul 25, 2013, at 9:26 PM, dangerwillrobinsondan...@gmail.com wrote: Yep, I know of these, but this is tied to the run loop and timers on the runloop can be delayed. The reason I went with dispatch_timer is because it can be done with its own thread and if I understand correctly, frees it

Re: Observing Time

2013-07-25 Thread dangerwillrobinsondanger
On Jul 26, 2013, at 12:09 PM, Ken Thomases k...@codeweavers.com wrote: On Jul 25, 2013, at 9:26 PM, dangerwillrobinsondan...@gmail.com wrote: Yep, I know of these, but this is tied to the run loop and timers on the runloop can be delayed. The reason I went with dispatch_timer is because