#include "TGLStopwatch.h"
#include "TGLIncludes.h"
#ifdef R__WIN32
#include <Windows.h> // For GetSystemTimeAsFileTime()
#else
#include <sys/time.h> // For gettimeofday()
#endif
ClassImp(TGLStopwatch);
TGLStopwatch::TGLStopwatch() : fStart(0), fEnd(0), fLastRun(0)
{
}
TGLStopwatch::~TGLStopwatch()
{
}
void TGLStopwatch::Start()
{
fStart = GetClock();
fEnd = 0;
}
Double_t TGLStopwatch::Lap() const
{
if (fStart == 0)
return 0;
else
return GetClock() - fStart;
}
Double_t TGLStopwatch::End()
{
if (fStart == 0)
return 0;
if (fEnd == 0) {
fEnd = GetClock();
fLastRun = fEnd - fStart;
}
return fLastRun;
}
Double_t TGLStopwatch::GetClock(void) const
{
#ifdef R__WIN32
static LARGE_INTEGER perfFreq;
static Bool_t usePerformanceCounter = QueryPerformanceFrequency(&perfFreq);
if (usePerformanceCounter) {
LARGE_INTEGER counter;
QueryPerformanceCounter(&counter);
Double_t time = static_cast<Double_t>(counter.QuadPart)*1000.0 /
static_cast<Double_t>(perfFreq.QuadPart);
return time;
}
FILETIME ft;
ULARGE_INTEGER uli;
__int64 t;
GetSystemTimeAsFileTime(&ft);
uli.LowPart = ft.dwLowDateTime;
uli.HighPart = ft.dwHighDateTime;
t = uli.QuadPart;
return static_cast<Double_t>(t /= 1E4);
#else
struct timeval tv;
gettimeofday(&tv, 0);
return static_cast<Double_t>(tv.tv_sec*1E3) + static_cast<Double_t>(tv.tv_usec) / 1E3;
#endif
}
Last change: Wed Jun 25 08:41:24 2008
Last generated: 2008-06-25 08:41
This page has been automatically generated. If you have any comments or suggestions about the page layout send a mail to ROOT support, or contact the developers with any questions or problems regarding ROOT.