Changeset 2678


Ignore:
Timestamp:
11/19/24 12:43:43 (3 months ago)
Author:
ymipsl
Message:

Add averaging to xios_timers

YM

Location:
XIOS3/dev/XIOS_NOTIFICATIONS_MANAGER/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • XIOS3/dev/XIOS_NOTIFICATIONS_MANAGER/src/timer.cpp

    r1750 r2678  
    1111  std::map<std::string,CTimer> CTimer::allTimer; 
    1212   
    13   CTimer::CTimer(const std::string& name_, bool trace) : name(name_)  
     13  CTimer::CTimer(const std::string& name_, bool trace) : name(name_), num_(0) 
    1414  {  
    1515    isTracing_=trace ; 
     
    3636    if (suspended)  
    3737    { 
     38      num_++ ; 
    3839      lastTime = getTime(); 
    3940      if (isTracing_) traceBegin(name); 
     
    5354  } 
    5455   
     56  double CTimer::getNumCall(void) 
     57  { 
     58    return num_; 
     59  } 
     60 
     61  double CTimer::getAverageTime(void) 
     62  { 
     63    if (num_==0) return 0. ; 
     64    else return cumulatedTime/num_; 
     65  } 
     66 
    5567  CTimer& CTimer::get(const std::string name, bool trace) 
    5668  { 
  • XIOS3/dev/XIOS_NOTIFICATIONS_MANAGER/src/timer.hpp

    r2399 r2678  
    1515      bool isTracing_ ; 
    1616      std::string name; 
     17      size_t num_ ; 
    1718 
    1819      CTimer(const std::string& name, bool trace=true); 
     
    2324      void minus(double time) { cumulatedTime-=time ;} 
    2425      double getCumulatedTime(void); 
     26      double getNumCall(void) ; 
     27      double getAverageTime(void) ; 
    2528      static std::map<std::string,CTimer> allTimer; 
    2629      static double getTime(void); 
Note: See TracChangeset for help on using the changeset viewer.