Changeset 652
- Timestamp:
- 07/24/15 16:40:06 (9 years ago)
- Location:
- XIOS/trunk/src
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
XIOS/trunk/src/timer.cpp
r501 r652 7 7 namespace xios 8 8 { 9 using namespace std; 10 11 map<string,CTimer*> CTimer::allTimer ; 9 std::map<std::string,CTimer> CTimer::allTimer; 12 10 13 CTimer::CTimer(const st ring& name_) : name(name_)11 CTimer::CTimer(const std::string& name_) : name(name_) 14 12 { 15 reset() 13 reset(); 16 14 } 17 15 … … 25 23 if (!suspended) 26 24 { 27 traceEnd(name) 28 cumulatedTime +=getTime()-lastTime;25 traceEnd(name); 26 cumulatedTime += getTime() - lastTime; 29 27 } 30 suspended =true;28 suspended = true; 31 29 } 32 30 … … 35 33 if (suspended) 36 34 { 37 lastTime =getTime();38 traceBegin(name) 35 lastTime = getTime(); 36 traceBegin(name); 39 37 } 40 suspended =false;38 suspended = false; 41 39 } 42 40 43 41 void CTimer::reset(void) 44 42 { 45 cumulatedTime =0.;46 suspended =true;43 cumulatedTime = 0.; 44 suspended = true; 47 45 } 48 46 49 47 double CTimer::getCumulatedTime(void) 50 48 { 51 return cumulatedTime 49 return cumulatedTime; 52 50 } 53 51 54 CTimer& CTimer::get(const st ring name)52 CTimer& CTimer::get(const std::string name) 55 53 { 56 map<string,CTimer*>::iterator it;57 i t=allTimer.find(name) ;58 if (it==allTimer.end()) it=allTimer.insert(pair<string,CTimer*>(name,new CTimer(name))).first;59 return *(it->second);54 std::map<std::string,CTimer>::iterator it = allTimer.find(name); 55 if (it == allTimer.end()) 56 it = allTimer.insert(std::make_pair(name, CTimer(name))).first; 57 return it->second; 60 58 } 61 59 } -
XIOS/trunk/src/timer.hpp
r501 r652 7 7 namespace xios 8 8 { 9 using namespace std ;10 11 12 9 class CTimer 13 10 { 14 public : 15 16 double cumulatedTime ; 17 double lastTime ; 18 bool suspended ; 19 string name ; 20 21 CTimer(const string& name) ; 22 void suspend(void) ; 23 void resume(void) ; 24 void reset(void) ; 25 double getCumulatedTime(void) ; 26 static map<string,CTimer*> allTimer ; 27 static double getTime(void) ; 28 static CTimer& get(string name) ; 29 } ; 30 11 public: 12 double cumulatedTime; 13 double lastTime; 14 bool suspended; 15 std::string name; 16 17 CTimer(const std::string& name); 18 void suspend(void); 19 void resume(void); 20 void reset(void); 21 double getCumulatedTime(void); 22 static std::map<std::string,CTimer> allTimer; 23 static double getTime(void); 24 static CTimer& get(std::string name); 25 }; 31 26 } 32 27
Note: See TracChangeset
for help on using the changeset viewer.