Re: capturing user reaction times in msecs
Re: capturing user reaction times in msecs
- Subject: Re: capturing user reaction times in msecs
- From: Nir Soffer <email@hidden>
- Date: Tue, 19 Dec 2006 22:16:58 +0200
On Dec 19, 2006, at 20:12, David Duncan wrote:
UInt64 startTime = UnsignedWideToUInt64(AbsoluteToNanoseconds
(UpTime()));
... do your thing...
UInt64 endTime = UnsignedWideToUInt64(AbsoluteToNanoseconds(UpTime
()));
UInt64 elapsedTime = (endTime - startTime); // elapsed time in
nanoseconds
You will get slightly more accurate timing with
AbsoluteTime startTime = UpTime();
... do your thing...
AbsoluteTime endTime = UpTime();
UInt64 elapsedTime = UnsignedWideToUInt64(AbsoluteToNanoseconds
(SubAbsoluteFromAbsolute(endTime, startTime)));
Or simpler:
Duration milliseconds = AbsoluteDeltaToDuration(startTime, endTime);
// For short durations (< 35 minutes), returns negative value in
microseconds
if (milliseconds < 0)
milliseconds /= -1000;
Best Regards,
Nir Soffer
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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