Fast timer fix-up

The logic is incorrect in principle, but at least it's better behaved now.
Also, get fast timer out of important parts of aistatemachine.
This commit is contained in:
Siana Gearz
2012-09-10 02:06:07 +02:00
parent 2a70dde016
commit 8a44c8fce1
4 changed files with 334 additions and 333 deletions

View File

@@ -182,6 +182,7 @@ std::string LLFastTimer::sLogName = "";
BOOL LLFastTimer::sMetricLog = FALSE;
LLMutex* LLFastTimer::sLogLock = NULL;
std::queue<LLSD> LLFastTimer::sLogQueue;
const int LLFastTimer::NamedTimer::HISTORY_NUM = 300;
#if LL_WINDOWS
#define USE_RDTSC 1
@@ -435,16 +436,12 @@ LLFastTimer::NamedTimer::NamedTimer(const std::string& name)
mFrameStateIndex = frame_state_list.size();
getFrameStateList().push_back(FrameState(this));
mCountHistory = new U32[HISTORY_NUM];
memset(mCountHistory, 0, sizeof(U32) * HISTORY_NUM);
mCallHistory = new U32[HISTORY_NUM];
memset(mCallHistory, 0, sizeof(U32) * HISTORY_NUM);
mCountHistory.resize(HISTORY_NUM);
mCallHistory.resize(HISTORY_NUM);
}
LLFastTimer::NamedTimer::~NamedTimer()
{
delete[] mCountHistory;
delete[] mCallHistory;
}
std::string LLFastTimer::NamedTimer::getToolTip(S32 history_idx)
@@ -637,10 +634,12 @@ void LLFastTimer::NamedTimer::accumulateTimings()
// update timer history
int hidx = cur_frame % HISTORY_NUM;
int weight = llmin(100, cur_frame);
timerp->mCountHistory[hidx] = timerp->mTotalTimeCounter;
timerp->mCountAverage = ((U64)timerp->mCountAverage * cur_frame + timerp->mTotalTimeCounter) / (cur_frame+1);
timerp->mCountAverage = ((F64)timerp->mCountAverage * weight + (F64)timerp->mTotalTimeCounter) / (weight+1);
timerp->mCallHistory[hidx] = timerp->getFrameState().mCalls;
timerp->mCallAverage = ((U64)timerp->mCallAverage * cur_frame + timerp->getFrameState().mCalls) / (cur_frame+1);
timerp->mCallAverage = ((F64)timerp->mCallAverage * weight + (F64)timerp->getFrameState().mCalls) / (weight+1);
}
}
}
@@ -776,8 +775,10 @@ void LLFastTimer::NamedTimer::reset()
timer.mCountAverage = 0;
timer.mCallAverage = 0;
memset(timer.mCountHistory, 0, sizeof(U32) * HISTORY_NUM);
memset(timer.mCallHistory, 0, sizeof(U32) * HISTORY_NUM);
timer.mCountHistory.clear();
timer.mCountHistory.resize(HISTORY_NUM);
timer.mCallHistory.clear();
timer.mCallHistory.resize(HISTORY_NUM);
}
}
@@ -856,7 +857,8 @@ void LLFastTimer::nextFrame()
if (!sPauseHistory)
{
NamedTimer::processTimes();
sLastFrameIndex = sCurFrameIndex++;
sLastFrameIndex = sCurFrameIndex;
++sCurFrameIndex;
}
// get ready for next frame