diff options
author | moneromooo-monero <moneromooo-monero@users.noreply.github.com> | 2018-03-11 11:17:29 +0000 |
---|---|---|
committer | moneromooo-monero <moneromooo-monero@users.noreply.github.com> | 2018-12-07 14:23:47 +0000 |
commit | 6a507dab6f935b0d8c417299ba4f5be4882582bb (patch) | |
tree | a628451e1159b9c1766f0abb6ea9dc0464617a16 /src/common/perf_timer.cpp | |
parent | perf_timer: only log to file (diff) | |
download | monero-6a507dab6f935b0d8c417299ba4f5be4882582bb.tar.xz |
perf_timer: add a way to get and reset the current time
Diffstat (limited to 'src/common/perf_timer.cpp')
-rw-r--r-- | src/common/perf_timer.cpp | 16 |
1 files changed, 16 insertions, 0 deletions
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); +} + } |