aboutsummaryrefslogtreecommitdiff
path: root/src/common/perf_timer.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/common/perf_timer.h')
-rw-r--r--src/common/perf_timer.h30
1 files changed, 23 insertions, 7 deletions
diff --git a/src/common/perf_timer.h b/src/common/perf_timer.h
index 0e910caf9..675d6234d 100644
--- a/src/common/perf_timer.h
+++ b/src/common/perf_timer.h
@@ -43,30 +43,46 @@ class PerformanceTimer;
extern el::Level performance_timer_log_level;
+uint64_t get_tick_count();
+uint64_t get_ticks_per_ns();
+uint64_t ticks_to_ns(uint64_t ticks);
+
class PerformanceTimer
{
public:
- PerformanceTimer(const std::string &s, uint64_t unit, el::Level l = el::Level::Debug);
+ PerformanceTimer(bool paused = false);
~PerformanceTimer();
void pause();
void resume();
+ uint64_t value() const { return ticks; }
+void set(uint64_t v){ticks=v;}
+
+protected:
+ uint64_t ticks;
+ bool started;
+ bool paused;
+};
+
+class LoggingPerformanceTimer: public PerformanceTimer
+{
+public:
+ LoggingPerformanceTimer(const std::string &s, uint64_t unit, el::Level l = el::Level::Debug);
+ ~LoggingPerformanceTimer();
+
private:
std::string name;
uint64_t unit;
el::Level level;
- uint64_t ticks;
- bool started;
- bool paused;
};
void set_performance_timer_log_level(el::Level level);
-#define PERF_TIMER_UNIT(name, unit) tools::PerformanceTimer pt_##name(#name, unit, tools::performance_timer_log_level)
-#define PERF_TIMER_UNIT_L(name, unit, l) tools::PerformanceTimer pt_##name(#name, unit, l)
+#define PERF_TIMER_UNIT(name, unit) tools::LoggingPerformanceTimer pt_##name(#name, unit, tools::performance_timer_log_level)
+#define PERF_TIMER_UNIT_L(name, unit, l) tools::LoggingPerformanceTimer 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) std::unique_ptr<tools::PerformanceTimer> pt_##name(new tools::PerformanceTimer(#name, unit, el::Level::Info))
+#define PERF_TIMER_START_UNIT(name, unit) std::unique_ptr<tools::LoggingPerformanceTimer> pt_##name(new tools::LoggingPerformanceTimer(#name, unit, el::Level::Info))
#define PERF_TIMER_START(name) PERF_TIMER_START_UNIT(name, 1000)
#define PERF_TIMER_STOP(name) do { pt_##name.reset(NULL); } while(0)
#define PERF_TIMER_PAUSE(name) pt_##name->pause()