|
-
February 20th, 2006, 10:53 AM
#1
Timers
I need a timer with resolution less than 1 millisecond. I have found the QueryPerformanceCounter API. It WOULD work great however the ticks between two successive QueryPerformanceCounter calls is far to great.
Is this because the app is only allowed a small sliver of processor time before it goes on to other processes? If so is there any way to give this application an extremely high priority so this time delta will decrease?
Thanks!
-
February 20th, 2006, 11:06 AM
#2
Re: Timers
http://www.codeguru.com/forum/showth...ormanceCounter
Perhaps there is something happening that is taking up time between the two counter calls like poorly framed socket communications or calls to cout or printf.
HTH,
ahoodin
Last edited by ahoodin; February 20th, 2006 at 11:10 AM.
-
February 20th, 2006, 11:30 AM
#3
Re: Timers
 Originally Posted by eeboy
I need a timer with resolution less than 1 millisecond. I have found the QueryPerformanceCounter API. It WOULD work great however the ticks between two successive QueryPerformanceCounter calls is far to great.
Is this because the app is only allowed a small sliver of processor time before it goes on to other processes? If so is there any way to give this application an extremely high priority so this time delta will decrease?
Thanks!
Look at Multimedia Timers.
Cheers
-
February 20th, 2006, 11:56 AM
#4
Re: Timers
That's just it... there is nothing executing in the background (except for any services). It's a modern PC (Pentium 4) as well.
Based on what I read with multimedia timers the best achievable time period is 1 ms. I need a time period on the order of 10 us.
-
February 20th, 2006, 02:19 PM
#5
Re: Timers
 Originally Posted by eeboy
That's just it... there is nothing executing in the background (except for any services). It's a modern PC (Pentium 4) as well.
Based on what I read with multimedia timers the best achievable time period is 1 ms. I need a time period on the order of 10 us.
Please simpley admit that you do not understand QueryPerformanceCounter(). It returns effectively the number of counts per second of the high performance counter. These are not clock ticks.
Here is your code.
Code:
LARGE_INTEGER ntime1,ntime2;
LARGE_INTEGER freq;
QueryPerformanceFrequency(&freq);//counts per second
QueryPerformanceCounter(&ntime1);
//do your op here
QueryPerformanceCounter(&ntime2);
nmicrosecs = ntime2.QuadPart-ntime1.QuadPart)/(freq.QuadPart/1000000);
Last edited by ahoodin; February 20th, 2006 at 02:21 PM.
-
February 20th, 2006, 03:03 PM
#6
Re: Timers
Well, I do understand the QueryPerformanceCounter() API. Ticks may not be the most appropriate wording... but a tick is a clock cycle which is quantified by the QueryPerformanceFrequency() function.... even though it's not the actual clock of the processor.
Your code yields the same results as mine.... around 100 us. I would expect to be able to achieve values right around or a little less than 1us since my frequency is 3579545 Hz.
Any more suggestions?
Thanks!
-
February 22nd, 2006, 07:20 AM
#7
Re: Timers
eeboy...
Sounds like you should post your code. You mean when you stuck your code inside the code I provided, it gave you the same results. I have gleaned sub 100 us data from that code, so it can't possibly be that code, so something else must be going on.
Remove all un-necessary files. Only include your .dsp and your source files. No class wizzard files, ncb files or any other junk. Zip it and attach it. Must have a small footprint or CG will reject.
ahoodin
Last edited by ahoodin; February 22nd, 2006 at 07:28 AM.
Reason: funny
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|