HighPerformanceCounter rounding

nobody_ spam at spam.spam
Thu Oct 26 12:00:49 PDT 2006

> Unfortunatly QPC does not always play nice with multicore as said in
> that article: "While the QueryPerformanceCounter / 
> QueryPerformanceFrequency API is intended to be multiprocessor aware, bugs 
> in the BIOS or motherboard drivers may result in these routines returning 
> different values as the thread moves from one processor to another. We 
> recommend that all game timing be computed on a single thread, and that 
> thread is set to stay running on a single processor through the 
> SetThreadAffinityMask Windows API."
> And then there is variable clock speed, buggy hardware. I sometimes have 
> leaps a few ms forward in time, seems to be a because of a defect in the 
> southbridge. Timing bugs are not fun...

You make timing sound even worse! :D
What the article is talking about, as you just quoted, is that faulty(buggy) 
hardware might not play nicely with multiple threads,
 making it more safe to just limit it to one thread.(You make it sound like 
those are two different problems :)
Variable clock speed shouldn't matter. QPC was invented for just that 
reason. It doesn't depent on only the cpu,
 but if possible also on other hardware timers.

> QueryPerformanceFrequency is only for checking counts per second, but 
> granularity of QPC should be good, it just can have some overhead per 
> call.

Knowing the frequency does let you know whether your cpu is being used or 
maybe something else.
I think I saw the function in the source code, so I could probably just call 
it somehow.

I hope this post doesn't sound to allknowing, as I just read 2 articles :D
and just needed the functions for a single computer...

More information about the Digitalmars-d-learn mailing list