Ogan

Hello. Sry if i choose wrong subforum.

Im really need to know which resolution QueryPerformanceCounter(and QueryPerformanceFrequnce) Functions have Im read few different numbers - 1 nanosec, 2 mcsec, and 1 millisec. May be someone on this forum can help me...

P.S.

Sry my bad English...



Re: Visual C++ General QueryPerformanceCounter Resolution

Aleksandr Tokarev

Frequency of QueryPerfomanceCounter variable.

It dependce upon hardware of the target machine.

QueryPerformanceFrequnce gives real frequency on the target machine!

__int64 ctr1 = 0, ctr2 = 0, freq = 0;
int acc = 0, i = 0;

// Start timing the code.
if (QueryPerformanceCounter((LARGE_INTEGER *)&ctr1)!= 0)
{
// Code segment is being timed.
for (i=0; i<100; i++) acc++;

// Finish timing the code.
QueryPerformanceCounter((LARGE_INTEGER *)&ctr2);


QueryPerformanceFrequency((LARGE_INTEGER *)&freq);


Console::WriteLine("100 Increment time: {0} seconds.",((ctr2 - ctr1) * 1.0 / freq).ToString());
}





Re: Visual C++ General QueryPerformanceCounter Resolution

Ogan

Thanks for answer.

If we use this functions together, we recieve something, that looks like timer Smile

And this timer is very High - resolution. In MSDN How To: Time Managed Code Using QueryPerformanceCounter and QueryPerformanceFrequency we can see result in nanoseconds. But in other source i can read that resolution of this "timer" is near 5 microseconds or may be 1 millsecond. And my question about this "timer" resolution...





Re: Visual C++ General QueryPerformanceCounter Resolution

Simple Samples

I had assumed that QueryPerformanceFrequency is the resolution for the system they are used in.

You are likely to get the best answer to this question in the microsoft.public.win32.programmer newsgroup.






Re: Visual C++ General QueryPerformanceCounter Resolution

Aleksandr Tokarev

The answer is QuereyPerformanceCounter Reslution depends upon paticular computer hardware. It is not a constant value.

MSDN for QueryPerformanceCounter:

....

However, you can get different results on different processors due to bugs in the basic input/output system (BIOS) or the hardware abstraction layer (HAL).

...




Re: Visual C++ General QueryPerformanceCounter Resolution

Simple Samples

Aleksandr Tokarev wrote:
The answer is QuereyPerformanceCounter Reslution depends upon paticular computer hardware. It is not a constant value.

Then how can the resolution be determined

Aleksandr Tokarev wrote:
MSDN for QueryPerformanceCounter:

....

However, you can get different results on different processors due to bugs in the basic input/output system (BIOS) or the hardware abstraction layer (HAL).

...

It is not clear that that says anything about resolution. It says that results vary.






Re: Visual C++ General QueryPerformanceCounter Resolution

Aleksandr Tokarev

Simple Samples wrote:

Aleksandr Tokarev wrote:
The answer is QuereyPerformanceCounter Reslution depends upon paticular computer hardware. It is not a constant value.

Then how can the resolution be determined

By calling QueryPerformanceFrequency!

Simple Samples wrote:

Aleksandr Tokarev wrote:
MSDN for QueryPerformanceCounter:

....

However, you can get different results on different processors due to bugs in the basic input/output system (BIOS) or the hardware abstraction layer (HAL).

...

It is not clear that that says anything about resolution. It says that results vary.

Posts aboves show this. And you can check it manually!!! And Richter says!

For me it's enouph!





Re: Visual C++ General QueryPerformanceCounter Resolution

Ogan

Ok. If i understand right, max resolution depends hardware. And we can get this value by QueryPerformanceFrequency function. For example on my computer QueryPerformanceFrequency = Freq = 3579545. Freq = Nubmer of QuereyPerformanceCounter ticks in second. And resolution is 1/freq seconds or 1000 000 000/freq nanoseconds. Is it true





Re: Visual C++ General QueryPerformanceCounter Resolution

Aleksandr Tokarev

Yes, it is.

BTW: For those who doubt, in my computer Freq = 25000000.