Bug 487605 - nsStopwatch.cpp: Fix GetProcessTimes() usage; (Bv1-MC) stopwatch.cpp; r+sr=roc

This commit is contained in:
Serge Gautherie 2009-04-20 12:23:52 +02:00
parent 21e625c1d2
commit 8b50c1c962

View File

@ -191,22 +191,20 @@ double Stopwatch::GetRealTime(){
#endif
}
double Stopwatch::GetCPUTime(){
double Stopwatch::GetCPUTime() {
#if defined(R__MAC)
// return(double)clock() / gTicks;
return(double)clock();
// return(double)clock() / gTicks;
return(double)clock();
#elif defined(R__UNIX)
struct tms cpt;
times(&cpt);
return (double)(cpt.tms_utime+cpt.tms_stime) / gTicks;
struct tms cpt;
times(&cpt);
return (double)(cpt.tms_utime+cpt.tms_stime) / gTicks;
#elif defined(R__VMS)
return(double)clock()/gTicks;
return(double)clock()/gTicks;
#elif defined(WINCE)
return 0;
return 0;
#elif defined(WIN32)
DWORD ret;
FILETIME ftCreate, // when the process was created
ftExit; // when the process exited
@ -219,15 +217,16 @@ double Stopwatch::GetCPUTime(){
} ftUser; // time the process has spent in user mode
HANDLE hProcess = GetCurrentProcess();
ret = GetProcessTimes (hProcess, &ftCreate, &ftExit,
&ftKernel.ftFileTime,
&ftUser.ftFileTime);
if (ret != PR_TRUE){
ret = GetLastError ();
#ifdef DEBUG
printf("%s 0x%lx\n"," Error on GetProcessTimes", (int)ret);
BOOL ret =
#endif
GetProcessTimes(hProcess, &ftCreate, &ftExit,
&ftKernel.ftFileTime, &ftUser.ftFileTime);
#ifdef DEBUG
if (!ret)
// ToDo: May want to use NS_ERROR().
printf("Error: GetProcessTimes() failed, 0x%lx\n", (int)GetLastError());
#endif
}
/*
* Process times are returned in a 64-bit structure, as the number of
@ -237,10 +236,9 @@ double Stopwatch::GetCPUTime(){
*
* Convert sum of high 32-bit quantities to 64-bit int
*/
return (double) (ftKernel.ftInt64 + ftUser.ftInt64) * gTicks;
return (double) (ftKernel.ftInt64 + ftUser.ftInt64) * gTicks;
#endif
#endif # elif, WIN32
}