Commit 7f8a8d2b authored by Quentin Khan's avatar Quentin Khan
Browse files

FAlgorithmTimers: documentation improvement & timers moved to stack

 - `nbTimers` constant has been moved to the end of the `Timers` enum to
    automaticaly get the number of timers.

 - `Timers` array has been moved to the stack.

 - Copy and a move constructors were added.
parent 735dd882
...@@ -18,53 +18,60 @@ ...@@ -18,53 +18,60 @@
#define FALGORITHMTIMERS_HPP #define FALGORITHMTIMERS_HPP
/** /**
* @brief This class provide a way for the different algorithms to * @brief Collection of timers for FMM operators.
* store the time spent in each operator.
* *
* This class provide a way for the different algorithms to
* store the time spent in each operator.
*/ */
class FAlgorithmTimers{ class FAlgorithmTimers{
protected:
FTic * Timers;
public: public:
/// The timer names
enum FTimers{ enum FTimers {
P2MTimer=0, P2MTimer,
M2MTimer=1, M2MTimer,
M2LTimer=2, M2LTimer,
L2LTimer=3, L2LTimer,
L2PTimer=4, L2PTimer,
P2PTimer=5, P2PTimer,
NearTimer=6, NearTimer,
nbTimers ///< Timer count
}; };
const int nbTimers = 7; protected:
/// Timer array
FTic Timers[nbTimers];
FAlgorithmTimers() : Timers(nullptr) public:
/// Constructor: resets all timers
FAlgorithmTimers()
{ {
Timers = new FTic[nbTimers]; for(int i = 0; i < nbTimers ; ++i){
for(int i=0; i<nbTimers ; ++i){
Timers[i].reset(); Timers[i].reset();
} }
} }
virtual ~FAlgorithmTimers(){ /// Default copy contructor
delete[] Timers; FAlgorithmTimers(const FAlgorithmTimers&) = default;
} /// Default move contructor
FAlgorithmTimers(FAlgorithmTimers&&) = default;
/// Returns the timer array
const FTic * getAllTimers() const { const FTic * getAllTimers() const {
return Timers; return Timers;
} }
/// Returns the timer count
int getNbOfTimerRecorded() const { int getNbOfTimerRecorded() const {
return nbTimers; return nbTimers;
} }
/// Elapsed time between last FTic::tic() and FTic::tac() for given timer.
double getTime(FTimers OpeTimer) const{ double getTime(FTimers OpeTimer) const{
//assert to verify size //assert to verify size
return Timers[OpeTimer].elapsed(); return Timers[OpeTimer].elapsed();
} }
/// Cumulated time between all FTic::tic() and FTic::tac() for given timer.
double getCumulatedTime(FTimers OpeTimer) const{ double getCumulatedTime(FTimers OpeTimer) const{
//assert to verify size //assert to verify size
return Timers[OpeTimer].cumulated(); return Timers[OpeTimer].cumulated();
......
Supports Markdown
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