From df49b93877b40551111be6ef5ecfe4629787ab75 Mon Sep 17 00:00:00 2001 From: kwolekr Date: Fri, 29 Mar 2013 16:51:57 -0400 Subject: Add varying levels of precision to TimeTaker --- src/util/timetaker.cpp | 11 ++++++----- src/util/timetaker.h | 7 +++++-- 2 files changed, 11 insertions(+), 7 deletions(-) (limited to 'src/util') diff --git a/src/util/timetaker.cpp b/src/util/timetaker.cpp index 910fea822..720a9e1a9 100644 --- a/src/util/timetaker.cpp +++ b/src/util/timetaker.cpp @@ -23,19 +23,20 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "../log.h" #include -TimeTaker::TimeTaker(const char *name, u32 *result) +TimeTaker::TimeTaker(const char *name, u32 *result, TimePrecision prec) { m_name = name; m_result = result; m_running = true; - m_time1 = getTimeMs(); + m_precision = prec; + m_time1 = getTime(prec); } u32 TimeTaker::stop(bool quiet) { if(m_running) { - u32 time2 = getTimeMs(); + u32 time2 = getTime(m_precision); u32 dtime = time2 - m_time1; if(m_result != NULL) { @@ -52,9 +53,9 @@ u32 TimeTaker::stop(bool quiet) return 0; } -u32 TimeTaker::getTime() +u32 TimeTaker::getTimerTime() { - u32 time2 = getTimeMs(); + u32 time2 = getTime(m_precision); u32 dtime = time2 - m_time1; return dtime; } diff --git a/src/util/timetaker.h b/src/util/timetaker.h index 0b9d9ca04..5512c205f 100644 --- a/src/util/timetaker.h +++ b/src/util/timetaker.h @@ -21,6 +21,7 @@ with this program; if not, write to the Free Software Foundation, Inc., #define UTIL_TIMETAKER_HEADER #include "../irrlichttypes.h" +#include "../gettime.h" /* TimeTaker @@ -29,7 +30,8 @@ with this program; if not, write to the Free Software Foundation, Inc., class TimeTaker { public: - TimeTaker(const char *name, u32 *result=NULL); + TimeTaker(const char *name, u32 *result=NULL, + TimePrecision=PRECISION_MILLI); ~TimeTaker() { @@ -38,12 +40,13 @@ public: u32 stop(bool quiet=false); - u32 getTime(); + u32 getTimerTime(); private: const char *m_name; u32 m_time1; bool m_running; + TimePrecision m_precision; u32 *m_result; }; -- cgit v1.2.3