/* * timer.cpp * * Created on: Jul 18, 2009 * Author: gregor */ #include "GLTB/timer.h" #ifndef WIN32 // Linux implementation #include namespace gltb { void Timer::start() { struct timeval tv; gettimeofday(&tv,0); startTime=tv.tv_sec*1000+tv.tv_usec/1000; } long long Timer::stop() { struct timeval tv; gettimeofday(&tv,0); long long endTime=tv.tv_sec*1000+tv.tv_usec/1000; return endTime-startTime; } } #else // Win32 implementation #include "windows.h" namespace gltb { void Timer::start() { LARGE_INTEGER temp; QueryPerformanceCounter(&temp); startTime=temp.QuadPart; } long long Timer::stop() { LARGE_INTEGER temp; QueryPerformanceCounter(&temp); long long endTime=temp.QuadPart; QueryPerformanceFrequency(&temp); return (long long)(1000*((endTime-startTime)/((double)temp.QuadPart))); } } #endif