Skip to content
Snippets Groups Projects
Commit 16dbd21e authored by Christoph Rettinger's avatar Christoph Rettinger
Browse files

Added functionality to timers and fixed docu typos

parent 9d28f33b
Branches
Tags
No related merge requests found
......@@ -111,7 +111,7 @@ void TimingNode<TP>::swap(TimingNode<TP>& tt)
}
}
/// Finds the spezified timer in the timing hierarchy
/// Finds the specified timer in the timing hierarchy
/// \param name timer name which may include more than one hierarchy separated by "."
/// \code findTimer(tn, "firstLevel.secondLevel.thirdLevel.timerName"); \endcode
/// \relates TimingNode
......@@ -130,6 +130,31 @@ const Timer<TP>& findTimer( const TimingNode<TP>& tn, const std::string& name)
}
}
/// Checks if the specified timer exists in the timing hierarchy
/// \param name timer name which may include more than one hierarchy separated by "."
/// \code timerExists(tn, "firstLevel.secondLevel.thirdLevel.timerName"); \endcode
/// \relates TimingNode
template< typename TP > // Timing policy
bool timerExists( const TimingNode<TP>& tn, const std::string& name )
{
auto pos = name.find_first_of(".");
if (pos != std::string::npos)
{
if( tn.tree_.find(name.substr(0, pos)) != tn.tree_.end() )
{
return timerExists( tn.tree_.at(name.substr(0, pos)), name.substr(pos+1, std::string::npos));
}
else
{
return false;
}
}
else
{
return tn.tree_.find(name) != tn.tree_.end();
}
}
/// Resets the timer in the TimingNode structure and all sub timers
/// \relates TimingNode
template< typename TP > // Timing policy
......
......@@ -59,13 +59,13 @@ public:
void swap(TimingTree<TP>& tt);
/// Starts a timer beneath the current hirarchy level
/// Starts a timer beneath the current hierarchy level
void start(const std::string& name);
/// Stops the last started timer and jumps back one hirarchy level
/// Stops the last started timer and jumps back one hierarchy level
void stop(const std::string& name);
/// Checks if specified timer is currently running.
bool isTimerRunning(const std::string& name) const;
/// Resets the the timing hirarchy
/// Resets the the timing hierarchy
void reset();
//** Reduction ******************************************************************************************************
......@@ -81,7 +81,9 @@ public:
/// Returns the raw tree data structure
const TimingNode<TP>& getRawData() const;
const Timer<TP>& operator[](const std::string& name) const;
inline bool timerExists ( const std::string & n ) const;
/// Returns the name of the currently running timer
/// Might be expensive due to value search.
......@@ -89,7 +91,7 @@ public:
private:
/// Tree data structure
TimingNode<TP> root_;
/// Pointer to the current hirarchy level.
/// Pointer to the current hierarchy level.
TimingNode<TP>* current_;
};
......@@ -204,7 +206,7 @@ const TimingNode<TP>& TimingTree<TP>::getRawData() const
return root_;
}
/// Finds the spezified timer in the timing hierarchy
/// Finds the specified timer in the timing hierarchy
/// \param name timer name which may include more than one hierarchy separated by "."
/// \code tt["firstLevel.secondLevel.thirdLevel.timerName"].total(); \endcode
template< typename TP > // Timing policy
......@@ -213,6 +215,15 @@ const Timer<TP>& TimingTree<TP>::operator[](const std::string& name) const
return findTimer(root_, name);
}
/// Checks if the specified timer exists in the timing hierarchy
/// \param name timer name which may include more than one hierarchy separated by "."
/// \code tt.timerExists("firstLevel.secondLevel.thirdLevel.timerName"); \endcode
template< typename TP > // Timing policy
bool TimingTree<TP>::timerExists(const std::string& name) const
{
return walberla::timing::timerExists(root_, name);
}
template< typename TP > // Timing policy
std::string TimingTree<TP>::getCurrentTimerName() const
{
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment