|
reSIProcate/stack
9694
|
Accumulates time and count by distinct string. More...
#include <TimeAccumulate.hxx>

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 |
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.
typedef std::map<Data, Accumulator> resip::TimeAccumulate::TimeMap [private] |
Definition at line 94 of file TimeAccumulate.hxx.
| 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;
}

| 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;
}
Definition at line 61 of file TimeAccumulate.hxx.
References mMutex, and mTimes.
{
Lock lock(TimeAccumulate::mMutex);
return TimeAccumulate::mTimes[name].totalTime;
}
resip::Mutex TimeAccumulate::mMutex [static, private] |
Definition at line 99 of file TimeAccumulate.hxx.
Referenced by clear(), dump(), getCount(), getTime(), and ~TimeAccumulate().
const Data resip::TimeAccumulate::mName [private] |
Definition at line 96 of file TimeAccumulate.hxx.
Referenced by ~TimeAccumulate().
const UInt64 resip::TimeAccumulate::mStart [private] |
Definition at line 97 of file TimeAccumulate.hxx.
Referenced by ~TimeAccumulate().
TimeAccumulate::TimeMap TimeAccumulate::mTimes [static, private] |
Definition at line 100 of file TimeAccumulate.hxx.
Referenced by clear(), dump(), getCount(), getTime(), and ~TimeAccumulate().
1.7.5.1