From 6a507dab6f935b0d8c417299ba4f5be4882582bb Mon Sep 17 00:00:00 2001 From: moneromooo-monero Date: Sun, 11 Mar 2018 11:17:29 +0000 Subject: perf_timer: add a way to get and reset the current time --- src/common/perf_timer.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'src/common/perf_timer.cpp') diff --git a/src/common/perf_timer.cpp b/src/common/perf_timer.cpp index d287949ba..fc51dc7f7 100644 --- a/src/common/perf_timer.cpp +++ b/src/common/perf_timer.cpp @@ -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); +} + } -- cgit v1.2.3