summaryrefslogtreecommitdiff
path: root/indra/llcommon
diff options
context:
space:
mode:
Diffstat (limited to 'indra/llcommon')
-rw-r--r--indra/llcommon/llfasttimer.cpp40
-rw-r--r--indra/llcommon/llfasttimer.h10
2 files changed, 20 insertions, 30 deletions
diff --git a/indra/llcommon/llfasttimer.cpp b/indra/llcommon/llfasttimer.cpp
index 700ad65bf9..d54e1a93ea 100644
--- a/indra/llcommon/llfasttimer.cpp
+++ b/indra/llcommon/llfasttimer.cpp
@@ -113,9 +113,10 @@ public:
/*virtual */ void initSingleton()
{
mTimerRoot = new LLFastTimer::NamedTimer("root");
- mRootFrameState = &mTimerRoot->getFrameState();
+ mRootFrameState.setNamedTimer(mTimerRoot);
+ mTimerRoot->setFrameState(&mRootFrameState);
mTimerRoot->mParent = mTimerRoot;
- mRootFrameState->mParent = mRootFrameState;
+ mRootFrameState.mParent = &mRootFrameState;
}
~NamedTimerFactory()
@@ -125,15 +126,10 @@ public:
delete mTimerRoot;
}
- LLFastTimer::NamedTimer& createNamedTimer(const std::string& name)
+ LLFastTimer::NamedTimer& createNamedTimer(const std::string& name, LLFastTimer::FrameState* state)
{
- timer_map_t::iterator found_it = mTimers.find(name);
- if (found_it != mTimers.end())
- {
- return *found_it->second;
- }
-
LLFastTimer::NamedTimer* timer = new LLFastTimer::NamedTimer(name);
+ timer->setFrameState(state);
timer->setParent(mTimerRoot);
mTimers.insert(std::make_pair(name, timer));
@@ -152,7 +148,7 @@ public:
LLFastTimer::NamedTimer* getRootTimer() { return mTimerRoot; }
- typedef std::map<std::string, LLFastTimer::NamedTimer*> timer_map_t;
+ typedef std::multimap<std::string, LLFastTimer::NamedTimer*> timer_map_t;
timer_map_t::iterator beginTimers() { return mTimers.begin(); }
timer_map_t::iterator endTimers() { return mTimers.end(); }
S32 timerCount() { return mTimers.size(); }
@@ -161,20 +157,18 @@ private:
timer_map_t mTimers;
LLFastTimer::NamedTimer* mTimerRoot;
- LLFastTimer::FrameState* mRootFrameState;
+ LLFastTimer::FrameState mRootFrameState;
};
LLFastTimer::DeclareTimer::DeclareTimer(const std::string& name, bool open )
-: mTimer(NamedTimerFactory::instance().createNamedTimer(name))
+: mTimer(NamedTimerFactory::instance().createNamedTimer(name, &mFrameState))
{
- mFrameState = &mTimer.getFrameState();
mTimer.setCollapsed(!open);
}
LLFastTimer::DeclareTimer::DeclareTimer(const std::string& name)
-: mTimer(NamedTimerFactory::instance().createNamedTimer(name))
+: mTimer(NamedTimerFactory::instance().createNamedTimer(name, &mFrameState))
{
- mFrameState = &mTimer.getFrameState();
}
//static
@@ -224,13 +218,13 @@ LLFastTimer::NamedTimer::NamedTimer(const std::string& name)
mTotalTimeCounter(0),
mCountAverage(0),
mCallAverage(0),
- mNeedsSorting(false)
+ mNeedsSorting(false),
+ mFrameState(NULL)
{
mCountHistory = new U32[HISTORY_NUM];
memset(mCountHistory, 0, sizeof(U32) * HISTORY_NUM);
mCallHistory = new U32[HISTORY_NUM];
memset(mCallHistory, 0, sizeof(U32) * HISTORY_NUM);
- mFrameState.setNamedTimer(this);
}
LLFastTimer::NamedTimer::~NamedTimer()
@@ -290,9 +284,10 @@ S32 LLFastTimer::NamedTimer::getDepth()
{
S32 depth = 0;
NamedTimer* timerp = mParent;
- while(timerp && timerp->mParent != timerp)
+ while(timerp)
{
depth++;
+ if (timerp->getParent() == timerp) break;
timerp = timerp->mParent;
}
return depth;
@@ -545,14 +540,9 @@ U32 LLFastTimer::NamedTimer::getHistoricalCalls(S32 history_index ) const
return mCallHistory[history_idx];
}
-const LLFastTimer::FrameState& LLFastTimer::NamedTimer::getFrameState() const
-{
- return mFrameState;
-}
-
-LLFastTimer::FrameState& LLFastTimer::NamedTimer::getFrameState()
+LLFastTimer::FrameState& LLFastTimer::NamedTimer::getFrameState() const
{
- return mFrameState;
+ return *mFrameState;
}
std::vector<LLFastTimer::NamedTimer*>::const_iterator LLFastTimer::NamedTimer::beginChildren()
diff --git a/indra/llcommon/llfasttimer.h b/indra/llcommon/llfasttimer.h
index 07af0f1d4d..e42e549df5 100644
--- a/indra/llcommon/llfasttimer.h
+++ b/indra/llcommon/llfasttimer.h
@@ -91,8 +91,8 @@ public:
U32 getHistoricalCount(S32 history_index = 0) const;
U32 getHistoricalCalls(S32 history_index = 0) const;
- const FrameState& getFrameState() const;
- FrameState& getFrameState();
+ void setFrameState(FrameState* state) { mFrameState = state; state->setNamedTimer(this); }
+ FrameState& getFrameState() const;
private:
friend class LLFastTimer;
@@ -116,7 +116,7 @@ public:
//
// members
//
- FrameState mFrameState;
+ FrameState* mFrameState;
std::string mName;
@@ -147,7 +147,7 @@ public:
NamedTimer& getNamedTimer() { return mTimer; }
private:
- FrameState* mFrameState;
+ FrameState mFrameState;
NamedTimer& mTimer;
};
@@ -155,7 +155,7 @@ public:
LLFastTimer(LLFastTimer::FrameState* state);
LL_FORCE_INLINE LLFastTimer(LLFastTimer::DeclareTimer& timer)
- : mFrameState(timer.mFrameState)
+ : mFrameState(&timer.mFrameState)
{
#if FAST_TIMER_ON
LLFastTimer::FrameState* frame_state = mFrameState;