Click here to Skip to main content
15,795,402 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: QueryPerformanceCounter inaccurate timing even with use of SetThreadAffinityMask Pin
Robert Inventor14-Mar-13 19:07
Robert Inventor14-Mar-13 19:07 
GeneralRe: QueryPerformanceCounter inaccurate timing even with use of SetThreadAffinityMask Pin
dusty_dex15-Mar-13 1:24
dusty_dex15-Mar-13 1:24 
GeneralRe: QueryPerformanceCounter inaccurate timing even with use of SetThreadAffinityMask Pin
Robert Inventor18-Mar-13 15:44
Robert Inventor18-Mar-13 15:44 
GeneralRe: QueryPerformanceCounter inaccurate timing even with use of SetThreadAffinityMask Pin
dusty_dex18-Mar-13 23:08
dusty_dex18-Mar-13 23:08 
AnswerRe: QueryPerformanceCounter inaccurate timing even with use of SetThreadAffinityMask Pin
Robert Inventor19-Mar-13 7:19
Robert Inventor19-Mar-13 7:19 
GeneralRe: QueryPerformanceCounter inaccurate timing even with use of SetThreadAffinityMask Pin
dusty_dex19-Mar-13 9:34
dusty_dex19-Mar-13 9:34 
GeneralRe: QueryPerformanceCounter inaccurate timing even with use of SetThreadAffinityMask Pin
Robert Inventor20-Mar-13 11:10
Robert Inventor20-Mar-13 11:10 
GeneralRe: QueryPerformanceCounter inaccurate timing even with use of SetThreadAffinityMask Pin
Robert Inventor20-Mar-13 12:12
Robert Inventor20-Mar-13 12:12 
Oh - still getting those reversed times

C++
static Spec_Thread double ddwt_was;
if(ddwt_was!=0)
if(ddwt<ddwt_was)
 ddwt=ddwt;
ddwt_was=ddwt;


C++
ddwt    22589372.894629
ddwt_was    22589372.895075


And this is fixed using:

C++
{
  DWORD threadAffMask=SetThreadAffinityMask(GetCurrentThread(),1);
  QueryPerformanceCounter(&HPT_PerformanceCount);
  SetThreadAffinityMask(GetCurrentThread(),threadAffMask );
}


So - seems - that code actually does work, you don't need to do it for the entire thread, just with every call as in the example code.

Sorry for the confusion.

So - seems - here anyway - that you can get time reversals if you let the time be measured on any core.

You avoid them if you access the interrupt timer via KUSER_SHARED_DATA though that doesn't have the same resolution on my computer as the QueryPerformanceCounter (only changes every 1ms - though it seems likely that it reports the exact time at the moment that it changes - so you could time an exact ms by just waiting in a busy loop for it to change).

But to get the clocks running at a constant rate you need to force the OS to use HPET. Doesn't seem to be anyway for a program to access HPET if Windows isn't using it as far as I can see anyway.

HPET is guaranteed, on Intel machines anyway, to be accurate to 0.05 % over 1 ms and

http://www.intel.com/content/dam/www/public/us/en/documents/technical-specifications/software-developers-hpet-spec-1-0a.pdf[^]
GeneralRe: QueryPerformanceCounter inaccurate timing even with use of SetThreadAffinityMask Pin
dusty_dex20-Mar-13 12:18
dusty_dex20-Mar-13 12:18 
GeneralRe: QueryPerformanceCounter inaccurate timing even with use of SetThreadAffinityMask Pin
Robert Inventor20-Mar-13 13:15
Robert Inventor20-Mar-13 13:15 
QuestionHelp in Win32 programming with c++ Pin
naseer86114-Mar-13 9:44
naseer86114-Mar-13 9:44 
AnswerRe: Help in Win32 programming with c++ Pin
NotPolitcallyCorrect14-Mar-13 9:50
NotPolitcallyCorrect14-Mar-13 9:50 
GeneralRe: Help in Win32 programming with c++ Pin
naseer86118-Mar-13 10:41
naseer86118-Mar-13 10:41 
AnswerRe: Help in Win32 programming with c++ Pin
Maximilien14-Mar-13 9:54
Maximilien14-Mar-13 9:54 
AnswerRe: Help in Win32 programming with c++ Pin
Captain Price16-Mar-13 3:55
professionalCaptain Price16-Mar-13 3:55 
QuestionNeed a free image library, png, Visual Studio 6.0 Pin
Andrlage14-Mar-13 6:52
Andrlage14-Mar-13 6:52 
AnswerRe: Need a free image library, png, Visual Studio 6.0 Pin
Richard MacCutchan14-Mar-13 7:22
mveRichard MacCutchan14-Mar-13 7:22 
AnswerRe: Need a free image library, png, Visual Studio 6.0 Pin
_Flaviu14-Mar-13 22:19
_Flaviu14-Mar-13 22:19 
QuestionMSCOWRKS.DLL ? Pin
ForNow13-Mar-13 4:10
ForNow13-Mar-13 4:10 
AnswerRe: MSCOWRKS.DLL ? Pin
Richard MacCutchan13-Mar-13 4:53
mveRichard MacCutchan13-Mar-13 4:53 
GeneralRe: MSCOWRKS.DLL ? Pin
ForNow13-Mar-13 5:12
ForNow13-Mar-13 5:12 
AnswerRe: MSCOWRKS.DLL ? Pin
Albert Holguin13-Mar-13 6:33
professionalAlbert Holguin13-Mar-13 6:33 
QuestionHow to fix Static contol width at run time? Pin
Le@rner12-Mar-13 21:52
Le@rner12-Mar-13 21:52 
AnswerRe: How to fix Static contol width at run time? Pin
Richard MacCutchan12-Mar-13 23:22
mveRichard MacCutchan12-Mar-13 23:22 
GeneralRe: How to fix Static contol width at run time? Pin
Le@rner13-Mar-13 2:25
Le@rner13-Mar-13 2:25 

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

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