summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Linden <none@none>2012-12-04 19:10:02 -0800
committerRichard Linden <none@none>2012-12-04 19:10:02 -0800
commit6c7825107f6ebb3dd8697a52aeb5d29a93060dc4 (patch)
treefa4e359f1818b7584596cf34111b90cc4d345796
parent407e5013f3845208e0a60e26e8f0a7fad997df5d (diff)
SH-3406 WIP convert fast timers to lltrace system
added copy constructor to periodic recording to allow snapshot generation in fast timer view fixed build errors
-rw-r--r--indra/llcommon/lltrace.h4
-rw-r--r--indra/llcommon/lltracerecording.cpp14
-rw-r--r--indra/llcommon/lltracerecording.h3
-rw-r--r--indra/newview/llfasttimerview.cpp47
-rw-r--r--indra/newview/llfasttimerview.h3
-rwxr-xr-xindra/newview/llstartup.cpp3
6 files changed, 53 insertions, 21 deletions
diff --git a/indra/llcommon/lltrace.h b/indra/llcommon/lltrace.h
index 9e275da647..a6b1b227c9 100644
--- a/indra/llcommon/lltrace.h
+++ b/indra/llcommon/lltrace.h
@@ -213,10 +213,10 @@ namespace LLTrace
: public LLInstanceTracker<TraceType<ACCUMULATOR>, std::string>
{
public:
- TraceType(const char* name, const char* description = "")
+ TraceType(const char* name, const char* description = NULL)
: LLInstanceTracker(name),
mName(name),
- mDescription(description)
+ mDescription(description ? description : "")
{
mAccumulatorIndex = AccumulatorBuffer<ACCUMULATOR>::getDefaultBuffer().reserveSlot();
}
diff --git a/indra/llcommon/lltracerecording.cpp b/indra/llcommon/lltracerecording.cpp
index 0d4d07faf6..7ed7e57570 100644
--- a/indra/llcommon/lltracerecording.cpp
+++ b/indra/llcommon/lltracerecording.cpp
@@ -305,6 +305,20 @@ PeriodicRecording::PeriodicRecording( S32 num_periods, EStopWatchState state)
initTo(state);
}
+PeriodicRecording::PeriodicRecording(PeriodicRecording& other)
+: mNumPeriods(other.mNumPeriods),
+ mCurPeriod(other.mCurPeriod),
+ mTotalValid(other.mTotalValid),
+ mTotalRecording(other.mTotalRecording)
+{
+ mRecordingPeriods = new Recording[mNumPeriods];
+ for (S32 i = 0; i < mNumPeriods; i++)
+ {
+ mRecordingPeriods[i] = other.mRecordingPeriods[i];
+ }
+}
+
+
PeriodicRecording::~PeriodicRecording()
{
delete[] mRecordingPeriods;
diff --git a/indra/llcommon/lltracerecording.h b/indra/llcommon/lltracerecording.h
index efed3f662e..a3af215dd3 100644
--- a/indra/llcommon/lltracerecording.h
+++ b/indra/llcommon/lltracerecording.h
@@ -234,6 +234,7 @@ namespace LLTrace
{
public:
PeriodicRecording(S32 num_periods, EStopWatchState state = STOPPED);
+ PeriodicRecording(PeriodicRecording& recording);
~PeriodicRecording();
void nextPeriod();
@@ -261,11 +262,13 @@ namespace LLTrace
Recording& getPrevRecordingPeriod(S32 offset)
{
+ offset = llclamp(offset, 0, mNumPeriods - 1);
return mRecordingPeriods[(mCurPeriod + mNumPeriods - offset) % mNumPeriods];
}
const Recording& getPrevRecordingPeriod(S32 offset) const
{
+ offset = llclamp(offset, 0, mNumPeriods - 1);
return mRecordingPeriods[(mCurPeriod + mNumPeriods - offset) % mNumPeriods];
}
diff --git a/indra/newview/llfasttimerview.cpp b/indra/newview/llfasttimerview.cpp
index acf3799f27..a06fac6bb6 100644
--- a/indra/newview/llfasttimerview.cpp
+++ b/indra/newview/llfasttimerview.cpp
@@ -87,21 +87,38 @@ LLFastTimerView::LLFastTimerView(const LLSD& key)
mScrollIndex(0),
mHoverID(NULL),
mHoverBarIndex(-1),
- mPrintStats(-1)
+ mPrintStats(-1),
+ mRecording(&LLTrace::get_frame_recording())
{}
+LLFastTimerView::~LLFastTimerView()
+{
+ if (mRecording != &LLTrace::get_frame_recording())
+ {
+ delete mRecording;
+ }
+ mRecording = NULL;
+}
+
void LLFastTimerView::onPause()
{
LLTrace::TimeBlock::sPauseHistory = !LLTrace::TimeBlock::sPauseHistory;
// reset scroll to bottom when unpausing
if (!LLTrace::TimeBlock::sPauseHistory)
{
+ mRecording = new LLTrace::PeriodicRecording(LLTrace::get_frame_recording());
mScrollIndex = 0;
LLTrace::TimeBlock::sResetHistory = true;
getChild<LLButton>("pause_btn")->setLabel(getString("pause"));
}
else
{
+ if (mRecording != &LLTrace::get_frame_recording())
+ {
+ delete mRecording;
+ }
+ mRecording = &LLTrace::get_frame_recording();
+
getChild<LLButton>("pause_btn")->setLabel(getString("run"));
}
}
@@ -133,7 +150,7 @@ BOOL LLFastTimerView::handleRightMouseDown(S32 x, S32 y, MASK mask)
{
S32 bar_idx = MAX_VISIBLE_HISTORY - ((y - mBarRect.mBottom) * (MAX_VISIBLE_HISTORY + 2) / mBarRect.getHeight());
bar_idx = llclamp(bar_idx, 0, MAX_VISIBLE_HISTORY);
- mPrintStats = LLTrace::TimeBlock::HISTORY_NUM - mScrollIndex - bar_idx;
+ mPrintStats = mScrollIndex + bar_idx;
return TRUE;
}
return LLFloater::handleRightMouseDown(x, y, mask);
@@ -217,7 +234,7 @@ BOOL LLFastTimerView::handleMouseUp(S32 x, S32 y, MASK mask)
BOOL LLFastTimerView::handleHover(S32 x, S32 y, MASK mask)
{
- LLTrace::PeriodicRecording& frame_recording = LLTrace::get_frame_recording();
+ LLTrace::PeriodicRecording& frame_recording = *mRecording;
if (hasMouseCapture())
{
@@ -231,7 +248,7 @@ BOOL LLFastTimerView::handleHover(S32 x, S32 y, MASK mask)
if(LLTrace::TimeBlock::sPauseHistory && mBarRect.pointInRect(x, y))
{
- mHoverBarIndex = llmin(LLTrace::get_frame_recording().getNumPeriods() - 1,
+ mHoverBarIndex = llmin(mRecording->getNumPeriods() - 1,
MAX_VISIBLE_HISTORY - ((y - mBarRect.mBottom) * (MAX_VISIBLE_HISTORY + 2) / mBarRect.getHeight()));
if (mHoverBarIndex == 0)
{
@@ -286,12 +303,10 @@ BOOL LLFastTimerView::handleHover(S32 x, S32 y, MASK mask)
}
-static std::string get_tooltip(LLTrace::TimeBlock& timer, S32 history_index = -1)
+static std::string get_tooltip(LLTrace::TimeBlock& timer, S32 history_index, LLTrace::PeriodicRecording& frame_recording)
{
F64 ms_multiplier = 1000.0 / (F64)LLTrace::TimeBlock::countsPerSecond();
- LLTrace::PeriodicRecording& frame_recording = LLTrace::get_frame_recording();
-
std::string tooltip;
if (history_index < 0)
{
@@ -315,7 +330,7 @@ BOOL LLFastTimerView::handleToolTip(S32 x, S32 y, MASK mask)
LLRect screen_rect;
localRectToScreen(mToolTipRect, &screen_rect);
- std::string tooltip = get_tooltip(*mHoverTimer, LLTrace::TimeBlock::HISTORY_NUM - mScrollIndex - mHoverBarIndex);
+ std::string tooltip = get_tooltip(*mHoverTimer, mScrollIndex + mHoverBarIndex, *mRecording);
LLToolTipMgr::instance().show(LLToolTip::Params()
.message(tooltip)
@@ -333,7 +348,7 @@ BOOL LLFastTimerView::handleToolTip(S32 x, S32 y, MASK mask)
LLTrace::TimeBlock* idp = getLegendID(y);
if (idp)
{
- LLToolTipMgr::instance().show(get_tooltip(*idp));
+ LLToolTipMgr::instance().show(get_tooltip(*idp, -1, *mRecording));
return TRUE;
}
@@ -345,7 +360,7 @@ BOOL LLFastTimerView::handleToolTip(S32 x, S32 y, MASK mask)
BOOL LLFastTimerView::handleScrollWheel(S32 x, S32 y, S32 clicks)
{
- LLTrace::PeriodicRecording& frame_recording = LLTrace::get_frame_recording();
+ LLTrace::PeriodicRecording& frame_recording = *mRecording;
LLTrace::TimeBlock::sPauseHistory = TRUE;
mScrollIndex = llclamp( mScrollIndex + clicks,
@@ -362,7 +377,7 @@ void LLFastTimerView::draw()
{
LLFastTimer t(FTM_RENDER_TIMER);
- LLTrace::PeriodicRecording& frame_recording = LLTrace::get_frame_recording();
+ LLTrace::PeriodicRecording& frame_recording = *mRecording;
std::string tdesc;
@@ -480,7 +495,7 @@ void LLFastTimerView::draw()
S32 calls = 0;
if (mHoverBarIndex > 0 && mHoverID)
{
- S32 hidx = LLTrace::TimeBlock::HISTORY_NUM - mScrollIndex - mHoverBarIndex;
+ S32 hidx = mScrollIndex + mHoverBarIndex;
ms = frame_recording.getPrevRecordingPeriod(hidx).getSum(*idp);
calls = frame_recording.getPrevRecordingPeriod(hidx).getSum(idp->callCount());
}
@@ -660,7 +675,7 @@ void LLFastTimerView::draw()
S32 tidx;
if (j >= 0)
{
- tidx = LLTrace::TimeBlock::HISTORY_NUM - j - 1 - mScrollIndex;
+ tidx = j + 1 + mScrollIndex;
}
else
{
@@ -870,8 +885,8 @@ void LLFastTimerView::draw()
gGL.color4f(col[0], col[1], col[2], alpha);
gGL.begin(LLRender::TRIANGLE_STRIP);
for (U32 j = frame_recording.getNumPeriods();
- j < LLTrace::TimeBlock::HISTORY_NUM;
- j++)
+ j > 0;
+ j--)
{
LLUnit<LLUnits::Seconds, F32> time = llmax(frame_recording.getPrevRecordingPeriod(j).getSum(*idp), LLUnit<LLUnits::Seconds, F64>(0.000001));
U32 calls = frame_recording.getPrevRecordingPeriod(j).getSum(idp->callCount());
@@ -882,7 +897,7 @@ void LLFastTimerView::draw()
cur_max = llmax(cur_max, time);
cur_max_calls = llmax(cur_max_calls, calls);
}
- F32 x = mGraphRect.mLeft + j * (F32)(mGraphRect.getWidth())/(LLTrace::TimeBlock::HISTORY_NUM-1);
+ F32 x = mGraphRect.mRight - j * (F32)(mGraphRect.getWidth())/(LLTrace::TimeBlock::HISTORY_NUM-1);
F32 y = mDisplayHz
? mGraphRect.mBottom + (1.f / time.value()) * ((F32) mGraphRect.getHeight() / (1.f / max_time.value()))
: mGraphRect.mBottom + time * ((F32)mGraphRect.getHeight() / max_time);
diff --git a/indra/newview/llfasttimerview.h b/indra/newview/llfasttimerview.h
index 55adae4147..6474c2f524 100644
--- a/indra/newview/llfasttimerview.h
+++ b/indra/newview/llfasttimerview.h
@@ -30,11 +30,13 @@
#include "llfloater.h"
#include "llfasttimer.h"
#include "llunit.h"
+#include "lltracerecording.h"
class LLFastTimerView : public LLFloater
{
public:
LLFastTimerView(const LLSD&);
+ ~LLFastTimerView();
BOOL postBuild();
static BOOL sAnalyzePerformance;
@@ -92,6 +94,7 @@ private:
LLFrameTimer mHighlightTimer;
S32 mPrintStats;
LLRect mGraphRect;
+ LLTrace::PeriodicRecording* mRecording;
};
#endif
diff --git a/indra/newview/llstartup.cpp b/indra/newview/llstartup.cpp
index 69999071e7..648fb0f7b7 100755
--- a/indra/newview/llstartup.cpp
+++ b/indra/newview/llstartup.cpp
@@ -2183,9 +2183,6 @@ bool idle_startup()
LLAppViewer::instance()->handleLoginComplete();
- // reset timers now that we are running "logged in" logic
- LLTrace::TimeBlock::reset();
-
LLAgentPicksInfo::getInstance()->requestNumberOfPicks();
LLIMFloater::initIMFloater();