0ad/source/tools/atlas/AtlasUI/CustomControls/HighResTimer/HighResTimer.cpp
olsner db045c330b # Made Atlas compile on linux
graphics: basic terrain passibility
atlas: lots of changes to make atlas compile under linux
unix/X: more clipboard support - copy from 0AD to other programs
unix/debug: use sys_get_executable_name instead of hard-coded paths
... and lots of other misc. changes

This was SVN commit r4640.
2006-11-12 04:02:36 +00:00

43 lines
730 B
C++

#include "stdafx.h"
#include "HighResTimer.h"
#ifndef _WIN32
#include <sys/time.h>
#endif
// TODO: Portability and general betterness. (But it's good enough for now.)
HighResTimer::HighResTimer()
{
#ifdef _WIN32
LARGE_INTEGER freq;
BOOL ok = QueryPerformanceFrequency(&freq);
if (! ok)
{
wxLogError(_("QPF failed!"));
}
else
{
m_TickLength = freq.QuadPart;
}
#endif
}
double HighResTimer::GetTime()
{
#ifdef _WIN32
LARGE_INTEGER count;
BOOL ok = QueryPerformanceCounter(&count);
if (! ok)
{
wxLogError(_("QPC failed!"));
return 0.0;
}
return (double)count.QuadPart / (double)m_TickLength.GetValue();
#else
struct timeval tv;
gettimeofday(&tv, NULL);
return tv.tv_sec+(tv.tv_usec/1000000.0);
#endif
}