From 3c27bb36d482879ffa1d11e9bdb1fb114beaff99 Mon Sep 17 00:00:00 2001 From: Antonin Portelli Date: Mon, 13 Aug 2018 20:17:45 +0100 Subject: [PATCH] Hadrons: direct timer access --- extras/Hadrons/Module.cc | 18 ++++++++++++++++++ extras/Hadrons/Module.hpp | 1 + 2 files changed, 19 insertions(+) diff --git a/extras/Hadrons/Module.cc b/extras/Hadrons/Module.cc index 8ac33ccf..f0f3def1 100644 --- a/extras/Hadrons/Module.cc +++ b/extras/Hadrons/Module.cc @@ -75,6 +75,24 @@ void ModuleBase::startTimer(const std::string &name) } } +GridTime ModuleBase::getTimer(const std::string &name) +{ + GridTime t; + + if (!name.empty()) + { + stopTimer(name); + t = timer_.at(name).Elapsed(); + startTimer(name); + } + else + { + t = GridTime::zero(); + } + + return t; +} + void ModuleBase::startCurrentTimer(const std::string &name) { if (!name.empty()) diff --git a/extras/Hadrons/Module.hpp b/extras/Hadrons/Module.hpp index f3d87c2d..8f260c19 100644 --- a/extras/Hadrons/Module.hpp +++ b/extras/Hadrons/Module.hpp @@ -165,6 +165,7 @@ public: void operator()(void); // timers void startTimer(const std::string &name); + GridTime getTimer(const std::string &name); void startCurrentTimer(const std::string &name); void stopTimer(const std::string &name); void stopCurrentTimer(void);