timers modefied
This commit is contained in:
parent
c6ddf00d7b
commit
ef1e3c1e33
|
@ -25,8 +25,6 @@ bool pFlow::sphereDEMSystem::loop()
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
Control().timers().start();
|
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|
||||||
if(! insertion_().insertParticles(
|
if(! insertion_().insertParticles(
|
||||||
|
@ -56,9 +54,6 @@ bool pFlow::sphereDEMSystem::loop()
|
||||||
|
|
||||||
geometry_->afterIteration();
|
geometry_->afterIteration();
|
||||||
|
|
||||||
|
|
||||||
Control().timers().end();
|
|
||||||
|
|
||||||
}while(Control()++);
|
}while(Control()++);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -65,7 +65,6 @@ if(!cmds.parse(argc, argv)) return 0;
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
Control.timers().start();
|
|
||||||
|
|
||||||
if(! sphInsertion.insertParticles(
|
if(! sphInsertion.insertParticles(
|
||||||
Control.time().currentTime(),
|
Control.time().currentTime(),
|
||||||
|
@ -94,8 +93,6 @@ if(!cmds.parse(argc, argv)) return 0;
|
||||||
surfGeometry.afterIteration();
|
surfGeometry.afterIteration();
|
||||||
|
|
||||||
|
|
||||||
Control.timers().end();
|
|
||||||
|
|
||||||
}while(Control++);
|
}while(Control++);
|
||||||
|
|
||||||
REPORT(0)<<"\nEnd of time loop.\n"<<endREPORT;
|
REPORT(0)<<"\nEnd of time loop.\n"<<endREPORT;
|
||||||
|
|
|
@ -77,18 +77,24 @@ bool pFlow::Timer::write(iOstream& os, bool subTree)const
|
||||||
|
|
||||||
if(lvl==0)
|
if(lvl==0)
|
||||||
os<<greenColor<<boldChar;
|
os<<greenColor<<boldChar;
|
||||||
|
else if(master())
|
||||||
|
os<<yellowColor;
|
||||||
|
|
||||||
|
|
||||||
os<<name_;
|
os<<name_;
|
||||||
|
|
||||||
if(timerActive())
|
auto tt = accTimersTotal();
|
||||||
if(master())
|
if(abs(tt)>smallValue)
|
||||||
os<<" execution time (s): total ("<<
|
{
|
||||||
totalTime()<<"), av. ("<<
|
os<<" execution time (s): total ("<<
|
||||||
averageTime()<<").";
|
tt<<")";
|
||||||
else
|
|
||||||
os<<" execution time (s): total ("<<
|
if(!master())
|
||||||
cyanText(totalTime())<<"), av. ("<<
|
{
|
||||||
cyanText(averageTime())<<").";
|
os<<", av. ("<<
|
||||||
|
averageTime()<<").";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
os<<defaultColor;
|
os<<defaultColor;
|
||||||
os<<'\n';
|
os<<'\n';
|
||||||
|
|
|
@ -109,32 +109,41 @@ public:
|
||||||
accTime_ += lastTime_;
|
accTime_ += lastTime_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline
|
||||||
bool timerActive()const
|
bool timerActive()const
|
||||||
{
|
{
|
||||||
return numIteration_!=0;
|
return numIteration_!=0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline
|
||||||
real lastTime()const
|
real lastTime()const
|
||||||
{
|
{
|
||||||
return lastTime_;
|
return lastTime_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline
|
||||||
real totalTime()const
|
real totalTime()const
|
||||||
{
|
{
|
||||||
return accTime_;
|
return accTime_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline
|
||||||
real averageTime()const
|
real averageTime()const
|
||||||
{
|
{
|
||||||
|
|
||||||
return accTime_/max(numIteration_, 1);
|
return accTime_/max(numIteration_, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
virtual
|
||||||
|
real accTimersTotal()const
|
||||||
|
{
|
||||||
|
return totalTime();
|
||||||
|
}
|
||||||
|
|
||||||
//// - IO operations
|
//// - IO operations
|
||||||
|
|
||||||
virtual bool write(iOstream& os, bool subTree)const;
|
virtual bool write(iOstream& os, bool subTree)const;
|
||||||
|
|
||||||
|
|
||||||
virtual bool read(iIstream& is)
|
virtual bool read(iIstream& is)
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -21,6 +21,27 @@ Licence:
|
||||||
|
|
||||||
#include "Timers.hpp"
|
#include "Timers.hpp"
|
||||||
|
|
||||||
|
pFlow::real pFlow::Timers::accTimersTotal()const
|
||||||
|
{
|
||||||
|
// first this timer
|
||||||
|
real total = 0;
|
||||||
|
if(this->timerActive()) total += this->totalTime();
|
||||||
|
|
||||||
|
for(const auto tmr:timers_)
|
||||||
|
{
|
||||||
|
if(tmr -> master())
|
||||||
|
{
|
||||||
|
total += dynamic_cast<const Timers*>(tmr)->accTimersTotal();
|
||||||
|
}
|
||||||
|
else if(tmr->timerActive())
|
||||||
|
{
|
||||||
|
total += tmr->totalTime();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return total;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
bool pFlow::Timers::write(iOstream& os, bool subTree)const
|
bool pFlow::Timers::write(iOstream& os, bool subTree)const
|
||||||
{
|
{
|
||||||
|
|
|
@ -30,7 +30,7 @@ namespace pFlow
|
||||||
|
|
||||||
class Timers
|
class Timers
|
||||||
:
|
:
|
||||||
public Timer
|
public pFlow::Timer
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
|
@ -93,6 +93,8 @@ public:
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
real accTimersTotal()const override;
|
||||||
|
|
||||||
virtual bool write(iOstream& os, bool subTree = true)const;
|
virtual bool write(iOstream& os, bool subTree = true)const;
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -100,6 +100,19 @@ pFlow::timeControl::timeControl(
|
||||||
checkForOutputToFile();
|
checkForOutputToFile();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool pFlow::timeControl::finalTime()const
|
||||||
|
{
|
||||||
|
if( currentTime_ >= endTime_ ) return true;
|
||||||
|
if( abs(currentTime_-endTime_) < 0.5*dt_ )return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool pFlow::timeControl::reachedStopAt()const
|
||||||
|
{
|
||||||
|
if( currentTime_ >= stopAt_ ) return true;
|
||||||
|
if( abs(currentTime_-stopAt_) < 0.5*dt_ )return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
void pFlow::timeControl::checkForOutputToFile()
|
void pFlow::timeControl::checkForOutputToFile()
|
||||||
{
|
{
|
||||||
|
|
|
@ -152,18 +152,9 @@ public:
|
||||||
return currentIter_;
|
return currentIter_;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool finalTime()const
|
bool finalTime()const;
|
||||||
{
|
|
||||||
if( currentTime_ >= endTime_ ) return true;
|
bool reachedStopAt()const;
|
||||||
if( abs(currentTime_-endTime_) < 0.5*dt_ )return true;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
bool reachedStopAt()const
|
|
||||||
{
|
|
||||||
if( currentTime_ >= stopAt_ ) return true;
|
|
||||||
if( abs(currentTime_-stopAt_) < 0.5*dt_ )return true;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool outputToFile()const
|
bool outputToFile()const
|
||||||
{
|
{
|
||||||
|
|
|
@ -239,31 +239,37 @@ bool pFlow::systemControl::operator ++(int)
|
||||||
//output<< "time()++"<<endl;
|
//output<< "time()++"<<endl;
|
||||||
auto finished = time()++;
|
auto finished = time()++;
|
||||||
|
|
||||||
writeToFileTimer_.start();
|
if(!finished)
|
||||||
if(time().currentIter() != 0)
|
|
||||||
{
|
{
|
||||||
//- save the results to file
|
writeToFileTimer_.start();
|
||||||
if( !time().write() )
|
//if(time().currentIter() != 0 )
|
||||||
{
|
{
|
||||||
fatalErrorInFunction;
|
//- save the results to file
|
||||||
return false;
|
if( !time().write() )
|
||||||
|
{
|
||||||
|
fatalErrorInFunction;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
writeToFileTimer_.end();
|
||||||
else if( time().finalTime() )
|
|
||||||
{
|
|
||||||
if( !time().write() )
|
|
||||||
{
|
|
||||||
fatalErrorInFunction;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
writeToFileTimer_.end();
|
|
||||||
|
|
||||||
//output<< "after finalTime()"<<endl;
|
if( time().timersReportTime() &&
|
||||||
|
|
||||||
if( time().timersReportTime() &&
|
|
||||||
timersReport() )
|
timersReport() )
|
||||||
|
{
|
||||||
|
timers_.write(output, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
else if (time().finalTime())
|
||||||
{
|
{
|
||||||
|
writeToFileTimer_.start();
|
||||||
|
if( !time().write() )
|
||||||
|
{
|
||||||
|
fatalErrorInFunction;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
writeToFileTimer_.end();
|
||||||
|
|
||||||
timers_.write(output, true);
|
timers_.write(output, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue