From: fine AT mail DOT cern DOT ch (Valery Fine) Subject: RE: using times() 22 Sep 1997 01:18:40 -0700 Message-ID: <199709220754.JAA83444.cygnus.gnu-win32@sp064.cern.ch> References: <01BCC732 DOT 3C3AA5E0 AT sos> Reply-To: fine AT mail DOT cern DOT ch To: Sergey Okhapkin , gnu-win32 AT cygnus DOT com 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 AT mail DOT cern DOT ch Switzerland http://nicewww.cern.ch/~fine - For help on using this list (especially unsubscribing), send a message to "gnu-win32-request AT cygnus DOT com" with one line of text: "help".