Measuring Time Using QueryPerformanceCounter() and QueryPerformanceFrequency()

preview_player
Показать описание
Game Engine Foundation-Jamie King showing how to measure the high-performance CPU clock to gain a high granularity in game time measurement.
Рекомендации по теме
Комментарии
Автор

Very helpful, thanks! Curiously, I'm getting better (faster) timing results using my platform's built-in timing functions to measure "Hello world" console writes. I didn't expect that.

ElectroLund
Автор

Please someone correct me if I'm wrong but I think when Jamie said the delta.quad part equaled 1.433 megahertz he really meant it equaled 1.433 KILOhertz (1433, in dollars as Jamie says, is one thousand four hundred thirty three, so kilo means 1, 000). This would make more sense as that debug statement shouldn't have taken half the time of the original total clock frequency.

bgzdevtips
Автор

should i activate the HPET (high performance event timer) in bios and windows?

mrGrad
Автор

2:17 lol!!! Yeah, Delta Airlines, good analogy

deltakid
Автор

Very cool! So it took 0.00043434757 seconds to execute that qDebug() statement, is how I interpret that debugger result.So this is then about 434 microseconds? Is that your understanding too Jamie?

bluehornet
Автор

why is my deltaseconds like 33000? Code is pretty much the same as yours.

mrrwsn
Автор

In Microsoft's documentation for QPC timers, it suggests we convert to the number of elapsed microseconds to guard against loss of precision as shown below. Any additional comments on this?

//
// We now have the elapsed number of ticks, along with the
// number of ticks-per-second. We use these values
// to convert to the number of elapsed microseconds.
// To guard against loss-of-precision, we convert
// to microseconds *before* dividing by ticks-per-second.
//

ElapsedMicroseconds.QuadPart *=
ElapsedMicroseconds.QuadPart /= Frequency.QuadPart;

ryklin