Difference of time in MilliSeconds - pls help urgent !!
Hi friends,
I am trying out a small function in which i want a time difference in milliseconds.
but am not able to do it.
i am using time_t tm;
than doing GetLocalTime(&tm); and using another instance but time_t does not show time in milliseconds.
I also tried with CTime and SYSTEMTIME but they give independant values and does not provide substraction facility.
pls help ... how to do this ?
Thanks.
Re: Difference of time in MilliSeconds - pls help urgent !!
Aloha,
you could use
clock()
Look in the MSDN, how to use it.
Its really nice.
Greetings
BOA
Re: Difference of time in MilliSeconds - pls help urgent !!
hi,
try the GetTickCount function.
The difference between start of some code part and end would be the execution time in milliseconds.
regards,
typecast
Re: Difference of time in MilliSeconds - pls help urgent !!
You should use QueryPerformanceCounter() or QueryPerformanceFrequency() in stead.
If you try to benchmark a function, you dhould do something like this:
Code:
DWORD start, end;
DWORD dwCounter = 10000; // or some other value
QueryPerformanceCounter(&start);
while(dwCounter--)
foo(); // call your function
QueryPerformanceCounter(&end);
double average = (end-start)/10000;