mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-26 22:32:46 +00:00
Bug 487605 - nsStopwatch.cpp: Fix GetProcessTimes() usage; (Bv1-MC) stopwatch.cpp; r+sr=roc
This commit is contained in:
parent
21e625c1d2
commit
8b50c1c962
@ -191,22 +191,20 @@ double Stopwatch::GetRealTime(){
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
double Stopwatch::GetCPUTime() {
|
||||||
double Stopwatch::GetCPUTime(){
|
|
||||||
#if defined(R__MAC)
|
#if defined(R__MAC)
|
||||||
// return(double)clock() / gTicks;
|
// return(double)clock() / gTicks;
|
||||||
return(double)clock();
|
return(double)clock();
|
||||||
#elif defined(R__UNIX)
|
#elif defined(R__UNIX)
|
||||||
struct tms cpt;
|
struct tms cpt;
|
||||||
times(&cpt);
|
times(&cpt);
|
||||||
return (double)(cpt.tms_utime+cpt.tms_stime) / gTicks;
|
return (double)(cpt.tms_utime+cpt.tms_stime) / gTicks;
|
||||||
#elif defined(R__VMS)
|
#elif defined(R__VMS)
|
||||||
return(double)clock()/gTicks;
|
return(double)clock()/gTicks;
|
||||||
#elif defined(WINCE)
|
#elif defined(WINCE)
|
||||||
return 0;
|
return 0;
|
||||||
#elif defined(WIN32)
|
#elif defined(WIN32)
|
||||||
|
|
||||||
DWORD ret;
|
|
||||||
FILETIME ftCreate, // when the process was created
|
FILETIME ftCreate, // when the process was created
|
||||||
ftExit; // when the process exited
|
ftExit; // when the process exited
|
||||||
|
|
||||||
@ -219,15 +217,16 @@ double Stopwatch::GetCPUTime(){
|
|||||||
} ftUser; // time the process has spent in user mode
|
} ftUser; // time the process has spent in user mode
|
||||||
|
|
||||||
HANDLE hProcess = GetCurrentProcess();
|
HANDLE hProcess = GetCurrentProcess();
|
||||||
ret = GetProcessTimes (hProcess, &ftCreate, &ftExit,
|
|
||||||
&ftKernel.ftFileTime,
|
|
||||||
&ftUser.ftFileTime);
|
|
||||||
if (ret != PR_TRUE){
|
|
||||||
ret = GetLastError ();
|
|
||||||
#ifdef DEBUG
|
#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
|
#endif
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Process times are returned in a 64-bit structure, as the number of
|
* 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
|
* 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 # elif, WIN32
|
||||||
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user