29 #ifndef ompLoopWatcher_hpp
30 #define ompLoopWatcher_hpp
33 #include "../sys/timeUtils.hpp"
74 template<
class _outputT=std::ostream,
bool _pr
intPretty=true,
bool _pr
intLoops=true,
bool _pr
intPercent=true,
bool _pr
intNLine=false,
bool _time = true>
78 typedef _outputT outputT;
109 if(_printLoops) (*_output) <<
" / " <<
_nLoops;
110 if(_printPercent) (*_output) <<
" (" << 100.0*((float)
_counter) /
_nLoops <<
"%)";
113 (*_output) <<
" " << (t1-t0)/
_counter <<
" s/loop ";
117 if(_printNLine) (*_output) <<
'\n';
118 if(!_printNLine) (*_output) <<
" \r";
120 (*_output) << std::flush;
125 if(_printLoops) (*_output) <<
_nLoops;
127 if(_time) (*_output) <<
" " << t0 <<
" " << t1;
128 if(_printNLine) (*_output) <<
'\n';
A class to track the number of iterations in an OMP parallelized loop.
void increment()
Increment the counter.
void advanceAndOutputStatus(size_t diff_count)
Advance and output status.
void _increment()
Increment the counter.
size_t _nLoops
The total number of loops.
void outputStatus()
Output current status.
void _advance(size_t diff_count)
Advance the counter by a number of steps.
size_t _counter
The current counter.
outputT * _output
Pointer to the instance of type outputT.
void _outputStatus()
Perform the output.
void incrementAndOutputStatus()
Increment and output status.
ompLoopWatcher(size_t nLoops, outputT &output)
Constructor.
void advance(size_t diff_count)
Advance the counter by a number of steps.
typeT get_curr_time(timespec &tsp)
Get the current system time in seconds.