24# include <sys/times.h>
95 Error(
"Continue",
"stopwatch not started");
112 Error(
"RealTime",
"stopwatch not started");
127 Error(
"CpuTime",
"stopwatch not started");
149 SystemTimeToFileTime(&st,&ftRealTime.ftFileTime);
165 OSVERSIONINFO OsVersionInfo;
173 OsVersionInfo.dwOSVersionInfoSize=
sizeof(OSVERSIONINFO);
174 GetVersionEx(&OsVersionInfo);
175 if (OsVersionInfo.dwPlatformId == VER_PLATFORM_WIN32_NT) {
190 HANDLE hThread = GetCurrentThread();
191 ret = GetThreadTimes (hThread, &ftCreate, &ftExit,
192 &ftKernel.ftFileTime,
195 ret = GetLastError ();
196 ::Error (
"GetCPUTime",
" Error on GetProcessTimes 0x%lx", (
int)
ret);
224 realt -= hours * 3600;
229 if (realt < 0) realt = 0;
230 if (cput < 0) cput = 0;
232 if (opt && *opt ==
'm') {
234 Printf(
"Real time %d:%02d:%06.3f, CP time %.3f, %d slices", hours, min, realt, cput,
Counter());
236 Printf(
"Real time %d:%02d:%06.3f, CP time %.3f", hours, min, realt, cput);
238 }
else if (opt && *opt ==
'u') {
240 Printf(
"Real time %d:%02d:%09.6f, CP time %.3f, %d slices", hours, min, realt, cput,
Counter());
242 Printf(
"Real time %d:%02d:%09.6f, CP time %.3f", hours, min, realt, cput);
246 Printf(
"Real time %d:%02d:%02d, CP time %.3f, %d slices", hours, min, sec, cput,
Counter());
248 Printf(
"Real time %d:%02d:%02d, CP time %.3f", hours, min, sec, cput);
int Int_t
Signed integer 4 bytes (int).
bool Bool_t
Boolean (0=false, 1=true) (bool).
double Double_t
Double 8 bytes.
const char Option_t
Option string (const char).
void Printf(const char *fmt,...)
Formats a string in a circular formatting buffer and prints the string.
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
Double_t RealTime()
Stop the stopwatch (if it is running) and return the realtime (in seconds) passed between the start a...
void Start(Bool_t reset=kTRUE)
Start the stopwatch.
static Double_t GetRealTime()
Private static method returning system realtime.
Double_t CpuTime()
Stop the stopwatch (if it is running) and return the cputime (in seconds) passed between the start an...
void Continue()
Resume a stopped stopwatch.
void Stop()
Stop the stopwatch.
TStopwatch()
Create a stopwatch and start it.
static Double_t GetCPUTime()
Private static method returning system CPU time.
void Print(Option_t *option="") const override
Print the real and cpu time passed between the start and stop events.
The TTimeStamp encapsulates seconds and ns since EPOCH.