Click here to Skip to main content
       

C / C++ / MFC

 
QuestionHow Can I set Noise In Image ? Pinmemberyogeshs14-Mar-13 19:25 
AnswerRe: How Can I set Noise In Image ? PinmemberMarco Bertschi14-Mar-13 22:21 
AnswerRe: How Can I set Noise In Image ? Pinmembernv316-Mar-13 2:16 
QuestiontimeGetTime() is unreliable on my computer too, not monotonic! [modified] PinmemberRobert Inventor14-Mar-13 18:04 
AnswerMessage Removed PinmemberRobert Inventor14-Mar-13 18:15 
GeneralMessage Removed PinmemberRobert Inventor14-Mar-13 18:20 
GeneralMessage Removed PinmemberRobert Inventor14-Mar-13 18:53 
GeneralMessage Removed PinmemberRobert Inventor14-Mar-13 19:19 
AnswerRe: timeGetTime() is unreliable on my computer too, not monotonic! PinmemberRobert Inventor19-Mar-13 7:31 
QuestionQueryPerformanceCounter inaccurate timing even with use of SetThreadAffinityMask PinmemberRobert Inventor14-Mar-13 15:50 
AnswerRe: QueryPerformanceCounter inaccurate timing even with use of SetThreadAffinityMask PinmemberRobert Inventor14-Mar-13 18:07 
GeneralRe: QueryPerformanceCounter inaccurate timing even with use of SetThreadAffinityMask Pinmemberdusty_dex15-Mar-13 0:24 
GeneralRe: QueryPerformanceCounter inaccurate timing even with use of SetThreadAffinityMask PinmemberRobert Inventor18-Mar-13 14:44 
GeneralRe: QueryPerformanceCounter inaccurate timing even with use of SetThreadAffinityMask [modified] Pinmemberdusty_dex18-Mar-13 22:08 
If you're seeing 15ms then I'm pretty sure that's the thread 'quantum' of Windows scheduling. It used to be 10ms on Windows NT 4.0
 
I've encountered this problem too. The best you can do is to not bother with the high perf counters, as they're still at the mercy of scheduler. All I do is get the average of about 3-5 readings, but the trick seems to be to put the thread to sleep until the next exact second (1000-current_millisecond) and repeat with timing durations less than the scheduling quantum. Which means it will take 3 - 4 seconds to get your average. Put thread into realtime priority, which should reduce preemption. (if you're confident that your timing-code is free of bugs)
 
sleep until msec:000, timing loop < 15ms
 
repeat as many times as you need to, the cpu scaling of some processors creates problems with initial result, so be prepared to discard the first and second result or ramp up the cpu to 100%.
 
If it's any consolation it's the same problem with any pre-emptive OS, but also disappointing to know that xGHz machines can't give you a reliable reading from within a modern OS. Linux calculates the timing before it boots.
"It's true that hard work never killed anyone. But I figure, why take the chance." - Ronald Reagan
 
That's what machines are for.
 
Got a problem?
Sleep on it.


modified 19-Mar-13 7:12am.

AnswerRe: QueryPerformanceCounter inaccurate timing even with use of SetThreadAffinityMask PinmemberRobert Inventor19-Mar-13 6:19 
GeneralRe: QueryPerformanceCounter inaccurate timing even with use of SetThreadAffinityMask Pinmemberdusty_dex19-Mar-13 8:34 
GeneralRe: QueryPerformanceCounter inaccurate timing even with use of SetThreadAffinityMask PinmemberRobert Inventor20-Mar-13 10:10 
GeneralRe: QueryPerformanceCounter inaccurate timing even with use of SetThreadAffinityMask PinmemberRobert Inventor20-Mar-13 11:12 
GeneralRe: QueryPerformanceCounter inaccurate timing even with use of SetThreadAffinityMask Pinmemberdusty_dex20-Mar-13 11:18 
GeneralRe: QueryPerformanceCounter inaccurate timing even with use of SetThreadAffinityMask PinmemberRobert Inventor20-Mar-13 12:15 
QuestionHelp in Win32 programming with c++ Pinmembernaseer86114-Mar-13 8:44 
AnswerRe: Help in Win32 programming with c++ PinmemberThePhantomUpvoter14-Mar-13 8:50 
GeneralRe: Help in Win32 programming with c++ Pinmembernaseer86118-Mar-13 9:41 
AnswerRe: Help in Win32 programming with c++ PinmemberMaximilien14-Mar-13 8:54 
AnswerRe: Help in Win32 programming with c++ PinmemberPravinda Amarathunge16-Mar-13 2:55 
QuestionNeed a free image library, png, Visual Studio 6.0 PinmemberAndrlage14-Mar-13 5:52 
AnswerRe: Need a free image library, png, Visual Studio 6.0 PinmvpRichard MacCutchan14-Mar-13 6:22 
AnswerRe: Need a free image library, png, Visual Studio 6.0 PinmemberFlaviu214-Mar-13 21:19 
QuestionMSCOWRKS.DLL ? PinmemberForNow13-Mar-13 3:10 
AnswerRe: MSCOWRKS.DLL ? PinmvpRichard MacCutchan13-Mar-13 3:53 
GeneralRe: MSCOWRKS.DLL ? PinmemberForNow13-Mar-13 4:12 
AnswerRe: MSCOWRKS.DLL ? PinmemberAlbert Holguin13-Mar-13 5:33 
QuestionHow to fix Static contol width at run time? [modified] PinmemberLe@rner12-Mar-13 20:52 
AnswerRe: How to fix Static contol width at run time? PinmvpRichard MacCutchan12-Mar-13 22:22 
GeneralRe: How to fix Static contol width at run time? PinmemberLe@rner13-Mar-13 1:25 
AnswerRe: How to fix Static contol width at run time? PinmemberParthi_Appu13-Mar-13 1:47 
GeneralRe: How to fix Static contol width at run time? PinmemberLe@rner13-Mar-13 2:01 
QuestionCannot access #include files – “permission denied” [modified] PinmemberMember 990306512-Mar-13 0:42 
AnswerRe: Cannot access #include files – “permission denied” [modified] PinmvpRichard MacCutchan12-Mar-13 1:11 
AnswerRe: Cannot access #include files – “permission denied” [modified] PinmemberOrjan Westin12-Mar-13 1:13 
QuestionRe: Cannot access #include files – “permission denied” [modified] PinmvpRichard MacCutchan12-Mar-13 2:18 
QuestionBitmap creation from a buffer recived PinmemberMember 990306512-Mar-13 0:26 
AnswerRe: Bitmap creation from a buffer recived PinmvpRichard MacCutchan12-Mar-13 1:13 
Questionunable to register COM dll 64 bit PinmemberMember 990306512-Mar-13 0:24 
AnswerRe: unable to register COM dll 64 bit PinmvpRichard MacCutchan12-Mar-13 1:15 
AnswerRe: unable to register COM dll 64 bit [modified] Pinmemberdusty_dex12-Mar-13 5:16 
QuestionPlay Media File PinmemberMember 990306512-Mar-13 0:23 
AnswerRe: Play Media File PinmvpRichard MacCutchan12-Mar-13 1:19 
QuestionHow to find out if a file is loaded in memory? Pinmemberdliviu11-Mar-13 23:01 
AnswerRe: How to find out if a file is loaded in memory? PinmvpCPallini11-Mar-13 23:27 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.


Advertise | Privacy | Mobile
Web04 | 2.8.140721.1 | Last Updated 30 Jul 2014
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid