From ed58263c164b922d453ca78243c926fca4bb3d66 Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Sat, 12 Sep 2015 14:02:13 -0400 Subject: [PATCH] Timer: Added static ::now method for timestamps --- src/Timer.cpp | 8 ++++++++ src/Timer.h | 2 ++ 2 files changed, 10 insertions(+) diff --git a/src/Timer.cpp b/src/Timer.cpp index 1d26fe2f3..002270a7a 100644 --- a/src/Timer.cpp +++ b/src/Timer.cpp @@ -112,3 +112,11 @@ void Timer::subtract (unsigned long value) } //////////////////////////////////////////////////////////////////////////////// +unsigned long Timer::now () +{ + struct timeval now; + gettimeofday (&now, NULL); + return now.tv_sec * 1000000 + now.tv_usec; +} + +//////////////////////////////////////////////////////////////////////////////// diff --git a/src/Timer.h b/src/Timer.h index c0137d1b2..f873e366d 100644 --- a/src/Timer.h +++ b/src/Timer.h @@ -45,6 +45,8 @@ public: unsigned long total () const; void subtract (unsigned long); + static unsigned long now (); + private: std::string _description; bool _running;