using times()

Valery Fine fine@mail.cern.ch
Mon Sep 22 00:55:00 GMT 1997


On 22 Sep 97 at 8:33, Sergey Okhapkin wrote:
> times() call works on NT only. The underlying syscall
> GetProcessTimes() unimplemented on windows 95. The output of your
> examle looks the following on my box (NT4.0 SP3):

 Probably like this would be better then just ZERO:
//_______________
Duble_t TStopwatch::GetCPUTime(){
 OSVERSIONINFO OsVersionInfo;
 OsVersionInfo.dwOSVersionInfoSize=sizeof(OSVERSIONINFO);
 GetVersionEx(&OsVersionInfo);
 if (OsVersionInfo.dwPlatformId == VER_PLATFORM_WIN32_NT) {
 DWORD ret;
 FILETIME ftCreate, // when the process was created
 ftExit; // when the process exited
 union {FILETIME ftFileTime;
 __int64 ftInt64;
 } ftKernel; // time the process has spent in kernel mode
 union {FILETIME ftFileTime;
 __int64 ftInt64;
 } ftUser; // time the process has spent in user mode
 HANDLE hProcess = GetCurrentProcess();
 ret = GetProcessTimes (hProcess, &ftCreate, &ftExit,
 &ftKernel.ftFileTime,
 &ftUser.ftFileTime);
 if (ret != TRUE){
 ret = GetLastError ();
 ::Error ("GetCPUTime", " Error on GetProcessTimes 0x%lx",
 (int)ret);
 }
 return (Double_t) (ftKernel.ftInt64 + ftUser.ftInt64) * gTicks;
 }
 else
 return GetRealTime();
//_______________
Double_t TStopwatch::GetRealTime(){
 union {FILETIME ftFileTime;
 __int64 ftInt64;
 } ftRealTime; // time the process has spent in kernel mode
 SYSTEMTIME st;
 GetSystemTime(&st);
 SystemTimeToFileTime(&st,&ftRealTime.ftFileTime);
 return (Double_t)ftRealTime.ftInt64 * gTicks;
}
Dr. Valeri Faine (Valery Fine)
 ------------ ------------- Phone: +41 22 767 4921
CERN FAX : +41 22 767 7155
CH-1211 Geneva, 23 mailto:fine@mail.cern.ch 
Switzerland http://nicewww.cern.ch/~fine
 
-
For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request@cygnus.com" with one line of text: "help".


More information about the Cygwin mailing list

AltStyle によって変換されたページ (->オリジナル) /