/* sys/timer.cc This file is part of the Osirion project and is distributed under the terms and conditions of the GNU General Public License version 2 */ #include "sys/timer.h" #include #include #include namespace sys { Timer::Timer() { reset(); } Timer::~Timer() { } void Timer::reset() { struct timeval tick; struct timezone tick_tz; gettimeofday(&tick, &tick_tz); timer_start = tick.tv_sec * 1000 + tick.tv_usec / 1000; } unsigned long Timer::timestamp() const { struct timeval tick; struct timezone tick_tz; gettimeofday(&tick, &tick_tz); unsigned long delta = (tick.tv_sec * 1000 + tick.tv_usec / 1000) - timer_start; return delta; } }