perf_timer: add a way to get and reset the current time

This commit is contained in:
moneromooo-monero 2018-03-11 11:17:29 +00:00
parent c1581a5bb8
commit 6a507dab6f
No known key found for this signature in database
GPG key ID: 686F07454D6CEFC3
2 changed files with 18 additions and 2 deletions

View file

@ -165,4 +165,20 @@ void PerformanceTimer::resume()
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);
}
}