calculating time
-
dear all how to calculate time during processing using Time class, anyone has such code? thanks a lot.
gentleguy
Are you talking about
GetTickCount()
?"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
-
Are you talking about
GetTickCount()
?"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
i just would like to know how to calculate time from start to end processing, which function i can use it? when i used start clock() and end clock(), and CLOCK_PER_SEC, after compiling, output showed didn't declare CLOCK_PER_SEC. but the time is very small after calculate, how to calculate? any road is ok for me. thanks
gentleguy
-
dear all how to calculate time during processing using Time class, anyone has such code? thanks a lot.
gentleguy
Hi, Please refer below pseudocode,
long ltime = GetTickCount(); CallYourTimeTakingFunction(); TRACE("Time took = %li\n", GetTickCount() - ltime);
Or,
CTime startTime = CTime::GetCurrentTime(); CallYourTimeTakingFunction(); CTime endTime = CTime::GetCurrentTime(); CTimeSpan elapsedTime = endTime - startTime;
Hope this will server your purpose. Regards, Paresh.
-
Hi, Please refer below pseudocode,
long ltime = GetTickCount(); CallYourTimeTakingFunction(); TRACE("Time took = %li\n", GetTickCount() - ltime);
Or,
CTime startTime = CTime::GetCurrentTime(); CallYourTimeTakingFunction(); CTime endTime = CTime::GetCurrentTime(); CTimeSpan elapsedTime = endTime - startTime;
Hope this will server your purpose. Regards, Paresh.
#include <time.h> clock_t ckStart,ckEnd,duration =0.0; char buff[1000]; ckStart=clock(); .... ..... ckEnd=clock(); float fDuration=(float)(ckEnd-ckStart)/CLOCK_PER_SEC; sprintf(buff,"speed=%d ms",fAveduration); Message Box (buff,"Time"); what is wrong with these code? output showed no declare CLOCK_PER_SEC. what is problem. thanks
gentleguy
-
#include <time.h> clock_t ckStart,ckEnd,duration =0.0; char buff[1000]; ckStart=clock(); .... ..... ckEnd=clock(); float fDuration=(float)(ckEnd-ckStart)/CLOCK_PER_SEC; sprintf(buff,"speed=%d ms",fAveduration); Message Box (buff,"Time"); what is wrong with these code? output showed no declare CLOCK_PER_SEC. what is problem. thanks
gentleguy
gentleguy wrote:
float fDuration=(float)(ckEnd-ckStart)/CLOCK_PER_SEC;
Should be,
float fDuration=(float)(ckEnd-ckStart)/CLOCKS_PER_SEC;
Change
CLOCK_PER_SEC
toCLOCK**S**_PER_SEC
. Regards, Paresh.modified on Friday, May 16, 2008 6:55 AM