1

From these, it appears the function returns the value in Hz

QueryPerformaceFrequency()
Units of QueryPerformanceFrequency

Running the intel Core i5 - runs at 2.8 G Hz

The function appears to return M Hz ?

The value in the debugger is 1,328,261

  • Why is the value only 7 digits?
  • Why doesn't that value reflect 2 Ghz? (i.e. 2,8.....)

What am I missing here?

Using the function incorrectly (below)?

LARGE_INTEGER li;
QueryPerformanceFrequency(&li);
printf("Ticks: %f\n", double(li.QuadPart) );
Community
  • 1
  • 1
P.S.
  • 384
  • 3
  • 18

1 Answers1

2

QueryPerformanceFrequency returns the frequency of the performance counter, not the clock frequency of the CPU. Those are not the same thing, although it seems to be a common mis-conception that they are.

The documentation says, with my emphasis:

A pointer to a variable that receives the current performance-counter frequency, in counts per second.

So, what you have is the the performance-counter frequency measured in Hz.

For what it is worth, I would not print if that way. It's an integer value. Best to keep it that way for printing. So you can, assuming you use the MS compiler, print it like this:

printf("Ticks: %I64d\n", li.QuadPart);
David Heffernan
  • 601,492
  • 42
  • 1,072
  • 1,490