44 const char* exceptionCode,
46 const char* comments);
49# if defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE_EXTENDED==1)
55# include <sys/types.h>
60 if( a == _SC_CLK_TCK )
return 1000;
64 static clock_t filetime2msec( FILETIME* t ){
66 return (clock_t)((((float)t->dwHighDateTime)*429496.7296)+
67 (((
float)t->dwLowDateTime)*.0001) );
71 clock_t
times(
struct tms * t){
72 FILETIME ct = {0,0}, et = {0,0}, st = {0,0}, ut = {0,0}, rt = {0,0};
75 GetSystemTime( &realtime );
76 SystemTimeToFileTime( &realtime, &rt );
78 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);
97 os <<
"User=****s Real=****s Sys=****s";
111 G4Exception(
"G4Timer::GetRealElapsed()",
"InvalidCondition",
114 G4double diff=fEndRealTime-fStartRealTime;
115 return diff/sysconf(_SC_CLK_TCK);
123 G4Exception(
"G4Timer::GetSystemElapsed()",
"InvalidCondition",
126 G4double diff=fEndTimes.tms_stime-fStartTimes.tms_stime;
127 return diff/sysconf(_SC_CLK_TCK);
134 G4Exception(
"G4Timer::GetUserElapsed()",
"InvalidCondition",
137 G4double diff=fEndTimes.tms_utime-fStartTimes.tms_utime;
138 return diff/sysconf(_SC_CLK_TCK);
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
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)