39# if defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE_EXTENDED == 1)
45# include <sys/types.h>
57static clock_t filetime2msec(FILETIME* t)
59 return (clock_t)((((
G4float) t->dwHighDateTime) * 429496.7296) +
60 (((
G4float) t->dwLowDateTime) * .0001));
63clock_t times(
struct tms* t)
65 FILETIME ct = { 0, 0 }, et = { 0, 0 }, st = { 0, 0 }, ut = { 0, 0 },
69 GetSystemTime(&realtime);
70 SystemTimeToFileTime(&realtime, &rt);
73 GetProcessTimes(GetCurrentProcess(), &ct, &et, &st, &ut);
75 t->tms_utime = t->tms_cutime = filetime2msec(&ut);
76 t->tms_stime = t->tms_cstime = filetime2msec(&st);
78 return filetime2msec(&rt);
99 ss << std::setprecision(1);
100 ss <<
" [Cpu=" << std::setprecision(1) << cpu_util <<
"%]";
106 ss <<
"User=****s Real=****s Sys=****s";
118 "Timer not stopped or times not recorded!");
120 std::chrono::duration<G4double> diff = fEndRealTime - fStartRealTime;
128 G4Exception(
"G4Timer::GetSystemElapsed()",
"InvalidCondition",
131 G4double diff = fEndTimes.tms_stime - fStartTimes.tms_stime;
132 return diff / sysconf(_SC_CLK_TCK);
140 "Timer not stopped or times not recorded");
142 G4double diff = fEndTimes.tms_utime - fStartTimes.tms_utime;
143 return diff / sysconf(_SC_CLK_TCK);
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
std::ostream & operator<<(std::ostream &os, const G4Timer &t)
G4double GetSystemElapsed() const
G4double GetUserElapsed() const
G4double GetRealElapsed() const