39void G4Exception(
const char* originOfException,
const char* exceptionCode,
43# if defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE_EXTENDED == 1)
49# include <sys/types.h>
61static clock_t filetime2msec(FILETIME* t)
63 return (clock_t)((((
G4float) t->dwHighDateTime) * 429496.7296) +
64 (((
G4float) t->dwLowDateTime) * .0001));
67clock_t times(
struct tms* t)
69 FILETIME ct = { 0, 0 }, et = { 0, 0 }, st = { 0, 0 }, ut = { 0, 0 },
73 GetSystemTime(&realtime);
74 SystemTimeToFileTime(&realtime, &rt);
77 GetProcessTimes(GetCurrentProcess(), &ct, &et, &st, &ut);
79 t->tms_utime = t->tms_cutime = filetime2msec(&ut);
80 t->tms_stime = t->tms_cstime = filetime2msec(&st);
82 return filetime2msec(&rt);
103 ss << std::setprecision(1);
104 ss <<
" [Cpu=" << std::setprecision(1) << cpu_util <<
"%]";
110 ss <<
"User=****s Real=****s Sys=****s";
126 "Timer not stopped or times not recorded!");
128 std::chrono::duration<G4double> diff = fEndRealTime - fStartRealTime;
136 G4Exception(
"G4Timer::GetSystemElapsed()",
"InvalidCondition",
139 G4double diff = fEndTimes.tms_stime - fStartTimes.tms_stime;
140 return diff / sysconf(_SC_CLK_TCK);
148 "Timer not stopped or times not recorded");
150 G4double diff = fEndTimes.tms_utime - fStartTimes.tms_utime;
151 return diff / sysconf(_SC_CLK_TCK);
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
std::ostream & operator<<(std::ostream &os, const G4Timer &t)
G4double GetSystemElapsed() const
G4double GetUserElapsed() const
G4double GetRealElapsed() const