Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

re: Timing an activity



On Mon, 26 Jul 2004 20:18:38 -0600, Everett Sanmann
<email@hidden> wrote:
> I am attempting to implement a timer to record the time elapsed while an
> activity ( such as recording a track from a vinyl record) is proceeding. I
> found the following code snippet-posted by an Apple engineer-which I thought
> would be applicable:

Looks like my code.

> [BEGIN]
>
> AbsoluteTime start = UpTime();
>
> // stuff to be timed
> .
> .
> .
>
> AbsoluteTime stop = UpTime();
>
> AbsoluteTime delta = stop - start;
>
> double seconds = AbsoluteToNanoSeconds(delta) * 0.000000001f;
>
> [END]
>
> However, I found that "AbsoluteToNanoSeconds"-rather than returning a
> double, returns a UnsignedWide struct, consisting of UInt32 hi and UInt32
> lo. (Also, since Absolute time is the same struct, the compiler complains
> that stop and start and not valid variables) -(I did attempt to read the
> headers).

It's actually returning a 64-bit value. You can use the UnsignedWideToUInt64
macro to map between UnsignedWide's and UInt64's (they're in <Math64.h>).

double seconds = UnsignedWideToUInt64 (AbsoluteToNanoSeconds(delta)) *
0.000000001f;

> In my abysmal ignorance, I do not know how to convert this struct into a
> number which I can use.
> Am I completely on the wrong track?

Nope.

--
Enjoy,
George Warner,
Schizophrenic Optimization Scientist
Apple Developer Technical Support (DTS)
_______________________________________________
carbon-development mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/carbon-development
Do not post admin requests to the list. They will be ignored.




Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.