Original Post
๐ Locked
testing code performance
Advertisement
quote:
I've tried using timeGetTime and QueryPerformanceCounter but they don't seem to work very well.
why can u say that? Do something like this:
DWORD dwElapsedTime=timeGetTime();//Initialize ur variable
MyFunction(); //call ur function
dwElapsedTime-=timeGetTime();//get the interval of time elapsed
Hope it Helps
[edited by - remi on October 5, 2002 4:58:00 AM]
Or try something like this...
botman
[edited by - botman on October 5, 2002 3:25:29 PM]
#include <windows.h>
#include <stdio.h>
void main(void)
{
long x, y;
LARGE_INTEGER PerfFrequency;
LARGE_INTEGER PerfCountStart, PerfCountEnd;
LARGE_INTEGER PerfDiff;
float diff_time;
QueryPerformanceFrequency(&PerfFrequency);
if (PerfFrequency.QuadPart == 0)
{
printf("Your system doesn't support high-resolution timers!\n");
return;
}
printf("ticks per second = %12I64u\n", PerfFrequency);
PerfFrequency.QuadPart /= 1000; // convert to ticks per millisecond
QueryPerformanceCounter(&PerfCountStart);
y = 0;
for (x=0; x < 100000000L; x++)
y = y + x; // don't optimize the loop away
QueryPerformanceCounter(&PerfCountEnd);
PerfDiff.QuadPart = PerfCountEnd.QuadPart - PerfCountStart.QuadPart;
diff_time = (float)PerfDiff.QuadPart / (float)PerfFrequency.QuadPart;
printf("PerfDiff = %12I64u diff_time = %12.5f milliseconds\n", PerfDiff, diff_time);
}
botman
[edited by - botman on October 5, 2002 3:25:29 PM]
Topic Locked
This topic has been locked by a moderator. New replies are not allowed.
Sign in to reply to this topic.
Advertisement