Timers.cpp
Go to the documentation of this file.
1 /*------------------------------- phasicFlow ---------------------------------
2  O C enter of
3  O O E ngineering and
4  O O M ultiscale modeling of
5  OOOOOOO F luid flow
6 ------------------------------------------------------------------------------
7  Copyright (C): www.cemf.ir
8  email: hamid.r.norouzi AT gmail.com
9 ------------------------------------------------------------------------------
10 Licence:
11  This file is part of phasicFlow code. It is a free software for simulating
12  granular and multiphase flows. You can redistribute it and/or modify it under
13  the terms of GNU General Public License v3 or any other later versions.
14 
15  phasicFlow is distributed to help others in their research in the field of
16  granular and multiphase flows, but WITHOUT ANY WARRANTY; without even the
17  implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
18 
19 -----------------------------------------------------------------------------*/
20 
21 
22 #include "Timers.hpp"
23 
25 {
26  // first this timer
27  real total = 0;
28  if(this->timerActive()) total += this->totalTime();
29 
30  for(const auto tmr:timers_)
31  {
32  if(tmr -> master())
33  {
34  total += dynamic_cast<const Timers*>(tmr)->accTimersTotal();
35  }
36  else if(tmr->timerActive())
37  {
38  total += tmr->totalTime();
39  }
40  }
41 
42  return total;
43 }
44 
45 
46 bool pFlow::Timers::write(iOstream& os, bool subTree)const
47 {
48  if(level() == 0 )os<<"\n";
49  Timer::write(os, subTree);
50  if(subTree)
51  {
52 
53  for(const auto& timer:timers_)
54  {
55  timer->write(os, subTree);
56  }
57 
58  }
59  if(level() == 0 )os<<"\n";
60  return true;
61 }
pFlow::real
float real
Definition: builtinTypes.hpp:46
pFlow::Timer::totalTime
real totalTime() const
Definition: Timer.hpp:125
pFlow::Timers::master
virtual bool master() const
Definition: Timers.hpp:93
pFlow::Timer::write
virtual bool write(iOstream &os, bool subTree) const
Definition: Timer.cpp:52
pFlow::Timers
Definition: Timers.hpp:33
Timers.hpp
pFlow::Timers::accTimersTotal
real accTimersTotal() const override
Definition: Timers.cpp:24
pFlow::Timer::timer
std::chrono::high_resolution_clock timer
Definition: Timer.hpp:43
pFlow::Timers::write
virtual bool write(iOstream &os, bool subTree=true) const
Definition: Timers.cpp:46
pFlow::Timer::timerActive
bool timerActive() const
Definition: Timer.hpp:113
pFlow::iOstream
Definition: iOstream.hpp:53
pFlow::Timers::timers_
List< pFlow::Timer * > timers_
Definition: Timers.hpp:39