perf_timer: add a way to get and reset the current time
This commit is contained in:
parent
c1581a5bb8
commit
6a507dab6f
@ -165,4 +165,20 @@ void PerformanceTimer::resume()
|
|||||||
paused = false;
|
paused = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PerformanceTimer::reset()
|
||||||
|
{
|
||||||
|
if (paused)
|
||||||
|
ticks = 0;
|
||||||
|
else
|
||||||
|
ticks = get_tick_count();
|
||||||
|
}
|
||||||
|
|
||||||
|
uint64_t PerformanceTimer::value() const
|
||||||
|
{
|
||||||
|
uint64_t v = ticks;
|
||||||
|
if (!paused)
|
||||||
|
v = get_tick_count() - v;
|
||||||
|
return ticks_to_ns(v);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -51,8 +51,8 @@ public:
|
|||||||
~PerformanceTimer();
|
~PerformanceTimer();
|
||||||
void pause();
|
void pause();
|
||||||
void resume();
|
void resume();
|
||||||
|
void reset();
|
||||||
uint64_t value() const { return ticks; }
|
uint64_t value() const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
uint64_t ticks;
|
uint64_t ticks;
|
||||||
|
Loading…
Reference in New Issue
Block a user