25 #elif defined(__APPLE__)
26 # include <mach/mach_time.h>
28 # include <sys/time.h>
70 const char*
name = NULL)
72 , m_printdtr(printdtr == PrintDtr)
77 if (startnow == StartNow)
85 , m_printdtr(DontPrintDtr)
97 if (m_printdtr == PrintDtr)
118 m_elapsed_ticks += tickdiff(m_starttime, n);
121 return seconds(m_elapsed_ticks);
139 m_elapsed_ticks +=
r;
148 double lap() {
return seconds(lap_ticks()); }
152 ticks_t ticks()
const {
return ticks_since_start() + m_elapsed_ticks; }
163 return m_ticking ? tickdiff(m_starttime, now()) :
ticks_t(0);
194 ticks_t m_elapsed_ticks;
199 ticks_t now(
void)
const
203 QueryPerformanceCounter(&n);
205 #elif defined(__APPLE__)
206 return mach_absolute_time();
209 gettimeofday(&
t, NULL);
210 return (
long long)
t.tv_sec * 1000000ll +
t.tv_usec;
216 ticks_t tickdiff(ticks_t
then, ticks_t now)
const
218 return (now > then) ? now - then : then - now;
222 double diff(ticks_t then, ticks_t now)
const
224 return seconds(tickdiff(then, now));
227 static double seconds_per_tick;
228 static ticks_t ticks_per_second;
229 friend class TimerSetupOnce;
void printf(const char *fmt, const Args &...args)
Timer(StartNowVal startnow=StartNow, PrintDtrVal printdtr=DontPrintDtr, const char *name=NULL)
void start()
Start (or restart) ticking, if we are not currently.
String-related utilities, all in namespace Strutil.
**If you just want to fire and then
bool ticking() const
Is the timer currently ticking?
void add_ticks(ticks_t delta)
double time_since_start(void) const
GLuint const GLchar * name
double operator()(void) const
#define OIIO_NAMESPACE_END
void add_seconds(double t)
ticks_t ticks_since_start(void) const
static double seconds(ticks_t ticks)
Convert number of ticks to seconds.
#define OIIO_NAMESPACE_BEGIN