[music-dsp] Re: music-dsp-digest V1 #1224
Alexander R Angas
wgd at internode.on.net
Wed Oct 24 20:31:45 EDT 2001
Thanks! That could be really handy.
> Date: Wed, 24 Oct 2001 10:20:02 -0700
> From: "Jon Watte" <hplus at mindcontrol.org>
> Subject: RE: [music-dsp] Timing in Windoze
> > Another, higher resolution timing option if we are
> > talking Win2000 is QueryPerformanceCounter(). Check
> > the following snippet:
> > LARGE_INTEGER tim, freq;
> > double seconds;
> > QueryPerformanceCounter(&tim);
> > QeryPerformanceFrequency(&freq);
> > seconds = (double)tim / (double) freq;
> QueryPerformanceCounter() is available on most Windows these days (for
> on 98 and up) as long as you have a PCI chipset.
> The problem with QPC is that it appears to use some chipset timer which
> takes something like a PCI latency timer window to read, so the minimum
> execution time is a full microsecond; on my machine it takes two
> microseconds to run (I believe it's an actual system call, too).
> If you want very low-latency, very accurate measurements of time, use the
> "rdtsc" assembly instruction. It's available from the Pentium on up (an
> on AMD chips). It increments one by each CPU clock tick, so for a 1 GHz
> machine, it measures nanoseconds. If you're using NASM, here's some
> ; extern __int64 __cdecl read_rdtsc( );
> GLOBAL _read_rdtsc
> Here's some MSVC source:
> static __int64 __cdecl __declspec(naked) read_rdtsc( )
> The instruction returns a quadword with the upper 32 bits in EDX, the
> 32 in EAX, which happens to match the calling convention for 64-bit
> integers. Convenient, huh?
> The PowerPC has a similar instruction. QuickTime exposes a massaged
> of it using the Microseconds() routine.
> / h+
dupswapdrop -- the music-dsp mailing list and website: subscription info,
FAQ, source code archive, list archive, book reviews, dsp links
More information about the music-dsp