How to time a function call

Posts 1–2 of 2 · Page 1 of 1
How to time a function call
Do not use GetTickCount! You can't time with that. The ticks are not on every system the same.
You can use QueryPerformanceCounter for this.

Code:
LARGE_INTEGER StartTime;
::QueryPerformanceCounter(&StartTime);

//Run the function

LARGE_INTEGER StopTime;
::QueryPerformanceCounter(&StopTime);

LARGE_INTEGER PerformanceFrequency;
::QueryPerformanceFrequency(&PerformanceFrequency);

double Frequency = PerformanceFrequency.QuadPart;
double TimePassed = ((StopTime.QuadPart - StartTime.QuadPart) / Frequency);
Posts 1–2 of 2 · Page 1 of 1

Post a Reply

Similar Threads

Tags for this Thread

None

Talk with us