Interpreting timestamp value

Post questions, comments and feedback to our 3Dconnexion Mac Development Team.

Moderator: Moderators

Post Reply
mbp
Posts: 2
Joined: Tue Sep 04, 2007 9:04 pm

Interpreting timestamp value

Post by mbp » Tue Sep 04, 2007 9:18 pm

I would like to ignore SpaceNavigator events if they are stale, however clock_get_uptime seems to be a kernel function with no userland equivalent. How do I interpret the timestamp value in a Cocoa app and compare it with the current time?

flomotan
Moderator
Moderator
Posts: 287
Joined: Mon Jan 08, 2007 3:37 pm

Post by flomotan » Thu Sep 06, 2007 2:24 pm

You can use mach_absolute_time to get the current time. When comparing the two times, don't do an absolute equality check (i.e. time_now == event_time) as this will always fail since there will be some elapsed processing time between the event_time and time_now.

neuronaut
Posts: 1
Joined: Thu Oct 11, 2007 3:05 pm
Location: Mainz, Germany

Post by neuronaut » Thu Oct 11, 2007 3:16 pm

Hi all,

quick question in response to the previous posting: are you taking into account that mach_absolute_time is CPU dependent? This is not really a clock... so I am wondering if this wouldn't create problems on Intel vs. PPC Macs where mach_absolute_time behaves differently if you're relying on a constant threshold when discarding events...

Best wishes
--smb

flomotan
Moderator
Moderator
Posts: 287
Joined: Mon Jan 08, 2007 3:37 pm

Post by flomotan » Thu Oct 11, 2007 9:19 pm

Yeah, you'd normally want to normalize the value you get back from mach_absolute_time before using it to measure elapsed time. Here's a note from apple http://developer.apple.com/qa/qa2004/qa1398.html

davecotter
Posts: 20
Joined: Tue Mar 11, 2008 10:36 pm

Post by davecotter » Thu Apr 12, 2012 11:20 am

see this thread for some actual code to answer this question:

viewtopic.php?t=3419

Post Reply