aboutsummaryrefslogtreecommitdiff
path: root/src/common/perf_timer.h
diff options
context:
space:
mode:
authorRiccardo Spagni <ric@spagni.net>2018-01-27 17:24:49 -0800
committerRiccardo Spagni <ric@spagni.net>2018-01-27 17:24:49 -0800
commit4c302c63856c88815b0e00ab37b5a9c88320ee83 (patch)
treee98f075f28e2a2ef00ae89ebd47a596ab6422d70 /src/common/perf_timer.h
parentMerge pull request #3119 (diff)
parentperf_timer: add faster x86_64 timers, and pause/resume (diff)
downloadmonero-4c302c63856c88815b0e00ab37b5a9c88320ee83.tar.xz
Merge pull request #3120
6cf56682 perf_timer: add faster x86_64 timers, and pause/resume (moneromooo-monero) 411da337 perf_timer: use std::unique_ptr instead of new/delete (moneromooo-monero)
Diffstat (limited to 'src/common/perf_timer.h')
-rw-r--r--src/common/perf_timer.h10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/common/perf_timer.h b/src/common/perf_timer.h
index 3047f90b6..0e910caf9 100644
--- a/src/common/perf_timer.h
+++ b/src/common/perf_timer.h
@@ -30,6 +30,7 @@
#include <string>
#include <stdio.h>
+#include <memory>
#include "misc_log_ex.h"
#undef MONERO_DEFAULT_LOG_CATEGORY
@@ -47,6 +48,8 @@ class PerformanceTimer
public:
PerformanceTimer(const std::string &s, uint64_t unit, el::Level l = el::Level::Debug);
~PerformanceTimer();
+ void pause();
+ void resume();
private:
std::string name;
@@ -54,6 +57,7 @@ private:
el::Level level;
uint64_t ticks;
bool started;
+ bool paused;
};
void set_performance_timer_log_level(el::Level level);
@@ -62,8 +66,10 @@ void set_performance_timer_log_level(el::Level level);
#define PERF_TIMER_UNIT_L(name, unit, l) tools::PerformanceTimer pt_##name(#name, unit, l)
#define PERF_TIMER(name) PERF_TIMER_UNIT(name, 1000)
#define PERF_TIMER_L(name, l) PERF_TIMER_UNIT_L(name, 1000, l)
-#define PERF_TIMER_START_UNIT(name, unit) tools::PerformanceTimer *pt_##name = new tools::PerformanceTimer(#name, unit, el::Level::Info)
+#define PERF_TIMER_START_UNIT(name, unit) std::unique_ptr<tools::PerformanceTimer> pt_##name(new tools::PerformanceTimer(#name, unit, el::Level::Info))
#define PERF_TIMER_START(name) PERF_TIMER_START_UNIT(name, 1000)
-#define PERF_TIMER_STOP(name) do { delete pt_##name; pt_##name = NULL; } while(0)
+#define PERF_TIMER_STOP(name) do { pt_##name.reset(NULL); } while(0)
+#define PERF_TIMER_PAUSE(name) pt_##name->pause()
+#define PERF_TIMER_RESUME(name) pt_##name->resume()
}