reSIProcate/stack  9694
Classes | Public Member Functions | Static Public Member Functions | Private Types | Private Attributes | Static Private Attributes
resip::TimeAccumulate Class Reference

Accumulates time and count by distinct string. More...

#include <TimeAccumulate.hxx>

Collaboration diagram for resip::TimeAccumulate:
Collaboration graph
[legend]

List of all members.

Classes

struct  Accumulator
class  Guard

Public Member Functions

 TimeAccumulate (const Data &name)
 ~TimeAccumulate ()

Static Public Member Functions

static UInt64 getTime (const Data &name)
static size_t getCount (const Data &name)
static void dump ()
static void clear ()

Private Types

typedef std::map< Data,
Accumulator
TimeMap

Private Attributes

const Data mName
const UInt64 mStart

Static Private Attributes

static Mutex mMutex
static TimeMap mTimes

Detailed Description

Accumulates time and count by distinct string.

The data is available statically. Use class::method as the key when possible to avoid collision.

Definition at line 19 of file TimeAccumulate.hxx.


Member Typedef Documentation

typedef std::map<Data, Accumulator> resip::TimeAccumulate::TimeMap [private]

Definition at line 94 of file TimeAccumulate.hxx.


Constructor & Destructor Documentation

resip::TimeAccumulate::TimeAccumulate ( const Data name) [inline]

Definition at line 30 of file TimeAccumulate.hxx.

         : mName(name),
           mStart(Timer::getTimeMs())
      {}
resip::TimeAccumulate::~TimeAccumulate ( ) [inline]

Definition at line 35 of file TimeAccumulate.hxx.

References resip::TimeAccumulate::Accumulator::count, resip::Timer::getTimeMs(), mMutex, mName, mStart, mTimes, and resip::TimeAccumulate::Accumulator::totalTime.

      {
         UInt64 end = Timer::getTimeMs();
         end -= mStart;
         Lock lock(TimeAccumulate::mMutex);

         Accumulator& acc = TimeAccumulate::mTimes[mName];
         acc.count += 1;
         acc.totalTime += end;
      }

Here is the call graph for this function:


Member Function Documentation

void TimeAccumulate::clear ( void  ) [static]

Definition at line 30 of file TimeAccumulate.cxx.

References mMutex, and mTimes.

{
   Lock lock(mMutex);

   for (TimeMap::iterator i = TimeAccumulate::mTimes.begin();
        i != TimeAccumulate::mTimes.end(); i++)
   {
      i->second.count = 0;
      i->second.totalTime = 0;
   }
}
void TimeAccumulate::dump ( ) [static]

Definition at line 13 of file TimeAccumulate.cxx.

References mMutex, mTimes, and WarningLog.

{
   Lock lock(mMutex);
   WarningLog(<< "Accumulated times -------------------------:");
   for (TimeMap::const_iterator i = TimeAccumulate::mTimes.begin();
        i != TimeAccumulate::mTimes.end(); i++)
   {
      if (i->second.totalTime)
      {
         WarningLog(<< i->first << " = " << i->second.totalTime/1000.0 
                    << " seconds for " << i->second.count 
                    << " at " << i->second.count / (i->second.totalTime/1000.0) << " per second");
      }
   }
}
static size_t resip::TimeAccumulate::getCount ( const Data name) [inline, static]

Definition at line 67 of file TimeAccumulate.hxx.

References mMutex, and mTimes.

      {
         Lock lock(TimeAccumulate::mMutex);
         return TimeAccumulate::mTimes[name].count;
      }
static UInt64 resip::TimeAccumulate::getTime ( const Data name) [inline, static]

Definition at line 61 of file TimeAccumulate.hxx.

References mMutex, and mTimes.

      {
         Lock lock(TimeAccumulate::mMutex);
         return TimeAccumulate::mTimes[name].totalTime;
      }

Member Data Documentation

Definition at line 99 of file TimeAccumulate.hxx.

Referenced by clear(), dump(), getCount(), getTime(), and ~TimeAccumulate().

Definition at line 96 of file TimeAccumulate.hxx.

Referenced by ~TimeAccumulate().

Definition at line 97 of file TimeAccumulate.hxx.

Referenced by ~TimeAccumulate().

Definition at line 100 of file TimeAccumulate.hxx.

Referenced by clear(), dump(), getCount(), getTime(), and ~TimeAccumulate().


The documentation for this class was generated from the following files: