From 819adb5eb4d7f982121f3dbd82750e05d26864d9 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Thu, 1 Nov 2012 00:26:44 -0700 Subject: SH-3405 FIX convert existing stats to lltrace system final removal of remaining LLStat code --- indra/newview/llfasttimerview.cpp | 1 - 1 file changed, 1 deletion(-) (limited to 'indra/newview/llfasttimerview.cpp') diff --git a/indra/newview/llfasttimerview.cpp b/indra/newview/llfasttimerview.cpp index 4dfb93f1bc..065b20ba2b 100644 --- a/indra/newview/llfasttimerview.cpp +++ b/indra/newview/llfasttimerview.cpp @@ -46,7 +46,6 @@ #include "llviewertexturelist.h" #include "llui.h" #include "llviewercontrol.h" -#include "llstat.h" #include "llfasttimer.h" #include "lltreeiterators.h" -- cgit v1.2.3 From a3e3e8b4ccd96e98da73acf1c584bbfa5a8b2b56 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Mon, 12 Nov 2012 19:08:14 -0800 Subject: SH-3406 WIP convert fast timers to lltrace system simplified llfasttimer code down to 2 classes llunit unit conversion now done in floating point or 64 bit integer precision, depending on source type --- indra/newview/llfasttimerview.cpp | 98 +++++++++++++++++++++++---------------- 1 file changed, 57 insertions(+), 41 deletions(-) (limited to 'indra/newview/llfasttimerview.cpp') diff --git a/indra/newview/llfasttimerview.cpp b/indra/newview/llfasttimerview.cpp index 065b20ba2b..0934028a8c 100644 --- a/indra/newview/llfasttimerview.cpp +++ b/indra/newview/llfasttimerview.cpp @@ -61,17 +61,17 @@ static const S32 LINE_GRAPH_HEIGHT = 240; static S32 FTV_NUM_TIMERS; const S32 FTV_MAX_DEPTH = 8; -std::vector ft_display_idx; // line of table entry for display purposes (for collapse) +std::vector ft_display_idx; // line of table entry for display purposes (for collapse) -typedef LLTreeDFSIter timer_tree_iterator_t; +typedef LLTreeDFSIter timer_tree_iterator_t; BOOL LLFastTimerView::sAnalyzePerformance = FALSE; -static timer_tree_iterator_t begin_timer_tree(LLFastTimer::NamedTimer& id) +static timer_tree_iterator_t begin_timer_tree(LLFastTimer::DeclareTimer& id) { return timer_tree_iterator_t(&id, - boost::bind(boost::mem_fn(&LLFastTimer::NamedTimer::beginChildren), _1), - boost::bind(boost::mem_fn(&LLFastTimer::NamedTimer::endChildren), _1)); + boost::bind(boost::mem_fn(&LLFastTimer::DeclareTimer::beginChildren), _1), + boost::bind(boost::mem_fn(&LLFastTimer::DeclareTimer::endChildren), _1)); } static timer_tree_iterator_t end_timer_tree() @@ -92,7 +92,7 @@ LLFastTimerView::LLFastTimerView(const LLSD& key) mScrollIndex = 0; mHoverID = NULL; mHoverBarIndex = -1; - FTV_NUM_TIMERS = LLFastTimer::NamedTimer::instanceCount(); + FTV_NUM_TIMERS = LLFastTimer::DeclareTimer::instanceCount(); mPrintStats = -1; } @@ -139,13 +139,13 @@ 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 = LLFastTimer::NamedTimer::HISTORY_NUM - mScrollIndex - bar_idx; + mPrintStats = LLFastTimer::DeclareTimer::HISTORY_NUM - mScrollIndex - bar_idx; return TRUE; } return LLFloater::handleRightMouseDown(x, y, mask); } -LLFastTimer::NamedTimer* LLFastTimerView::getLegendID(S32 y) +LLFastTimer::DeclareTimer* LLFastTimerView::getLegendID(S32 y) { S32 idx = (getRect().getHeight() - y) / (LLFontGL::getFontMonospace()->getLineHeight()+2) - 5; @@ -172,7 +172,7 @@ BOOL LLFastTimerView::handleMouseDown(S32 x, S32 y, MASK mask) { if (x < mBarRect.mLeft) { - LLFastTimer::NamedTimer* idp = getLegendID(y); + LLFastTimer::DeclareTimer* idp = getLegendID(y); if (idp) { idp->setCollapsed(!idp->getCollapsed()); @@ -235,7 +235,7 @@ BOOL LLFastTimerView::handleHover(S32 x, S32 y, MASK mask) if (hasMouseCapture()) { F32 lerp = llclamp(1.f - (F32) (x - mGraphRect.mLeft) / (F32) mGraphRect.getWidth(), 0.f, 1.f); - mScrollIndex = llround( lerp * (F32)(LLFastTimer::NamedTimer::HISTORY_NUM - MAX_VISIBLE_HISTORY)); + mScrollIndex = llround( lerp * (F32)(LLFastTimer::DeclareTimer::HISTORY_NUM - MAX_VISIBLE_HISTORY)); mScrollIndex = llclamp( mScrollIndex, 0, LLFastTimer::getLastFrameIndex()); return TRUE; } @@ -288,7 +288,7 @@ BOOL LLFastTimerView::handleHover(S32 x, S32 y, MASK mask) } else if (x < mBarRect.mLeft) { - LLFastTimer::NamedTimer* timer_id = getLegendID(y); + LLFastTimer::DeclareTimer* timer_id = getLegendID(y); if (timer_id) { mHoverID = timer_id; @@ -299,6 +299,23 @@ BOOL LLFastTimerView::handleHover(S32 x, S32 y, MASK mask) } +static std::string get_tooltip(LLFastTimer::DeclareTimer& timer, S32 history_index = -1) +{ + F64 ms_multiplier = 1000.0 / (F64)LLFastTimer::countsPerSecond(); + + std::string tooltip; + if (history_index < 0) + { + // by default, show average number of call + tooltip = llformat("%s (%d ms, %d calls)", timer.getName().c_str(), (S32)(timer.getCountAverage() * ms_multiplier), (S32)timer.getCallAverage()); + } + else + { + tooltip = llformat("%s (%d ms, %d calls)", timer.getName().c_str(), (S32)(timer.getHistoricalCount(history_index) * ms_multiplier), (S32)timer.getHistoricalCalls(history_index)); + } + return tooltip; +} + BOOL LLFastTimerView::handleToolTip(S32 x, S32 y, MASK mask) { if(LLFastTimer::sPauseHistory && mBarRect.pointInRect(x, y)) @@ -309,8 +326,10 @@ BOOL LLFastTimerView::handleToolTip(S32 x, S32 y, MASK mask) LLRect screen_rect; localRectToScreen(mToolTipRect, &screen_rect); + std::string tooltip = get_tooltip(*mHoverTimer, LLFastTimer::DeclareTimer::HISTORY_NUM - mScrollIndex - mHoverBarIndex); + LLToolTipMgr::instance().show(LLToolTip::Params() - .message(mHoverTimer->getToolTip(LLFastTimer::NamedTimer::HISTORY_NUM - mScrollIndex - mHoverBarIndex)) + .message(tooltip) .sticky_rect(screen_rect) .delay_time(0.f)); @@ -322,10 +341,10 @@ BOOL LLFastTimerView::handleToolTip(S32 x, S32 y, MASK mask) // tooltips for timer legend if (x < mBarRect.mLeft) { - LLFastTimer::NamedTimer* idp = getLegendID(y); + LLFastTimer::DeclareTimer* idp = getLegendID(y); if (idp) { - LLToolTipMgr::instance().show(idp->getToolTip()); + LLToolTipMgr::instance().show(get_tooltip(*idp)); return TRUE; } @@ -340,13 +359,13 @@ BOOL LLFastTimerView::handleScrollWheel(S32 x, S32 y, S32 clicks) LLFastTimer::sPauseHistory = TRUE; mScrollIndex = llclamp( mScrollIndex + clicks, 0, - llmin(LLFastTimer::getLastFrameIndex(), (S32)LLFastTimer::NamedTimer::HISTORY_NUM - MAX_VISIBLE_HISTORY)); + llmin(LLFastTimer::getLastFrameIndex(), (S32)LLFastTimer::DeclareTimer::HISTORY_NUM - MAX_VISIBLE_HISTORY)); return TRUE; } static LLFastTimer::DeclareTimer FTM_RENDER_TIMER("Timers", true); -static std::map sTimerColors; +static std::map sTimerColors; void LLFastTimerView::draw() { @@ -426,7 +445,7 @@ void LLFastTimerView::draw() it != timer_tree_iterator_t(); ++it) { - LLFastTimer::NamedTimer* idp = (*it); + LLFastTimer::DeclareTimer* idp = (*it); const F32 HUE_INCREMENT = 0.23f; hue = fmodf(hue + HUE_INCREMENT, 1.f); @@ -446,12 +465,12 @@ void LLFastTimerView::draw() LLLocalClipRect clip(LLRect(margin, y, LEGEND_WIDTH, margin)); S32 cur_line = 0; ft_display_idx.clear(); - std::map display_line; + std::map display_line; for (timer_tree_iterator_t it = begin_timer_tree(getFrameTimer()); it != timer_tree_iterator_t(); ++it) { - LLFastTimer::NamedTimer* idp = (*it); + LLFastTimer::DeclareTimer* idp = (*it); display_line[idp] = cur_line; ft_display_idx.push_back(idp); cur_line++; @@ -471,7 +490,7 @@ void LLFastTimerView::draw() S32 calls = 0; if (mHoverBarIndex > 0 && mHoverID) { - S32 hidx = LLFastTimer::NamedTimer::HISTORY_NUM - mScrollIndex - mHoverBarIndex; + S32 hidx = LLFastTimer::DeclareTimer::HISTORY_NUM - mScrollIndex - mHoverBarIndex; U64 ticks = idp->getHistoricalCount(hidx); ms = (F32)((F64)ticks * iclock_freq); calls = (S32)idp->getHistoricalCalls(hidx); @@ -509,7 +528,7 @@ void LLFastTimerView::draw() x += dx; BOOL is_child_of_hover_item = (idp == mHoverID); - LLFastTimer::NamedTimer* next_parent = idp->getParent(); + LLFastTimer::DeclareTimer* next_parent = idp->getParent(); while(!is_child_of_hover_item && next_parent) { is_child_of_hover_item = (mHoverID == next_parent); @@ -687,7 +706,7 @@ void LLFastTimerView::draw() S32 tidx; if (j >= 0) { - tidx = LLFastTimer::NamedTimer::HISTORY_NUM - j - 1 - mScrollIndex; + tidx = LLFastTimer::DeclareTimer::HISTORY_NUM - j - 1 - mScrollIndex; } else { @@ -701,14 +720,14 @@ void LLFastTimerView::draw() std::vector deltax; xpos.push_back(xleft); - LLFastTimer::NamedTimer* prev_id = NULL; + LLFastTimer::DeclareTimer* prev_id = NULL; S32 i = 0; for(timer_tree_iterator_t it = begin_timer_tree(getFrameTimer()); it != end_timer_tree(); ++it, ++i) { - LLFastTimer::NamedTimer* idp = (*it); + LLFastTimer::DeclareTimer* idp = (*it); F32 frac = tidx == -1 ? (F32)idp->getCountAverage() / (F32)totalticks : (F32)idp->getHistoricalCount(tidx) / (F32)totalticks; @@ -735,7 +754,7 @@ void LLFastTimerView::draw() { U64 sublevelticks = 0; - for (LLFastTimer::NamedTimer::child_const_iter it = prev_id->beginChildren(); + for (LLFastTimer::DeclareTimer::child_const_iter it = prev_id->beginChildren(); it != prev_id->endChildren(); ++it) { @@ -777,7 +796,7 @@ void LLFastTimerView::draw() S32 scale_offset = 0; BOOL is_child_of_hover_item = (idp == mHoverID); - LLFastTimer::NamedTimer* next_parent = idp->getParent(); + LLFastTimer::DeclareTimer* next_parent = idp->getParent(); while(!is_child_of_hover_item && next_parent) { is_child_of_hover_item = (mHoverID == next_parent); @@ -842,10 +861,10 @@ void LLFastTimerView::draw() //highlight visible range { - S32 first_frame = LLFastTimer::NamedTimer::HISTORY_NUM - mScrollIndex; + S32 first_frame = LLFastTimer::DeclareTimer::HISTORY_NUM - mScrollIndex; S32 last_frame = first_frame - MAX_VISIBLE_HISTORY; - F32 frame_delta = ((F32) (mGraphRect.getWidth()))/(LLFastTimer::NamedTimer::HISTORY_NUM-1); + F32 frame_delta = ((F32) (mGraphRect.getWidth()))/(LLFastTimer::DeclareTimer::HISTORY_NUM-1); F32 right = (F32) mGraphRect.mLeft + frame_delta*first_frame; F32 left = (F32) mGraphRect.mLeft + frame_delta*last_frame; @@ -872,7 +891,7 @@ void LLFastTimerView::draw() it != end_timer_tree(); ++it) { - LLFastTimer::NamedTimer* idp = (*it); + LLFastTimer::DeclareTimer* idp = (*it); //fatten highlighted timer if (mHoverID == idp) @@ -896,8 +915,8 @@ void LLFastTimerView::draw() gGL.color4f(col[0], col[1], col[2], alpha); gGL.begin(LLRender::TRIANGLE_STRIP); - for (U32 j = llmax(0, LLFastTimer::NamedTimer::HISTORY_NUM - LLFastTimer::getLastFrameIndex()); - j < LLFastTimer::NamedTimer::HISTORY_NUM; + for (U32 j = llmax(0, LLFastTimer::DeclareTimer::HISTORY_NUM - LLFastTimer::getLastFrameIndex()); + j < LLFastTimer::DeclareTimer::HISTORY_NUM; j++) { U64 ticks = idp->getHistoricalCount(j); @@ -918,7 +937,7 @@ void LLFastTimerView::draw() //normalize to highlighted timer cur_max = llmax(cur_max, ticks); } - F32 x = mGraphRect.mLeft + ((F32) (mGraphRect.getWidth()))/(LLFastTimer::NamedTimer::HISTORY_NUM-1)*j; + F32 x = mGraphRect.mLeft + ((F32) (mGraphRect.getWidth()))/(LLFastTimer::DeclareTimer::HISTORY_NUM-1)*j; F32 y = mGraphRect.mBottom + (F32) mGraphRect.getHeight()/max_ticks*ticks; gGL.vertex2f(x,y); gGL.vertex2f(x,mGraphRect.mBottom); @@ -973,7 +992,7 @@ void LLFastTimerView::draw() it != end_timer_tree(); ++it) { - LLFastTimer::NamedTimer* idp = (*it); + LLFastTimer::DeclareTimer* idp = (*it); if (!first) { @@ -995,7 +1014,7 @@ void LLFastTimerView::draw() it != end_timer_tree(); ++it) { - LLFastTimer::NamedTimer* idp = (*it); + LLFastTimer::DeclareTimer* idp = (*it); if (!first) { @@ -1033,11 +1052,8 @@ void LLFastTimerView::draw() F64 LLFastTimerView::getTime(const std::string& name) { - const LLFastTimer::NamedTimer* timerp = LLFastTimer::getTimerByName(name); - if (timerp) - { - return (F64)timerp->getCountAverage() / (F64)LLFastTimer::countsPerSecond(); - } + //TODO: replace calls to this with use of timer object directly + //llstatic_assert(false, "TODO: implement"); return 0.0; } @@ -1552,9 +1568,9 @@ void LLFastTimerView::onClickCloseBtn() setVisible(false); } -LLFastTimer::NamedTimer& LLFastTimerView::getFrameTimer() +LLFastTimer::DeclareTimer& LLFastTimerView::getFrameTimer() { - return FTM_FRAME.getNamedTimer(); + return FTM_FRAME; } -- cgit v1.2.3 From 9d77e030d9a0d23cebce616631677459eec1612c Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Wed, 14 Nov 2012 23:52:27 -0800 Subject: SH-3406 WIP convert fast timers to lltrace system cleaning up build moved most includes of windows.h to llwin32headers.h to disable min/max macros, etc streamlined Time class and consolidated functionality in BlockTimer class llfasttimer is no longer included via llstring.h, so had to add it manually in several places --- indra/newview/llfasttimerview.cpp | 117 ++++++++++++++++++-------------------- 1 file changed, 54 insertions(+), 63 deletions(-) (limited to 'indra/newview/llfasttimerview.cpp') diff --git a/indra/newview/llfasttimerview.cpp b/indra/newview/llfasttimerview.cpp index 0934028a8c..d0bb75225c 100644 --- a/indra/newview/llfasttimerview.cpp +++ b/indra/newview/llfasttimerview.cpp @@ -61,17 +61,17 @@ static const S32 LINE_GRAPH_HEIGHT = 240; static S32 FTV_NUM_TIMERS; const S32 FTV_MAX_DEPTH = 8; -std::vector ft_display_idx; // line of table entry for display purposes (for collapse) +std::vector ft_display_idx; // line of table entry for display purposes (for collapse) -typedef LLTreeDFSIter timer_tree_iterator_t; +typedef LLTreeDFSIter timer_tree_iterator_t; BOOL LLFastTimerView::sAnalyzePerformance = FALSE; -static timer_tree_iterator_t begin_timer_tree(LLFastTimer::DeclareTimer& id) +static timer_tree_iterator_t begin_timer_tree(LLTrace::BlockTimer& id) { return timer_tree_iterator_t(&id, - boost::bind(boost::mem_fn(&LLFastTimer::DeclareTimer::beginChildren), _1), - boost::bind(boost::mem_fn(&LLFastTimer::DeclareTimer::endChildren), _1)); + boost::bind(boost::mem_fn(&LLTrace::BlockTimer::beginChildren), _1), + boost::bind(boost::mem_fn(&LLTrace::BlockTimer::endChildren), _1)); } static timer_tree_iterator_t end_timer_tree() @@ -92,18 +92,18 @@ LLFastTimerView::LLFastTimerView(const LLSD& key) mScrollIndex = 0; mHoverID = NULL; mHoverBarIndex = -1; - FTV_NUM_TIMERS = LLFastTimer::DeclareTimer::instanceCount(); + FTV_NUM_TIMERS = LLTrace::BlockTimer::instanceCount(); mPrintStats = -1; } void LLFastTimerView::onPause() { - LLFastTimer::sPauseHistory = !LLFastTimer::sPauseHistory; + LLTrace::BlockTimer::sPauseHistory = !LLTrace::BlockTimer::sPauseHistory; // reset scroll to bottom when unpausing - if (!LLFastTimer::sPauseHistory) + if (!LLTrace::BlockTimer::sPauseHistory) { mScrollIndex = 0; - LLFastTimer::sResetHistory = true; + LLTrace::BlockTimer::sResetHistory = true; getChild("pause_btn")->setLabel(getString("pause")); } else @@ -139,13 +139,13 @@ 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 = LLFastTimer::DeclareTimer::HISTORY_NUM - mScrollIndex - bar_idx; + mPrintStats = LLTrace::BlockTimer::HISTORY_NUM - mScrollIndex - bar_idx; return TRUE; } return LLFloater::handleRightMouseDown(x, y, mask); } -LLFastTimer::DeclareTimer* LLFastTimerView::getLegendID(S32 y) +LLTrace::BlockTimer* LLFastTimerView::getLegendID(S32 y) { S32 idx = (getRect().getHeight() - y) / (LLFontGL::getFontMonospace()->getLineHeight()+2) - 5; @@ -172,7 +172,7 @@ BOOL LLFastTimerView::handleMouseDown(S32 x, S32 y, MASK mask) { if (x < mBarRect.mLeft) { - LLFastTimer::DeclareTimer* idp = getLegendID(y); + LLTrace::BlockTimer* idp = getLegendID(y); if (idp) { idp->setCollapsed(!idp->getCollapsed()); @@ -208,16 +208,7 @@ BOOL LLFastTimerView::handleMouseDown(S32 x, S32 y, MASK mask) gFocusMgr.setMouseCapture(this); return TRUE; } - //else - //{ - // // pause/unpause - // LLFastTimer::sPauseHistory = !LLFastTimer::sPauseHistory; - // // reset scroll to bottom when unpausing - // if (!LLFastTimer::sPauseHistory) - // { - // mScrollIndex = 0; - // } - //} + return LLFloater::handleMouseDown(x, y, mask); } @@ -235,14 +226,14 @@ BOOL LLFastTimerView::handleHover(S32 x, S32 y, MASK mask) if (hasMouseCapture()) { F32 lerp = llclamp(1.f - (F32) (x - mGraphRect.mLeft) / (F32) mGraphRect.getWidth(), 0.f, 1.f); - mScrollIndex = llround( lerp * (F32)(LLFastTimer::DeclareTimer::HISTORY_NUM - MAX_VISIBLE_HISTORY)); - mScrollIndex = llclamp( mScrollIndex, 0, LLFastTimer::getLastFrameIndex()); + mScrollIndex = llround( lerp * (F32)(LLTrace::BlockTimer::HISTORY_NUM - MAX_VISIBLE_HISTORY)); + mScrollIndex = llclamp( mScrollIndex, 0, LLTrace::BlockTimer::getLastFrameIndex()); return TRUE; } mHoverTimer = NULL; mHoverID = NULL; - if(LLFastTimer::sPauseHistory && mBarRect.pointInRect(x, y)) + if(LLTrace::BlockTimer::sPauseHistory && mBarRect.pointInRect(x, y)) { mHoverBarIndex = llmin(LLFastTimer::getCurFrameIndex() - 1, MAX_VISIBLE_HISTORY - ((y - mBarRect.mBottom) * (MAX_VISIBLE_HISTORY + 2) / mBarRect.getHeight())); @@ -288,7 +279,7 @@ BOOL LLFastTimerView::handleHover(S32 x, S32 y, MASK mask) } else if (x < mBarRect.mLeft) { - LLFastTimer::DeclareTimer* timer_id = getLegendID(y); + LLTrace::BlockTimer* timer_id = getLegendID(y); if (timer_id) { mHoverID = timer_id; @@ -299,7 +290,7 @@ BOOL LLFastTimerView::handleHover(S32 x, S32 y, MASK mask) } -static std::string get_tooltip(LLFastTimer::DeclareTimer& timer, S32 history_index = -1) +static std::string get_tooltip(LLTrace::BlockTimer& timer, S32 history_index = -1) { F64 ms_multiplier = 1000.0 / (F64)LLFastTimer::countsPerSecond(); @@ -318,7 +309,7 @@ static std::string get_tooltip(LLFastTimer::DeclareTimer& timer, S32 history_ind BOOL LLFastTimerView::handleToolTip(S32 x, S32 y, MASK mask) { - if(LLFastTimer::sPauseHistory && mBarRect.pointInRect(x, y)) + if(LLTrace::BlockTimer::sPauseHistory && mBarRect.pointInRect(x, y)) { // tooltips for timer bars if (mHoverTimer) @@ -326,7 +317,7 @@ BOOL LLFastTimerView::handleToolTip(S32 x, S32 y, MASK mask) LLRect screen_rect; localRectToScreen(mToolTipRect, &screen_rect); - std::string tooltip = get_tooltip(*mHoverTimer, LLFastTimer::DeclareTimer::HISTORY_NUM - mScrollIndex - mHoverBarIndex); + std::string tooltip = get_tooltip(*mHoverTimer, LLTrace::BlockTimer::HISTORY_NUM - mScrollIndex - mHoverBarIndex); LLToolTipMgr::instance().show(LLToolTip::Params() .message(tooltip) @@ -341,7 +332,7 @@ BOOL LLFastTimerView::handleToolTip(S32 x, S32 y, MASK mask) // tooltips for timer legend if (x < mBarRect.mLeft) { - LLFastTimer::DeclareTimer* idp = getLegendID(y); + LLTrace::BlockTimer* idp = getLegendID(y); if (idp) { LLToolTipMgr::instance().show(get_tooltip(*idp)); @@ -356,16 +347,16 @@ BOOL LLFastTimerView::handleToolTip(S32 x, S32 y, MASK mask) BOOL LLFastTimerView::handleScrollWheel(S32 x, S32 y, S32 clicks) { - LLFastTimer::sPauseHistory = TRUE; + LLTrace::BlockTimer::sPauseHistory = TRUE; mScrollIndex = llclamp( mScrollIndex + clicks, 0, - llmin(LLFastTimer::getLastFrameIndex(), (S32)LLFastTimer::DeclareTimer::HISTORY_NUM - MAX_VISIBLE_HISTORY)); + llmin(LLTrace::BlockTimer::getLastFrameIndex(), (S32)LLTrace::BlockTimer::HISTORY_NUM - MAX_VISIBLE_HISTORY)); return TRUE; } -static LLFastTimer::DeclareTimer FTM_RENDER_TIMER("Timers", true); +static LLTrace::BlockTimer FTM_RENDER_TIMER("Timers", true); -static std::map sTimerColors; +static std::map sTimerColors; void LLFastTimerView::draw() { @@ -429,7 +420,7 @@ void LLFastTimerView::draw() y -= (texth + 2); } - S32 histmax = llmin(LLFastTimer::getLastFrameIndex()+1, MAX_VISIBLE_HISTORY); + S32 histmax = llmin(LLTrace::BlockTimer::getLastFrameIndex()+1, MAX_VISIBLE_HISTORY); // Draw the legend xleft = margin; @@ -445,7 +436,7 @@ void LLFastTimerView::draw() it != timer_tree_iterator_t(); ++it) { - LLFastTimer::DeclareTimer* idp = (*it); + LLTrace::BlockTimer* idp = (*it); const F32 HUE_INCREMENT = 0.23f; hue = fmodf(hue + HUE_INCREMENT, 1.f); @@ -465,12 +456,12 @@ void LLFastTimerView::draw() LLLocalClipRect clip(LLRect(margin, y, LEGEND_WIDTH, margin)); S32 cur_line = 0; ft_display_idx.clear(); - std::map display_line; + std::map display_line; for (timer_tree_iterator_t it = begin_timer_tree(getFrameTimer()); it != timer_tree_iterator_t(); ++it) { - LLFastTimer::DeclareTimer* idp = (*it); + LLTrace::BlockTimer* idp = (*it); display_line[idp] = cur_line; ft_display_idx.push_back(idp); cur_line++; @@ -490,7 +481,7 @@ void LLFastTimerView::draw() S32 calls = 0; if (mHoverBarIndex > 0 && mHoverID) { - S32 hidx = LLFastTimer::DeclareTimer::HISTORY_NUM - mScrollIndex - mHoverBarIndex; + S32 hidx = LLTrace::BlockTimer::HISTORY_NUM - mScrollIndex - mHoverBarIndex; U64 ticks = idp->getHistoricalCount(hidx); ms = (F32)((F64)ticks * iclock_freq); calls = (S32)idp->getHistoricalCalls(hidx); @@ -528,7 +519,7 @@ void LLFastTimerView::draw() x += dx; BOOL is_child_of_hover_item = (idp == mHoverID); - LLFastTimer::DeclareTimer* next_parent = idp->getParent(); + LLTrace::BlockTimer* next_parent = idp->getParent(); while(!is_child_of_hover_item && next_parent) { is_child_of_hover_item = (mHoverID == next_parent); @@ -570,18 +561,18 @@ void LLFastTimerView::draw() barw = width - xleft - margin; // Draw the history bars - if (LLFastTimer::getLastFrameIndex() >= 0) + if (LLTrace::BlockTimer::getLastFrameIndex() >= 0) { LLLocalClipRect clip(LLRect(xleft, ytop, getRect().getWidth() - margin, margin)); U64 totalticks; - if (!LLFastTimer::sPauseHistory) + if (!LLTrace::BlockTimer::sPauseHistory) { U64 ticks = getFrameTimer().getHistoricalCount(mScrollIndex); - if (LLFastTimer::getCurFrameIndex() >= 10) + if (LLTrace::BlockTimer::getCurFrameIndex() >= 10) { - U64 framec = LLFastTimer::getCurFrameIndex(); + U64 framec = LLTrace::BlockTimer::getCurFrameIndex(); U64 avg = (U64)mAvgCountTotal; mAvgCountTotal = (avg*framec + ticks) / (framec + 1); if (ticks > mMaxCountTotal) @@ -592,14 +583,14 @@ void LLFastTimerView::draw() if (ticks < mAvgCountTotal/100 || ticks > mAvgCountTotal*100) { - LLFastTimer::sResetHistory = true; + LLTrace::BlockTimer::sResetHistory = true; } - if (LLFastTimer::getCurFrameIndex() < 10 || LLFastTimer::sResetHistory) + if (LLTrace::BlockTimer::getCurFrameIndex() < 10 || LLTrace::BlockTimer::sResetHistory) { mAvgCountTotal = ticks; mMaxCountTotal = ticks; - LLFastTimer::sResetHistory = false; + LLTrace::BlockTimer::sResetHistory = false; } } @@ -706,7 +697,7 @@ void LLFastTimerView::draw() S32 tidx; if (j >= 0) { - tidx = LLFastTimer::DeclareTimer::HISTORY_NUM - j - 1 - mScrollIndex; + tidx = LLTrace::BlockTimer::HISTORY_NUM - j - 1 - mScrollIndex; } else { @@ -720,14 +711,14 @@ void LLFastTimerView::draw() std::vector deltax; xpos.push_back(xleft); - LLFastTimer::DeclareTimer* prev_id = NULL; + LLTrace::BlockTimer* prev_id = NULL; S32 i = 0; for(timer_tree_iterator_t it = begin_timer_tree(getFrameTimer()); it != end_timer_tree(); ++it, ++i) { - LLFastTimer::DeclareTimer* idp = (*it); + LLTrace::BlockTimer* idp = (*it); F32 frac = tidx == -1 ? (F32)idp->getCountAverage() / (F32)totalticks : (F32)idp->getHistoricalCount(tidx) / (F32)totalticks; @@ -754,7 +745,7 @@ void LLFastTimerView::draw() { U64 sublevelticks = 0; - for (LLFastTimer::DeclareTimer::child_const_iter it = prev_id->beginChildren(); + for (LLTrace::BlockTimer::child_const_iter it = prev_id->beginChildren(); it != prev_id->endChildren(); ++it) { @@ -796,7 +787,7 @@ void LLFastTimerView::draw() S32 scale_offset = 0; BOOL is_child_of_hover_item = (idp == mHoverID); - LLFastTimer::DeclareTimer* next_parent = idp->getParent(); + LLTrace::BlockTimer* next_parent = idp->getParent(); while(!is_child_of_hover_item && next_parent) { is_child_of_hover_item = (mHoverID == next_parent); @@ -861,10 +852,10 @@ void LLFastTimerView::draw() //highlight visible range { - S32 first_frame = LLFastTimer::DeclareTimer::HISTORY_NUM - mScrollIndex; + S32 first_frame = LLTrace::BlockTimer::HISTORY_NUM - mScrollIndex; S32 last_frame = first_frame - MAX_VISIBLE_HISTORY; - F32 frame_delta = ((F32) (mGraphRect.getWidth()))/(LLFastTimer::DeclareTimer::HISTORY_NUM-1); + F32 frame_delta = ((F32) (mGraphRect.getWidth()))/(LLTrace::BlockTimer::HISTORY_NUM-1); F32 right = (F32) mGraphRect.mLeft + frame_delta*first_frame; F32 left = (F32) mGraphRect.mLeft + frame_delta*last_frame; @@ -891,7 +882,7 @@ void LLFastTimerView::draw() it != end_timer_tree(); ++it) { - LLFastTimer::DeclareTimer* idp = (*it); + LLTrace::BlockTimer* idp = (*it); //fatten highlighted timer if (mHoverID == idp) @@ -915,8 +906,8 @@ void LLFastTimerView::draw() gGL.color4f(col[0], col[1], col[2], alpha); gGL.begin(LLRender::TRIANGLE_STRIP); - for (U32 j = llmax(0, LLFastTimer::DeclareTimer::HISTORY_NUM - LLFastTimer::getLastFrameIndex()); - j < LLFastTimer::DeclareTimer::HISTORY_NUM; + for (U32 j = llmax(0, LLTrace::BlockTimer::HISTORY_NUM - LLTrace::BlockTimer::getLastFrameIndex()); + j < LLTrace::BlockTimer::HISTORY_NUM; j++) { U64 ticks = idp->getHistoricalCount(j); @@ -937,7 +928,7 @@ void LLFastTimerView::draw() //normalize to highlighted timer cur_max = llmax(cur_max, ticks); } - F32 x = mGraphRect.mLeft + ((F32) (mGraphRect.getWidth()))/(LLFastTimer::DeclareTimer::HISTORY_NUM-1)*j; + F32 x = mGraphRect.mLeft + ((F32) (mGraphRect.getWidth()))/(LLTrace::BlockTimer::HISTORY_NUM-1)*j; F32 y = mGraphRect.mBottom + (F32) mGraphRect.getHeight()/max_ticks*ticks; gGL.vertex2f(x,y); gGL.vertex2f(x,mGraphRect.mBottom); @@ -992,7 +983,7 @@ void LLFastTimerView::draw() it != end_timer_tree(); ++it) { - LLFastTimer::DeclareTimer* idp = (*it); + LLTrace::BlockTimer* idp = (*it); if (!first) { @@ -1014,7 +1005,7 @@ void LLFastTimerView::draw() it != end_timer_tree(); ++it) { - LLFastTimer::DeclareTimer* idp = (*it); + LLTrace::BlockTimer* idp = (*it); if (!first) { @@ -1551,13 +1542,13 @@ void LLFastTimerView::outputAllMetrics() //static void LLFastTimerView::doAnalysis(std::string baseline, std::string target, std::string output) { - if(LLFastTimer::sLog) + if(LLTrace::BlockTimer::sLog) { doAnalysisDefault(baseline, target, output) ; return ; } - if(LLFastTimer::sMetricLog) + if(LLTrace::BlockTimer::sMetricLog) { LLMetricPerformanceTesterBasic::doAnalysisMetrics(baseline, target, output) ; return ; @@ -1568,7 +1559,7 @@ void LLFastTimerView::onClickCloseBtn() setVisible(false); } -LLFastTimer::DeclareTimer& LLFastTimerView::getFrameTimer() +LLTrace::BlockTimer& LLFastTimerView::getFrameTimer() { return FTM_FRAME; } -- cgit v1.2.3 From c136b432140f892a56d4996d5ed77e903ff0b32d Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Thu, 15 Nov 2012 19:46:09 -0800 Subject: SH-3406 WIP convert fast timers to lltrace system eliminated min and max macros from windows.h got rest of viewer to compile against llfasttimer changes --- indra/newview/llfasttimerview.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'indra/newview/llfasttimerview.cpp') diff --git a/indra/newview/llfasttimerview.cpp b/indra/newview/llfasttimerview.cpp index d0bb75225c..7a5c9dba46 100644 --- a/indra/newview/llfasttimerview.cpp +++ b/indra/newview/llfasttimerview.cpp @@ -92,7 +92,7 @@ LLFastTimerView::LLFastTimerView(const LLSD& key) mScrollIndex = 0; mHoverID = NULL; mHoverBarIndex = -1; - FTV_NUM_TIMERS = LLTrace::BlockTimer::instanceCount(); + FTV_NUM_TIMERS = LLInstanceTracker::instanceCount(); mPrintStats = -1; } @@ -235,7 +235,7 @@ BOOL LLFastTimerView::handleHover(S32 x, S32 y, MASK mask) if(LLTrace::BlockTimer::sPauseHistory && mBarRect.pointInRect(x, y)) { - mHoverBarIndex = llmin(LLFastTimer::getCurFrameIndex() - 1, + mHoverBarIndex = llmin(LLTrace::BlockTimer::getCurFrameIndex() - 1, MAX_VISIBLE_HISTORY - ((y - mBarRect.mBottom) * (MAX_VISIBLE_HISTORY + 2) / mBarRect.getHeight())); if (mHoverBarIndex == 0) { @@ -292,7 +292,7 @@ BOOL LLFastTimerView::handleHover(S32 x, S32 y, MASK mask) static std::string get_tooltip(LLTrace::BlockTimer& timer, S32 history_index = -1) { - F64 ms_multiplier = 1000.0 / (F64)LLFastTimer::countsPerSecond(); + F64 ms_multiplier = 1000.0 / (F64)LLTrace::BlockTimer::countsPerSecond(); std::string tooltip; if (history_index < 0) @@ -364,7 +364,7 @@ void LLFastTimerView::draw() std::string tdesc; - F64 clock_freq = (F64)LLFastTimer::countsPerSecond(); + F64 clock_freq = (F64)LLTrace::BlockTimer::countsPerSecond(); F64 iclock_freq = 1000.0 / clock_freq; S32 margin = 10; -- cgit v1.2.3 From 13e4edf1cd664864afa585bc83bbe99d4f743326 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Sun, 2 Dec 2012 23:00:36 -0800 Subject: SH-3406 WIP convert fast timers to lltrace system started moving fast timer historical stats over to LLTrace periodic recording --- indra/newview/llfasttimerview.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'indra/newview/llfasttimerview.cpp') diff --git a/indra/newview/llfasttimerview.cpp b/indra/newview/llfasttimerview.cpp index 7a5c9dba46..6aca8f4426 100644 --- a/indra/newview/llfasttimerview.cpp +++ b/indra/newview/llfasttimerview.cpp @@ -294,15 +294,17 @@ static std::string get_tooltip(LLTrace::BlockTimer& timer, S32 history_index = - { F64 ms_multiplier = 1000.0 / (F64)LLTrace::BlockTimer::countsPerSecond(); + LLTrace::PeriodicRecording& frame_stats = LLTrace::get_frame_recording(); + std::string tooltip; if (history_index < 0) { // by default, show average number of call - tooltip = llformat("%s (%d ms, %d calls)", timer.getName().c_str(), (S32)(timer.getCountAverage() * ms_multiplier), (S32)timer.getCallAverage()); + tooltip = llformat("%s (%d ms, %d calls)", timer.getName().c_str(), (S32)(frame_stats.getPeriodMean(timer) * ms_multiplier), (S32)timer.getCallAverage()); } else { - tooltip = llformat("%s (%d ms, %d calls)", timer.getName().c_str(), (S32)(timer.getHistoricalCount(history_index) * ms_multiplier), (S32)timer.getHistoricalCalls(history_index)); + tooltip = llformat("%s (%d ms, %d calls)", timer.getName().c_str(), (S32)(frame_stats.getPrevRecordingPeriod(history_index).getSum(timer) * ms_multiplier), (S32)timer.getHistoricalCalls(history_index)); } return tooltip; } -- cgit v1.2.3 From 407e5013f3845208e0a60e26e8f0a7fad997df5d Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Mon, 3 Dec 2012 19:54:53 -0800 Subject: SH-3406 WIP convert fast timers to lltrace system converted fast timer view over to new lltrace mechanisms --- indra/newview/llfasttimerview.cpp | 778 ++++++++++++++++++-------------------- 1 file changed, 370 insertions(+), 408 deletions(-) (limited to 'indra/newview/llfasttimerview.cpp') diff --git a/indra/newview/llfasttimerview.cpp b/indra/newview/llfasttimerview.cpp index 6aca8f4426..acf3799f27 100644 --- a/indra/newview/llfasttimerview.cpp +++ b/indra/newview/llfasttimerview.cpp @@ -57,21 +57,19 @@ static const S32 MAX_VISIBLE_HISTORY = 10; static const S32 LINE_GRAPH_HEIGHT = 240; -//static const int FTV_DISPLAY_NUM = (sizeof(ft_display_table)/sizeof(ft_display_table[0])); -static S32 FTV_NUM_TIMERS; const S32 FTV_MAX_DEPTH = 8; -std::vector ft_display_idx; // line of table entry for display purposes (for collapse) +std::vector ft_display_idx; // line of table entry for display purposes (for collapse) -typedef LLTreeDFSIter timer_tree_iterator_t; +typedef LLTreeDFSIter timer_tree_iterator_t; BOOL LLFastTimerView::sAnalyzePerformance = FALSE; -static timer_tree_iterator_t begin_timer_tree(LLTrace::BlockTimer& id) +static timer_tree_iterator_t begin_timer_tree(LLTrace::TimeBlock& id) { return timer_tree_iterator_t(&id, - boost::bind(boost::mem_fn(&LLTrace::BlockTimer::beginChildren), _1), - boost::bind(boost::mem_fn(&LLTrace::BlockTimer::endChildren), _1)); + boost::bind(boost::mem_fn(&LLTrace::TimeBlock::beginChildren), _1), + boost::bind(boost::mem_fn(&LLTrace::TimeBlock::endChildren), _1)); } static timer_tree_iterator_t end_timer_tree() @@ -81,29 +79,25 @@ static timer_tree_iterator_t end_timer_tree() LLFastTimerView::LLFastTimerView(const LLSD& key) : LLFloater(key), - mHoverTimer(NULL) -{ - mDisplayMode = 0; - mAvgCountTotal = 0; - mMaxCountTotal = 0; - mDisplayCenter = ALIGN_CENTER; - mDisplayCalls = 0; - mDisplayHz = 0; - mScrollIndex = 0; - mHoverID = NULL; - mHoverBarIndex = -1; - FTV_NUM_TIMERS = LLInstanceTracker::instanceCount(); - mPrintStats = -1; -} + mHoverTimer(NULL), + mDisplayMode(0), + mDisplayCenter(ALIGN_CENTER), + mDisplayCalls(false), + mDisplayHz(false), + mScrollIndex(0), + mHoverID(NULL), + mHoverBarIndex(-1), + mPrintStats(-1) +{} void LLFastTimerView::onPause() { - LLTrace::BlockTimer::sPauseHistory = !LLTrace::BlockTimer::sPauseHistory; + LLTrace::TimeBlock::sPauseHistory = !LLTrace::TimeBlock::sPauseHistory; // reset scroll to bottom when unpausing - if (!LLTrace::BlockTimer::sPauseHistory) + if (!LLTrace::TimeBlock::sPauseHistory) { mScrollIndex = 0; - LLTrace::BlockTimer::sResetHistory = true; + LLTrace::TimeBlock::sResetHistory = true; getChild("pause_btn")->setLabel(getString("pause")); } else @@ -139,13 +133,13 @@ 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::BlockTimer::HISTORY_NUM - mScrollIndex - bar_idx; + mPrintStats = LLTrace::TimeBlock::HISTORY_NUM - mScrollIndex - bar_idx; return TRUE; } return LLFloater::handleRightMouseDown(x, y, mask); } -LLTrace::BlockTimer* LLFastTimerView::getLegendID(S32 y) +LLTrace::TimeBlock* LLFastTimerView::getLegendID(S32 y) { S32 idx = (getRect().getHeight() - y) / (LLFontGL::getFontMonospace()->getLineHeight()+2) - 5; @@ -172,7 +166,7 @@ BOOL LLFastTimerView::handleMouseDown(S32 x, S32 y, MASK mask) { if (x < mBarRect.mLeft) { - LLTrace::BlockTimer* idp = getLegendID(y); + LLTrace::TimeBlock* idp = getLegendID(y); if (idp) { idp->setCollapsed(!idp->getCollapsed()); @@ -223,19 +217,21 @@ 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(); + if (hasMouseCapture()) { F32 lerp = llclamp(1.f - (F32) (x - mGraphRect.mLeft) / (F32) mGraphRect.getWidth(), 0.f, 1.f); - mScrollIndex = llround( lerp * (F32)(LLTrace::BlockTimer::HISTORY_NUM - MAX_VISIBLE_HISTORY)); - mScrollIndex = llclamp( mScrollIndex, 0, LLTrace::BlockTimer::getLastFrameIndex()); + mScrollIndex = llround( lerp * (F32)(LLTrace::TimeBlock::HISTORY_NUM - MAX_VISIBLE_HISTORY)); + mScrollIndex = llclamp( mScrollIndex, 0, frame_recording.getNumPeriods()); return TRUE; } mHoverTimer = NULL; mHoverID = NULL; - if(LLTrace::BlockTimer::sPauseHistory && mBarRect.pointInRect(x, y)) + if(LLTrace::TimeBlock::sPauseHistory && mBarRect.pointInRect(x, y)) { - mHoverBarIndex = llmin(LLTrace::BlockTimer::getCurFrameIndex() - 1, + mHoverBarIndex = llmin(LLTrace::get_frame_recording().getNumPeriods() - 1, MAX_VISIBLE_HISTORY - ((y - mBarRect.mBottom) * (MAX_VISIBLE_HISTORY + 2) / mBarRect.getHeight())); if (mHoverBarIndex == 0) { @@ -279,7 +275,7 @@ BOOL LLFastTimerView::handleHover(S32 x, S32 y, MASK mask) } else if (x < mBarRect.mLeft) { - LLTrace::BlockTimer* timer_id = getLegendID(y); + LLTrace::TimeBlock* timer_id = getLegendID(y); if (timer_id) { mHoverID = timer_id; @@ -290,28 +286,28 @@ BOOL LLFastTimerView::handleHover(S32 x, S32 y, MASK mask) } -static std::string get_tooltip(LLTrace::BlockTimer& timer, S32 history_index = -1) +static std::string get_tooltip(LLTrace::TimeBlock& timer, S32 history_index = -1) { - F64 ms_multiplier = 1000.0 / (F64)LLTrace::BlockTimer::countsPerSecond(); + F64 ms_multiplier = 1000.0 / (F64)LLTrace::TimeBlock::countsPerSecond(); - LLTrace::PeriodicRecording& frame_stats = LLTrace::get_frame_recording(); + LLTrace::PeriodicRecording& frame_recording = LLTrace::get_frame_recording(); std::string tooltip; if (history_index < 0) { // by default, show average number of call - tooltip = llformat("%s (%d ms, %d calls)", timer.getName().c_str(), (S32)(frame_stats.getPeriodMean(timer) * ms_multiplier), (S32)timer.getCallAverage()); + tooltip = llformat("%s (%d ms, %d calls)", timer.getName().c_str(), (S32)(frame_recording.getPeriodMean(timer) * ms_multiplier), (S32)frame_recording.getPeriodMean(timer.callCount())); } else { - tooltip = llformat("%s (%d ms, %d calls)", timer.getName().c_str(), (S32)(frame_stats.getPrevRecordingPeriod(history_index).getSum(timer) * ms_multiplier), (S32)timer.getHistoricalCalls(history_index)); + tooltip = llformat("%s (%d ms, %d calls)", timer.getName().c_str(), (S32)(frame_recording.getPrevRecordingPeriod(history_index).getSum(timer) * ms_multiplier), (S32)frame_recording.getPrevRecordingPeriod(history_index).getSum(timer.callCount())); } return tooltip; } BOOL LLFastTimerView::handleToolTip(S32 x, S32 y, MASK mask) { - if(LLTrace::BlockTimer::sPauseHistory && mBarRect.pointInRect(x, y)) + if(LLTrace::TimeBlock::sPauseHistory && mBarRect.pointInRect(x, y)) { // tooltips for timer bars if (mHoverTimer) @@ -319,7 +315,7 @@ BOOL LLFastTimerView::handleToolTip(S32 x, S32 y, MASK mask) LLRect screen_rect; localRectToScreen(mToolTipRect, &screen_rect); - std::string tooltip = get_tooltip(*mHoverTimer, LLTrace::BlockTimer::HISTORY_NUM - mScrollIndex - mHoverBarIndex); + std::string tooltip = get_tooltip(*mHoverTimer, LLTrace::TimeBlock::HISTORY_NUM - mScrollIndex - mHoverBarIndex); LLToolTipMgr::instance().show(LLToolTip::Params() .message(tooltip) @@ -334,7 +330,7 @@ BOOL LLFastTimerView::handleToolTip(S32 x, S32 y, MASK mask) // tooltips for timer legend if (x < mBarRect.mLeft) { - LLTrace::BlockTimer* idp = getLegendID(y); + LLTrace::TimeBlock* idp = getLegendID(y); if (idp) { LLToolTipMgr::instance().show(get_tooltip(*idp)); @@ -349,26 +345,27 @@ BOOL LLFastTimerView::handleToolTip(S32 x, S32 y, MASK mask) BOOL LLFastTimerView::handleScrollWheel(S32 x, S32 y, S32 clicks) { - LLTrace::BlockTimer::sPauseHistory = TRUE; + LLTrace::PeriodicRecording& frame_recording = LLTrace::get_frame_recording(); + + LLTrace::TimeBlock::sPauseHistory = TRUE; mScrollIndex = llclamp( mScrollIndex + clicks, 0, - llmin(LLTrace::BlockTimer::getLastFrameIndex(), (S32)LLTrace::BlockTimer::HISTORY_NUM - MAX_VISIBLE_HISTORY)); + llmin(frame_recording.getNumPeriods(), (S32)LLTrace::TimeBlock::HISTORY_NUM - MAX_VISIBLE_HISTORY)); return TRUE; } -static LLTrace::BlockTimer FTM_RENDER_TIMER("Timers", true); +static LLTrace::TimeBlock FTM_RENDER_TIMER("Timers", true); -static std::map sTimerColors; +static std::map sTimerColors; void LLFastTimerView::draw() { LLFastTimer t(FTM_RENDER_TIMER); - + + LLTrace::PeriodicRecording& frame_recording = LLTrace::get_frame_recording(); + std::string tdesc; - F64 clock_freq = (F64)LLTrace::BlockTimer::countsPerSecond(); - F64 iclock_freq = 1000.0 / clock_freq; - S32 margin = 10; S32 height = getRect().getHeight(); S32 width = getRect().getWidth(); @@ -422,7 +419,7 @@ void LLFastTimerView::draw() y -= (texth + 2); } - S32 histmax = llmin(LLTrace::BlockTimer::getLastFrameIndex()+1, MAX_VISIBLE_HISTORY); + S32 histmax = llmin(frame_recording.getNumPeriods()+1, MAX_VISIBLE_HISTORY); // Draw the legend xleft = margin; @@ -438,7 +435,7 @@ void LLFastTimerView::draw() it != timer_tree_iterator_t(); ++it) { - LLTrace::BlockTimer* idp = (*it); + LLTrace::TimeBlock* idp = (*it); const F32 HUE_INCREMENT = 0.23f; hue = fmodf(hue + HUE_INCREMENT, 1.f); @@ -458,12 +455,12 @@ void LLFastTimerView::draw() LLLocalClipRect clip(LLRect(margin, y, LEGEND_WIDTH, margin)); S32 cur_line = 0; ft_display_idx.clear(); - std::map display_line; + std::map display_line; for (timer_tree_iterator_t it = begin_timer_tree(getFrameTimer()); it != timer_tree_iterator_t(); ++it) { - LLTrace::BlockTimer* idp = (*it); + LLTrace::TimeBlock* idp = (*it); display_line[idp] = cur_line; ft_display_idx.push_back(idp); cur_line++; @@ -479,20 +476,18 @@ void LLFastTimerView::draw() } gl_rect_2d(left - scale_offset, top + scale_offset, right + scale_offset, bottom - scale_offset, sTimerColors[idp]); - F32 ms = 0; + LLUnit ms = 0; S32 calls = 0; if (mHoverBarIndex > 0 && mHoverID) { - S32 hidx = LLTrace::BlockTimer::HISTORY_NUM - mScrollIndex - mHoverBarIndex; - U64 ticks = idp->getHistoricalCount(hidx); - ms = (F32)((F64)ticks * iclock_freq); - calls = (S32)idp->getHistoricalCalls(hidx); + S32 hidx = LLTrace::TimeBlock::HISTORY_NUM - mScrollIndex - mHoverBarIndex; + ms = frame_recording.getPrevRecordingPeriod(hidx).getSum(*idp); + calls = frame_recording.getPrevRecordingPeriod(hidx).getSum(idp->callCount()); } else { - U64 ticks = idp->getCountAverage(); - ms = (F32)((F64)ticks * iclock_freq); - calls = (S32)idp->getCallAverage(); + ms = frame_recording.getPeriodMean(*idp); + calls = frame_recording.getPeriodMean(idp->callCount()); } if (mDisplayCalls) @@ -521,7 +516,7 @@ void LLFastTimerView::draw() x += dx; BOOL is_child_of_hover_item = (idp == mHoverID); - LLTrace::BlockTimer* next_parent = idp->getParent(); + LLTrace::TimeBlock* next_parent = idp->getParent(); while(!is_child_of_hover_item && next_parent) { is_child_of_hover_item = (mHoverID == next_parent); @@ -563,419 +558,386 @@ void LLFastTimerView::draw() barw = width - xleft - margin; // Draw the history bars - if (LLTrace::BlockTimer::getLastFrameIndex() >= 0) - { - LLLocalClipRect clip(LLRect(xleft, ytop, getRect().getWidth() - margin, margin)); - - U64 totalticks; - if (!LLTrace::BlockTimer::sPauseHistory) - { - U64 ticks = getFrameTimer().getHistoricalCount(mScrollIndex); - - if (LLTrace::BlockTimer::getCurFrameIndex() >= 10) - { - U64 framec = LLTrace::BlockTimer::getCurFrameIndex(); - U64 avg = (U64)mAvgCountTotal; - mAvgCountTotal = (avg*framec + ticks) / (framec + 1); - if (ticks > mMaxCountTotal) - { - mMaxCountTotal = ticks; - } - } - - if (ticks < mAvgCountTotal/100 || ticks > mAvgCountTotal*100) - { - LLTrace::BlockTimer::sResetHistory = true; - } + LLLocalClipRect clip(LLRect(xleft, ytop, getRect().getWidth() - margin, margin)); - if (LLTrace::BlockTimer::getCurFrameIndex() < 10 || LLTrace::BlockTimer::sResetHistory) - { - mAvgCountTotal = ticks; - mMaxCountTotal = ticks; - LLTrace::BlockTimer::sResetHistory = false; - } - } + LLUnit total_time; - if (mDisplayMode == 0) - { - totalticks = mAvgCountTotal*2; - } - else if (mDisplayMode == 1) - { - totalticks = mMaxCountTotal; - } - else if (mDisplayMode == 2) - { - // Calculate the max total ticks for the current history - totalticks = 0; - for (S32 j=0; j totalticks) - totalticks = ticks; - } - } - else - { - totalticks = (U64)(clock_freq * .1); // 100 ms - } + if (mDisplayMode == 0) + { + total_time = frame_recording.getPeriodMean(getFrameTimer())*2; + } + else if (mDisplayMode == 1) + { + total_time = mAllTimeMax; + } + else if (mDisplayMode == 2) + { + // Calculate the max total ticks for the current history + total_time = frame_recording.getPeriodMax(getFrameTimer()); + } + else + { + total_time = LLUnit(100); + } - // Draw MS ticks - { - U32 ms = (U32)((F64)totalticks * iclock_freq) ; + // Draw MS ticks + { + LLUnit ms = total_time; - tdesc = llformat("%.1f ms |", (F32)ms*.25f); - x = xleft + barw/4 - LLFontGL::getFontMonospace()->getWidth(tdesc); - LLFontGL::getFontMonospace()->renderUTF8(tdesc, 0, x, y, LLColor4::white, - LLFontGL::LEFT, LLFontGL::TOP); + tdesc = llformat("%.1f ms |", (F32)ms*.25f); + x = xleft + barw/4 - LLFontGL::getFontMonospace()->getWidth(tdesc); + LLFontGL::getFontMonospace()->renderUTF8(tdesc, 0, x, y, LLColor4::white, + LLFontGL::LEFT, LLFontGL::TOP); - tdesc = llformat("%.1f ms |", (F32)ms*.50f); - x = xleft + barw/2 - LLFontGL::getFontMonospace()->getWidth(tdesc); - LLFontGL::getFontMonospace()->renderUTF8(tdesc, 0, x, y, LLColor4::white, - LLFontGL::LEFT, LLFontGL::TOP); + tdesc = llformat("%.1f ms |", (F32)ms*.50f); + x = xleft + barw/2 - LLFontGL::getFontMonospace()->getWidth(tdesc); + LLFontGL::getFontMonospace()->renderUTF8(tdesc, 0, x, y, LLColor4::white, + LLFontGL::LEFT, LLFontGL::TOP); - tdesc = llformat("%.1f ms |", (F32)ms*.75f); - x = xleft + (barw*3)/4 - LLFontGL::getFontMonospace()->getWidth(tdesc); - LLFontGL::getFontMonospace()->renderUTF8(tdesc, 0, x, y, LLColor4::white, - LLFontGL::LEFT, LLFontGL::TOP); + tdesc = llformat("%.1f ms |", (F32)ms*.75f); + x = xleft + (barw*3)/4 - LLFontGL::getFontMonospace()->getWidth(tdesc); + LLFontGL::getFontMonospace()->renderUTF8(tdesc, 0, x, y, LLColor4::white, + LLFontGL::LEFT, LLFontGL::TOP); - tdesc = llformat( "%d ms |", ms); - x = xleft + barw - LLFontGL::getFontMonospace()->getWidth(tdesc); - LLFontGL::getFontMonospace()->renderUTF8(tdesc, 0, x, y, LLColor4::white, - LLFontGL::LEFT, LLFontGL::TOP); - } + tdesc = llformat( "%d ms |", (U32)ms); + x = xleft + barw - LLFontGL::getFontMonospace()->getWidth(tdesc); + LLFontGL::getFontMonospace()->renderUTF8(tdesc, 0, x, y, LLColor4::white, + LLFontGL::LEFT, LLFontGL::TOP); + } - // Draw borders - { - gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); - gGL.color4f(0.5f,0.5f,0.5f,0.5f); + // Draw borders + { + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); + gGL.color4f(0.5f,0.5f,0.5f,0.5f); - S32 by = y + 2; + S32 by = y + 2; - y -= ((S32)LLFontGL::getFontMonospace()->getLineHeight() + 4); + y -= ((S32)LLFontGL::getFontMonospace()->getLineHeight() + 4); - //heading - gl_rect_2d(xleft-5, by, getRect().getWidth()-5, y+5, FALSE); + //heading + gl_rect_2d(xleft-5, by, getRect().getWidth()-5, y+5, FALSE); - //tree view - gl_rect_2d(5, by, xleft-10, 5, FALSE); + //tree view + gl_rect_2d(5, by, xleft-10, 5, FALSE); - by = y + 5; - //average bar - gl_rect_2d(xleft-5, by, getRect().getWidth()-5, by-barh-dy-5, FALSE); + by = y + 5; + //average bar + gl_rect_2d(xleft-5, by, getRect().getWidth()-5, by-barh-dy-5, FALSE); - by -= barh*2+dy; + by -= barh*2+dy; - //current frame bar - gl_rect_2d(xleft-5, by, getRect().getWidth()-5, by-barh-dy-2, FALSE); + //current frame bar + gl_rect_2d(xleft-5, by, getRect().getWidth()-5, by-barh-dy-2, FALSE); - by -= barh+dy+1; + by -= barh+dy+1; - //history bars - gl_rect_2d(xleft-5, by, getRect().getWidth()-5, LINE_GRAPH_HEIGHT-barh-dy-2, FALSE); + //history bars + gl_rect_2d(xleft-5, by, getRect().getWidth()-5, LINE_GRAPH_HEIGHT-barh-dy-2, FALSE); - by = LINE_GRAPH_HEIGHT-barh-dy-7; + by = LINE_GRAPH_HEIGHT-barh-dy-7; - //line graph - mGraphRect = LLRect(xleft-5, by, getRect().getWidth()-5, 5); + //line graph + mGraphRect = LLRect(xleft-5, by, getRect().getWidth()-5, 5); - gl_rect_2d(mGraphRect, FALSE); - } + gl_rect_2d(mGraphRect, FALSE); + } - mBarStart.clear(); - mBarEnd.clear(); + mBarStart.clear(); + mBarEnd.clear(); - // Draw bars for each history entry - // Special: -1 = show running average - gGL.getTexUnit(0)->bind(box_imagep->getImage()); - for (S32 j=-1; j LINE_GRAPH_HEIGHT; j++) + // Draw bars for each history entry + // Special: -1 = show running average + gGL.getTexUnit(0)->bind(box_imagep->getImage()); + for (S32 j=-1; j LINE_GRAPH_HEIGHT; j++) + { + mBarStart.push_back(std::vector()); + mBarEnd.push_back(std::vector()); + int sublevel_dx[FTV_MAX_DEPTH]; + int sublevel_left[FTV_MAX_DEPTH]; + int sublevel_right[FTV_MAX_DEPTH]; + S32 tidx; + if (j >= 0) { - mBarStart.push_back(std::vector()); - mBarEnd.push_back(std::vector()); - int sublevel_dx[FTV_MAX_DEPTH]; - int sublevel_left[FTV_MAX_DEPTH]; - int sublevel_right[FTV_MAX_DEPTH]; - S32 tidx; - if (j >= 0) - { - tidx = LLTrace::BlockTimer::HISTORY_NUM - j - 1 - mScrollIndex; - } - else - { - tidx = -1; - } + tidx = LLTrace::TimeBlock::HISTORY_NUM - j - 1 - mScrollIndex; + } + else + { + tidx = -1; + } - x = xleft; + x = xleft; - // draw the bars for each stat - std::vector xpos; - std::vector deltax; - xpos.push_back(xleft); + // draw the bars for each stat + std::vector xpos; + std::vector deltax; + xpos.push_back(xleft); - LLTrace::BlockTimer* prev_id = NULL; + LLTrace::TimeBlock* prev_id = NULL; - S32 i = 0; - for(timer_tree_iterator_t it = begin_timer_tree(getFrameTimer()); - it != end_timer_tree(); - ++it, ++i) - { - LLTrace::BlockTimer* idp = (*it); - F32 frac = tidx == -1 - ? (F32)idp->getCountAverage() / (F32)totalticks - : (F32)idp->getHistoricalCount(tidx) / (F32)totalticks; + S32 i = 0; + for(timer_tree_iterator_t it = begin_timer_tree(getFrameTimer()); + it != end_timer_tree(); + ++it, ++i) + { + LLTrace::TimeBlock* idp = (*it); + F32 frac = tidx == -1 + ? (frame_recording.getPeriodMean(*idp) / total_time) + : (frame_recording.getPrevRecordingPeriod(tidx).getSum(*idp).value() / total_time.value()); - dx = llround(frac * (F32)barw); - S32 prev_delta_x = deltax.empty() ? 0 : deltax.back(); - deltax.push_back(dx); + dx = llround(frac * (F32)barw); + S32 prev_delta_x = deltax.empty() ? 0 : deltax.back(); + deltax.push_back(dx); + + int level = idp->getDepth() - 1; - int level = idp->getDepth() - 1; + while ((S32)xpos.size() > level + 1) + { + xpos.pop_back(); + } + left = xpos.back(); - while ((S32)xpos.size() > level + 1) + if (level == 0) + { + sublevel_left[level] = xleft; + sublevel_dx[level] = dx; + sublevel_right[level] = sublevel_left[level] + sublevel_dx[level]; + } + else if (prev_id && prev_id->getDepth() < idp->getDepth()) + { + U64 sublevelticks = 0; + + for (LLTrace::TimeBlock::child_const_iter it = prev_id->beginChildren(); + it != prev_id->endChildren(); + ++it) { - xpos.pop_back(); + sublevelticks += (tidx == -1) + ? frame_recording.getPeriodMean(**it) + : frame_recording.getPrevRecordingPeriod(tidx).getSum(**it); } - left = xpos.back(); - - if (level == 0) + + F32 subfrac = (F32)sublevelticks / (F32)total_time; + sublevel_dx[level] = (int)(subfrac * (F32)barw + .5f); + + if (mDisplayCenter == ALIGN_CENTER) { - sublevel_left[level] = xleft; - sublevel_dx[level] = dx; - sublevel_right[level] = sublevel_left[level] + sublevel_dx[level]; + left += (prev_delta_x - sublevel_dx[level])/2; } - else if (prev_id && prev_id->getDepth() < idp->getDepth()) + else if (mDisplayCenter == ALIGN_RIGHT) { - U64 sublevelticks = 0; - - for (LLTrace::BlockTimer::child_const_iter it = prev_id->beginChildren(); - it != prev_id->endChildren(); - ++it) - { - sublevelticks += (tidx == -1) - ? (*it)->getCountAverage() - : (*it)->getHistoricalCount(tidx); - } - - F32 subfrac = (F32)sublevelticks / (F32)totalticks; - sublevel_dx[level] = (int)(subfrac * (F32)barw + .5f); - - if (mDisplayCenter == ALIGN_CENTER) - { - left += (prev_delta_x - sublevel_dx[level])/2; - } - else if (mDisplayCenter == ALIGN_RIGHT) - { - left += (prev_delta_x - sublevel_dx[level]); - } - - sublevel_left[level] = left; - sublevel_right[level] = sublevel_left[level] + sublevel_dx[level]; - } - - right = left + dx; - xpos.back() = right; - xpos.push_back(left); + left += (prev_delta_x - sublevel_dx[level]); + } + + sublevel_left[level] = left; + sublevel_right[level] = sublevel_left[level] + sublevel_dx[level]; + } + + right = left + dx; + xpos.back() = right; + xpos.push_back(left); - mBarStart.back().push_back(left); - mBarEnd.back().push_back(right); + mBarStart.back().push_back(left); + mBarEnd.back().push_back(right); - top = y; - bottom = y - barh; + top = y; + bottom = y - barh; - if (right > left) - { - //U32 rounded_edges = 0; - LLColor4 color = sTimerColors[idp];//*ft_display_table[i].color; - S32 scale_offset = 0; - - BOOL is_child_of_hover_item = (idp == mHoverID); - LLTrace::BlockTimer* next_parent = idp->getParent(); - while(!is_child_of_hover_item && next_parent) - { - is_child_of_hover_item = (mHoverID == next_parent); - if (next_parent->getParent() == next_parent) break; - next_parent = next_parent->getParent(); - } - - if (idp == mHoverID) - { - scale_offset = llfloor(sinf(mHighlightTimer.getElapsedTimeF32() * 6.f) * 3.f); - //color = lerp(color, LLColor4::black, -0.4f); - } - else if (mHoverID != NULL && !is_child_of_hover_item) - { - color = lerp(color, LLColor4::grey, 0.8f); - } - - gGL.color4fv(color.mV); - F32 start_fragment = llclamp((F32)(left - sublevel_left[level]) / (F32)sublevel_dx[level], 0.f, 1.f); - F32 end_fragment = llclamp((F32)(right - sublevel_left[level]) / (F32)sublevel_dx[level], 0.f, 1.f); - gl_segmented_rect_2d_fragment_tex(sublevel_left[level], top - level + scale_offset, sublevel_right[level], bottom + level - scale_offset, box_imagep->getTextureWidth(), box_imagep->getTextureHeight(), 16, start_fragment, end_fragment); + if (right > left) + { + //U32 rounded_edges = 0; + LLColor4 color = sTimerColors[idp];//*ft_display_table[i].color; + S32 scale_offset = 0; + BOOL is_child_of_hover_item = (idp == mHoverID); + LLTrace::TimeBlock* next_parent = idp->getParent(); + while(!is_child_of_hover_item && next_parent) + { + is_child_of_hover_item = (mHoverID == next_parent); + if (next_parent->getParent() == next_parent) break; + next_parent = next_parent->getParent(); } - if ((*it)->getCollapsed()) + if (idp == mHoverID) { - it.skipDescendants(); + scale_offset = llfloor(sinf(mHighlightTimer.getElapsedTimeF32() * 6.f) * 3.f); + //color = lerp(color, LLColor4::black, -0.4f); } - - prev_id = idp; + else if (mHoverID != NULL && !is_child_of_hover_item) + { + color = lerp(color, LLColor4::grey, 0.8f); + } + + gGL.color4fv(color.mV); + F32 start_fragment = llclamp((F32)(left - sublevel_left[level]) / (F32)sublevel_dx[level], 0.f, 1.f); + F32 end_fragment = llclamp((F32)(right - sublevel_left[level]) / (F32)sublevel_dx[level], 0.f, 1.f); + gl_segmented_rect_2d_fragment_tex(sublevel_left[level], top - level + scale_offset, sublevel_right[level], bottom + level - scale_offset, box_imagep->getTextureWidth(), box_imagep->getTextureHeight(), 16, start_fragment, end_fragment); + } - y -= (barh + dy); - if (j < 0) - y -= barh; + + if ((*it)->getCollapsed()) + { + it.skipDescendants(); + } + + prev_id = idp; } + y -= (barh + dy); + if (j < 0) + y -= barh; + } - //draw line graph history - { - gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); - LLLocalClipRect clip(mGraphRect); + //draw line graph history + { + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); + LLLocalClipRect clip(mGraphRect); - //normalize based on last frame's maximum - static U64 last_max = 0; - static F32 alpha_interp = 0.f; - U64 max_ticks = llmax(last_max, (U64) 1); - F32 ms = (F32)((F64)max_ticks * iclock_freq); + //normalize based on last frame's maximum + static LLUnit max_time = 0.000001; + static U32 max_calls = 0; + static F32 alpha_interp = 0.f; - //display y-axis range - std::string tdesc; - if (mDisplayCalls) - tdesc = llformat("%d calls", (int)max_ticks); - else if (mDisplayHz) - tdesc = llformat("%d Hz", (int)max_ticks); - else - tdesc = llformat("%4.2f ms", ms); + //display y-axis range + std::string tdesc; + if (mDisplayCalls) + tdesc = llformat("%d calls", (int)max_calls); + else if (mDisplayHz) + tdesc = llformat("%d Hz", (int)(1.f / max_time.value())); + else + tdesc = llformat("%4.2f ms", LLUnit(max_time).value()); - x = mGraphRect.mRight - LLFontGL::getFontMonospace()->getWidth(tdesc)-5; - y = mGraphRect.mTop - LLFontGL::getFontMonospace()->getLineHeight(); + x = mGraphRect.mRight - LLFontGL::getFontMonospace()->getWidth(tdesc)-5; + y = mGraphRect.mTop - LLFontGL::getFontMonospace()->getLineHeight(); - LLFontGL::getFontMonospace()->renderUTF8(tdesc, 0, x, y, LLColor4::white, - LLFontGL::LEFT, LLFontGL::TOP); + LLFontGL::getFontMonospace()->renderUTF8(tdesc, 0, x, y, LLColor4::white, + LLFontGL::LEFT, LLFontGL::TOP); - //highlight visible range - { - S32 first_frame = LLTrace::BlockTimer::HISTORY_NUM - mScrollIndex; - S32 last_frame = first_frame - MAX_VISIBLE_HISTORY; + //highlight visible range + { + S32 first_frame = LLTrace::TimeBlock::HISTORY_NUM - mScrollIndex; + S32 last_frame = first_frame - MAX_VISIBLE_HISTORY; - F32 frame_delta = ((F32) (mGraphRect.getWidth()))/(LLTrace::BlockTimer::HISTORY_NUM-1); + F32 frame_delta = ((F32) (mGraphRect.getWidth()))/(LLTrace::TimeBlock::HISTORY_NUM-1); - F32 right = (F32) mGraphRect.mLeft + frame_delta*first_frame; - F32 left = (F32) mGraphRect.mLeft + frame_delta*last_frame; + F32 right = (F32) mGraphRect.mLeft + frame_delta*first_frame; + F32 left = (F32) mGraphRect.mLeft + frame_delta*last_frame; - gGL.color4f(0.5f,0.5f,0.5f,0.3f); - gl_rect_2d((S32) left, mGraphRect.mTop, (S32) right, mGraphRect.mBottom); + gGL.color4f(0.5f,0.5f,0.5f,0.3f); + gl_rect_2d((S32) left, mGraphRect.mTop, (S32) right, mGraphRect.mBottom); - if (mHoverBarIndex >= 0) - { - S32 bar_frame = first_frame - mHoverBarIndex; - F32 bar = (F32) mGraphRect.mLeft + frame_delta*bar_frame; + if (mHoverBarIndex >= 0) + { + S32 bar_frame = first_frame - mHoverBarIndex; + F32 bar = (F32) mGraphRect.mLeft + frame_delta*bar_frame; - gGL.color4f(0.5f,0.5f,0.5f,1); + gGL.color4f(0.5f,0.5f,0.5f,1); - gGL.begin(LLRender::LINES); - gGL.vertex2i((S32)bar, mGraphRect.mBottom); - gGL.vertex2i((S32)bar, mGraphRect.mTop); - gGL.end(); - } + gGL.begin(LLRender::LINES); + gGL.vertex2i((S32)bar, mGraphRect.mBottom); + gGL.vertex2i((S32)bar, mGraphRect.mTop); + gGL.end(); } + } - U64 cur_max = 0; - for(timer_tree_iterator_t it = begin_timer_tree(getFrameTimer()); - it != end_timer_tree(); - ++it) - { - LLTrace::BlockTimer* idp = (*it); + LLUnit cur_max = 0; + U32 cur_max_calls = 0; + for(timer_tree_iterator_t it = begin_timer_tree(getFrameTimer()); + it != end_timer_tree(); + ++it) + { + LLTrace::TimeBlock* idp = (*it); - //fatten highlighted timer - if (mHoverID == idp) - { - gGL.flush(); - glLineWidth(3); - } + //fatten highlighted timer + if (mHoverID == idp) + { + gGL.flush(); + glLineWidth(3); + } - const F32 * col = sTimerColors[idp].mV;// ft_display_table[idx].color->mV; + const F32 * col = sTimerColors[idp].mV;// ft_display_table[idx].color->mV; - F32 alpha = 1.f; + F32 alpha = 1.f; - if (mHoverID != NULL && - idp != mHoverID) - { //fade out non-highlighted timers - if (idp->getParent() != mHoverID) - { - alpha = alpha_interp; - } - } - - gGL.color4f(col[0], col[1], col[2], alpha); - gGL.begin(LLRender::TRIANGLE_STRIP); - for (U32 j = llmax(0, LLTrace::BlockTimer::HISTORY_NUM - LLTrace::BlockTimer::getLastFrameIndex()); - j < LLTrace::BlockTimer::HISTORY_NUM; - j++) + if (mHoverID != NULL && + idp != mHoverID) + { //fade out non-highlighted timers + if (idp->getParent() != mHoverID) { - U64 ticks = idp->getHistoricalCount(j); - - if (mDisplayHz) - { - F64 tc = (F64) (ticks+1) * iclock_freq; - tc = 1000.f/tc; - ticks = llmin((U64) tc, (U64) 1024); - } - else if (mDisplayCalls) - { - ticks = (S32)idp->getHistoricalCalls(j); - } - - if (alpha == 1.f) - { - //normalize to highlighted timer - cur_max = llmax(cur_max, ticks); - } - F32 x = mGraphRect.mLeft + ((F32) (mGraphRect.getWidth()))/(LLTrace::BlockTimer::HISTORY_NUM-1)*j; - F32 y = mGraphRect.mBottom + (F32) mGraphRect.getHeight()/max_ticks*ticks; - gGL.vertex2f(x,y); - gGL.vertex2f(x,mGraphRect.mBottom); - } - gGL.end(); - - if (mHoverID == idp) - { - gGL.flush(); - glLineWidth(1); + alpha = alpha_interp; } + } - if (idp->getCollapsed()) - { - //skip hidden timers - it.skipDescendants(); + 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++) + { + LLUnit time = llmax(frame_recording.getPrevRecordingPeriod(j).getSum(*idp), LLUnit(0.000001)); + U32 calls = frame_recording.getPrevRecordingPeriod(j).getSum(idp->callCount()); + + if (alpha == 1.f) + { + //normalize to highlighted timer + 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 y = mDisplayHz + ? mGraphRect.mBottom + (1.f / time.value()) * ((F32) mGraphRect.getHeight() / (1.f / max_time.value())) + : mGraphRect.mBottom + time * ((F32)mGraphRect.getHeight() / max_time); + gGL.vertex2f(x,y); + gGL.vertex2f(x,mGraphRect.mBottom); } - - //interpolate towards new maximum - last_max = (U64) lerp((F32)last_max, (F32) cur_max, LLCriticalDamp::getInterpolant(0.1f)); - if (last_max - cur_max <= 1 || cur_max - last_max <= 1) + gGL.end(); + + if (mHoverID == idp) { - last_max = cur_max; + gGL.flush(); + glLineWidth(1); } - F32 alpha_target = last_max > cur_max ? - llmin((F32) last_max/ (F32) cur_max - 1.f,1.f) : - llmin((F32) cur_max/ (F32) last_max - 1.f,1.f); - alpha_interp = lerp(alpha_interp, alpha_target, LLCriticalDamp::getInterpolant(0.1f)); - if (mHoverID != NULL) - { - x = (mGraphRect.mRight + mGraphRect.mLeft)/2; - y = mGraphRect.mBottom + 8; - - LLFontGL::getFontMonospace()->renderUTF8( - mHoverID->getName(), - 0, - x, y, - LLColor4::white, - LLFontGL::LEFT, LLFontGL::BOTTOM); - } + if (idp->getCollapsed()) + { + //skip hidden timers + it.skipDescendants(); + } + } + + //interpolate towards new maximum + max_time = lerp((F32)max_time, (F32) cur_max, LLCriticalDamp::getInterpolant(0.1f)); + if (max_time - cur_max <= 1 || cur_max - max_time <= 1) + { + max_time = llmax(LLUnit(1), LLUnit(cur_max)); + } + + max_calls = lerp((F32)max_calls, (F32) cur_max_calls, LLCriticalDamp::getInterpolant(0.1f)); + if (llabs(max_calls - cur_max) <= 1) + { + max_calls = cur_max_calls; } + + // TODO: make sure alpha is correct in DisplayHz mode + F32 alpha_target = (max_time > cur_max) + ? llmin((F32) max_time/ (F32) cur_max - 1.f,1.f) + : llmin((F32) cur_max/ (F32) max_time - 1.f,1.f); + alpha_interp = lerp(alpha_interp, alpha_target, LLCriticalDamp::getInterpolant(0.1f)); + + if (mHoverID != NULL) + { + x = (mGraphRect.mRight + mGraphRect.mLeft)/2; + y = mGraphRect.mBottom + 8; + + LLFontGL::getFontMonospace()->renderUTF8( + mHoverID->getName(), + 0, + x, y, + LLColor4::white, + LLFontGL::LEFT, LLFontGL::BOTTOM); + } } + // Output stats for clicked bar to log if (mPrintStats >= 0) { @@ -985,7 +947,7 @@ void LLFastTimerView::draw() it != end_timer_tree(); ++it) { - LLTrace::BlockTimer* idp = (*it); + LLTrace::TimeBlock* idp = (*it); if (!first) { @@ -1007,7 +969,7 @@ void LLFastTimerView::draw() it != end_timer_tree(); ++it) { - LLTrace::BlockTimer* idp = (*it); + LLTrace::TimeBlock* idp = (*it); if (!first) { @@ -1015,16 +977,16 @@ void LLFastTimerView::draw() } first = false; - U64 ticks; + LLUnit ticks; if (mPrintStats > 0) { - ticks = idp->getHistoricalCount(mPrintStats); + ticks = frame_recording.getPrevRecordingPeriod(mPrintStats).getSum(*idp); } else { - ticks = idp->getCountAverage(); + ticks = frame_recording.getPeriodMean(*idp); } - F32 ms = (F32)((F64)ticks * iclock_freq); + LLUnit ms = ticks; timer_stat += llformat("%.1f",ms); @@ -1544,13 +1506,13 @@ void LLFastTimerView::outputAllMetrics() //static void LLFastTimerView::doAnalysis(std::string baseline, std::string target, std::string output) { - if(LLTrace::BlockTimer::sLog) + if(LLTrace::TimeBlock::sLog) { doAnalysisDefault(baseline, target, output) ; return ; } - if(LLTrace::BlockTimer::sMetricLog) + if(LLTrace::TimeBlock::sMetricLog) { LLMetricPerformanceTesterBasic::doAnalysisMetrics(baseline, target, output) ; return ; @@ -1561,7 +1523,7 @@ void LLFastTimerView::onClickCloseBtn() setVisible(false); } -LLTrace::BlockTimer& LLFastTimerView::getFrameTimer() +LLTrace::TimeBlock& LLFastTimerView::getFrameTimer() { return FTM_FRAME; } -- cgit v1.2.3 From 6c7825107f6ebb3dd8697a52aeb5d29a93060dc4 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Tue, 4 Dec 2012 19:10:02 -0800 Subject: 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 --- indra/newview/llfasttimerview.cpp | 47 ++++++++++++++++++++++++++------------- 1 file changed, 31 insertions(+), 16 deletions(-) (limited to 'indra/newview/llfasttimerview.cpp') 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("pause_btn")->setLabel(getString("pause")); } else { + if (mRecording != &LLTrace::get_frame_recording()) + { + delete mRecording; + } + mRecording = &LLTrace::get_frame_recording(); + getChild("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 time = llmax(frame_recording.getPrevRecordingPeriod(j).getSum(*idp), LLUnit(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); -- cgit v1.2.3 From 60800dacdd7e9b66ed654af471f2b9e9680cd981 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Thu, 6 Dec 2012 00:37:15 -0800 Subject: SH-3406 WIP convert fast timers to lltrace system fixed gcc compile error made LLCopyOnWritePointer contain an LLPointer, not derive from it added type trait to control periodicrecording mean value type --- indra/newview/llfasttimerview.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'indra/newview/llfasttimerview.cpp') diff --git a/indra/newview/llfasttimerview.cpp b/indra/newview/llfasttimerview.cpp index a06fac6bb6..704b914b78 100644 --- a/indra/newview/llfasttimerview.cpp +++ b/indra/newview/llfasttimerview.cpp @@ -501,7 +501,7 @@ void LLFastTimerView::draw() } else { - ms = frame_recording.getPeriodMean(*idp); + ms = LLUnit(frame_recording.getPeriodMean(*idp)); calls = frame_recording.getPeriodMean(idp->callCount()); } @@ -511,7 +511,7 @@ void LLFastTimerView::draw() } else { - tdesc = llformat("%s [%.1f]",idp->getName().c_str(),ms); + tdesc = llformat("%s [%.1f]",idp->getName().c_str(),ms.value()); } dx = (texth+4) + idp->getDepth()*8; -- cgit v1.2.3 From c99886d94389babc78e92bbfa5084fdd785915af Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Fri, 7 Dec 2012 15:20:12 -0800 Subject: SH-3406 WIP convert fast timers to lltrace system improved unit tests for LLUnit renamed LLUnit to LLUnitImplicit with LLUnit being reserved for explicit units --- indra/newview/llfasttimerview.cpp | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) (limited to 'indra/newview/llfasttimerview.cpp') diff --git a/indra/newview/llfasttimerview.cpp b/indra/newview/llfasttimerview.cpp index 704b914b78..1c63022527 100644 --- a/indra/newview/llfasttimerview.cpp +++ b/indra/newview/llfasttimerview.cpp @@ -311,11 +311,11 @@ static std::string get_tooltip(LLTrace::TimeBlock& timer, S32 history_index, LLT if (history_index < 0) { // by default, show average number of call - tooltip = llformat("%s (%d ms, %d calls)", timer.getName().c_str(), (S32)(frame_recording.getPeriodMean(timer) * ms_multiplier), (S32)frame_recording.getPeriodMean(timer.callCount())); + tooltip = llformat("%s (%d ms, %d calls)", timer.getName().c_str(), (S32)(frame_recording.getPeriodMean(timer) * ms_multiplier).value(), (S32)frame_recording.getPeriodMean(timer.callCount())); } else { - tooltip = llformat("%s (%d ms, %d calls)", timer.getName().c_str(), (S32)(frame_recording.getPrevRecordingPeriod(history_index).getSum(timer) * ms_multiplier), (S32)frame_recording.getPrevRecordingPeriod(history_index).getSum(timer.callCount())); + tooltip = llformat("%s (%d ms, %d calls)", timer.getName().c_str(), (S32)(frame_recording.getPrevRecordingPeriod(history_index).getSum(timer) * ms_multiplier).value(), (S32)frame_recording.getPrevRecordingPeriod(history_index).getSum(timer.callCount())); } return tooltip; } @@ -601,22 +601,22 @@ void LLFastTimerView::draw() { LLUnit ms = total_time; - tdesc = llformat("%.1f ms |", (F32)ms*.25f); + tdesc = llformat("%.1f ms |", (F32)ms.value()*.25f); x = xleft + barw/4 - LLFontGL::getFontMonospace()->getWidth(tdesc); LLFontGL::getFontMonospace()->renderUTF8(tdesc, 0, x, y, LLColor4::white, LLFontGL::LEFT, LLFontGL::TOP); - tdesc = llformat("%.1f ms |", (F32)ms*.50f); + tdesc = llformat("%.1f ms |", (F32)ms.value()*.50f); x = xleft + barw/2 - LLFontGL::getFontMonospace()->getWidth(tdesc); LLFontGL::getFontMonospace()->renderUTF8(tdesc, 0, x, y, LLColor4::white, LLFontGL::LEFT, LLFontGL::TOP); - tdesc = llformat("%.1f ms |", (F32)ms*.75f); + tdesc = llformat("%.1f ms |", (F32)ms.value()*.75f); x = xleft + (barw*3)/4 - LLFontGL::getFontMonospace()->getWidth(tdesc); LLFontGL::getFontMonospace()->renderUTF8(tdesc, 0, x, y, LLColor4::white, LLFontGL::LEFT, LLFontGL::TOP); - tdesc = llformat( "%d ms |", (U32)ms); + tdesc = llformat( "%d ms |", (U32)ms.value()); x = xleft + barw - LLFontGL::getFontMonospace()->getWidth(tdesc); LLFontGL::getFontMonospace()->renderUTF8(tdesc, 0, x, y, LLColor4::white, LLFontGL::LEFT, LLFontGL::TOP); @@ -728,11 +728,11 @@ void LLFastTimerView::draw() ++it) { sublevelticks += (tidx == -1) - ? frame_recording.getPeriodMean(**it) - : frame_recording.getPrevRecordingPeriod(tidx).getSum(**it); + ? frame_recording.getPeriodMean(**it).value() + : frame_recording.getPrevRecordingPeriod(tidx).getSum(**it).value(); } - F32 subfrac = (F32)sublevelticks / (F32)total_time; + F32 subfrac = (F32)sublevelticks / (F32)total_time.value(); sublevel_dx[level] = (int)(subfrac * (F32)barw + .5f); if (mDisplayCenter == ALIGN_CENTER) @@ -819,7 +819,7 @@ void LLFastTimerView::draw() else if (mDisplayHz) tdesc = llformat("%d Hz", (int)(1.f / max_time.value())); else - tdesc = llformat("%4.2f ms", LLUnit(max_time).value()); + tdesc = llformat("%4.2f ms", max_time.value()); x = mGraphRect.mRight - LLFontGL::getFontMonospace()->getWidth(tdesc)-5; y = mGraphRect.mTop - LLFontGL::getFontMonospace()->getLineHeight(); @@ -900,7 +900,7 @@ void LLFastTimerView::draw() 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); + : mGraphRect.mBottom + time / max_time * (F32)mGraphRect.getHeight(); gGL.vertex2f(x,y); gGL.vertex2f(x,mGraphRect.mBottom); } @@ -920,22 +920,22 @@ void LLFastTimerView::draw() } //interpolate towards new maximum - max_time = lerp((F32)max_time, (F32) cur_max, LLCriticalDamp::getInterpolant(0.1f)); + max_time = lerp(max_time.value(), cur_max.value(), LLCriticalDamp::getInterpolant(0.1f)); if (max_time - cur_max <= 1 || cur_max - max_time <= 1) { max_time = llmax(LLUnit(1), LLUnit(cur_max)); } max_calls = lerp((F32)max_calls, (F32) cur_max_calls, LLCriticalDamp::getInterpolant(0.1f)); - if (llabs(max_calls - cur_max) <= 1) + if (llabs((S32)(max_calls - cur_max_calls)) <= 1) { max_calls = cur_max_calls; } // TODO: make sure alpha is correct in DisplayHz mode F32 alpha_target = (max_time > cur_max) - ? llmin((F32) max_time/ (F32) cur_max - 1.f,1.f) - : llmin((F32) cur_max/ (F32) max_time - 1.f,1.f); + ? llmin(max_time / cur_max - 1.f,1.f) + : llmin(cur_max/ max_time - 1.f,1.f); alpha_interp = lerp(alpha_interp, alpha_target, LLCriticalDamp::getInterpolant(0.1f)); if (mHoverID != NULL) -- cgit v1.2.3 From 8c2e3bea71ea15b805a9e2a288744f10d195d803 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Sun, 9 Dec 2012 23:19:11 -0800 Subject: SH-3406 WIP convert fast timers to lltrace system added ability to query self time of block timers indepedently --- indra/newview/llfasttimerview.cpp | 428 +++++++++++++++++++------------------- 1 file changed, 210 insertions(+), 218 deletions(-) (limited to 'indra/newview/llfasttimerview.cpp') diff --git a/indra/newview/llfasttimerview.cpp b/indra/newview/llfasttimerview.cpp index 1c63022527..8014b5712b 100644 --- a/indra/newview/llfasttimerview.cpp +++ b/indra/newview/llfasttimerview.cpp @@ -381,9 +381,9 @@ void LLFastTimerView::draw() std::string tdesc; - S32 margin = 10; - S32 height = getRect().getHeight(); - S32 width = getRect().getWidth(); + const S32 margin = 10; + const S32 height = getRect().getHeight(); + const S32 width = getRect().getWidth(); LLRect new_rect; new_rect.setLeftTopAndSize(getRect().mLeft, getRect().mTop, width, height); @@ -391,22 +391,17 @@ void LLFastTimerView::draw() S32 left, top, right, bottom; S32 x, y, barw, barh, dx, dy; - S32 texth, textw; + const S32 texth = (S32)LLFontGL::getFontMonospace()->getLineHeight(); LLPointer box_imagep = LLUI::getUIImage("Rounded_Square"); // Draw the window background gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); gl_rect_2d(0, getRect().getHeight(), getRect().getWidth(), 0, LLColor4(0.f, 0.f, 0.f, 0.25f)); - S32 xleft = margin; - S32 ytop = margin; - // Draw some help { - - x = xleft; - y = height - ytop; - texth = (S32)LLFontGL::getFontMonospace()->getLineHeight(); + x = margin; + y = height - margin; char modedesc[][32] = { "2 x Average ", @@ -422,9 +417,8 @@ void LLFastTimerView::draw() tdesc = llformat("Full bar = %s [Click to pause/reset] [SHIFT-Click to toggle]",modedesc[mDisplayMode]); LLFontGL::getFontMonospace()->renderUTF8(tdesc, 0, x, y, LLColor4::white, LLFontGL::LEFT, LLFontGL::TOP); - textw = LLFontGL::getFontMonospace()->getWidth(tdesc); - x = xleft, y -= (texth + 2); + x = margin, y -= (texth + 2); tdesc = llformat("Justification = %s [CTRL-Click to toggle]",centerdesc[mDisplayCenter]); LLFontGL::getFontMonospace()->renderUTF8(tdesc, 0, x, y, LLColor4::white, LLFontGL::LEFT, LLFontGL::TOP); y -= (texth + 2); @@ -436,36 +430,38 @@ void LLFastTimerView::draw() S32 histmax = llmin(frame_recording.getNumPeriods()+1, MAX_VISIBLE_HISTORY); - // Draw the legend - xleft = margin; - ytop = y; - + const S32 ytop = y; y -= (texth + 2); - sTimerColors[&getFrameTimer()] = LLColor4::grey; + // generate unique colors + { + sTimerColors[&getFrameTimer()] = LLColor4::grey; - F32 hue = 0.f; + F32 hue = 0.f; - for (timer_tree_iterator_t it = begin_timer_tree(getFrameTimer()); - it != timer_tree_iterator_t(); - ++it) - { - LLTrace::TimeBlock* idp = (*it); + for (timer_tree_iterator_t it = begin_timer_tree(getFrameTimer()); + it != timer_tree_iterator_t(); + ++it) + { + LLTrace::TimeBlock* idp = (*it); - const F32 HUE_INCREMENT = 0.23f; - hue = fmodf(hue + HUE_INCREMENT, 1.f); - // saturation increases with depth - F32 saturation = clamp_rescale((F32)idp->getDepth(), 0.f, 3.f, 0.f, 1.f); - // lightness alternates with depth - F32 lightness = idp->getDepth() % 2 ? 0.5f : 0.6f; + const F32 HUE_INCREMENT = 0.23f; + hue = fmodf(hue + HUE_INCREMENT, 1.f); + // saturation increases with depth + F32 saturation = clamp_rescale((F32)idp->getDepth(), 0.f, 3.f, 0.f, 1.f); + // lightness alternates with depth + F32 lightness = idp->getDepth() % 2 ? 0.5f : 0.6f; - LLColor4 child_color; - child_color.setHSL(hue, saturation, lightness); + LLColor4 child_color; + child_color.setHSL(hue, saturation, lightness); - sTimerColors[idp] = child_color; + sTimerColors[idp] = child_color; + } } + // draw legend const S32 LEGEND_WIDTH = 220; + const S32 x_start = margin + LEGEND_WIDTH + 8; { LLLocalClipRect clip(LLRect(margin, y, LEGEND_WIDTH, margin)); S32 cur_line = 0; @@ -480,7 +476,7 @@ void LLFastTimerView::draw() ft_display_idx.push_back(idp); cur_line++; - x = xleft; + x = margin; left = x; right = x + texth; top = y; bottom = y - texth; @@ -547,8 +543,6 @@ void LLFastTimerView::draw() y -= (texth + 2); - textw = dx + LLFontGL::getFontMonospace()->getWidth(idp->getName()) + 40; - if (idp->getCollapsed()) { it.skipDescendants(); @@ -556,11 +550,8 @@ void LLFastTimerView::draw() } } - xleft += LEGEND_WIDTH + 8; - // ytop = ytop; - // update rectangle that includes timer bars - mBarRect.mLeft = xleft; + mBarRect.mLeft = x_start; mBarRect.mRight = getRect().getWidth(); mBarRect.mTop = ytop - (LLFontGL::getFontMonospace()->getLineHeight() + 4); mBarRect.mBottom = margin + LINE_GRAPH_HEIGHT; @@ -570,238 +561,239 @@ void LLFastTimerView::draw() dy = barh>>2; // spacing between bars if (dy < 1) dy = 1; barh -= dy; - barw = width - xleft - margin; + barw = width - x_start - margin; // Draw the history bars - LLLocalClipRect clip(LLRect(xleft, ytop, getRect().getWidth() - margin, margin)); - LLUnit total_time; - - mAllTimeMax = llmax(mAllTimeMax, frame_recording.getLastRecordingPeriod().getSum(getFrameTimer())); - - if (mDisplayMode == 0) + switch(mDisplayMode) { + case 0: total_time = frame_recording.getPeriodMean(getFrameTimer())*2; - } - else if (mDisplayMode == 1) - { + break; + case 1: total_time = mAllTimeMax; - } - else if (mDisplayMode == 2) - { + break; + case 2: // Calculate the max total ticks for the current history total_time = frame_recording.getPeriodMax(getFrameTimer()); - } - else - { + break; + default: total_time = LLUnit(100); + break; } - - // Draw MS ticks + + if (total_time > 0) { - LLUnit ms = total_time; + LLLocalClipRect clip(LLRect(x_start, ytop, getRect().getWidth() - margin, margin)); - tdesc = llformat("%.1f ms |", (F32)ms.value()*.25f); - x = xleft + barw/4 - LLFontGL::getFontMonospace()->getWidth(tdesc); - LLFontGL::getFontMonospace()->renderUTF8(tdesc, 0, x, y, LLColor4::white, - LLFontGL::LEFT, LLFontGL::TOP); + mAllTimeMax = llmax(mAllTimeMax, frame_recording.getLastRecordingPeriod().getSum(getFrameTimer())); + + // Draw MS ticks + { + LLUnit ms = total_time; + + tdesc = llformat("%.1f ms |", (F32)ms.value()*.25f); + x = x_start + barw/4 - LLFontGL::getFontMonospace()->getWidth(tdesc); + LLFontGL::getFontMonospace()->renderUTF8(tdesc, 0, x, y, LLColor4::white, + LLFontGL::LEFT, LLFontGL::TOP); - tdesc = llformat("%.1f ms |", (F32)ms.value()*.50f); - x = xleft + barw/2 - LLFontGL::getFontMonospace()->getWidth(tdesc); - LLFontGL::getFontMonospace()->renderUTF8(tdesc, 0, x, y, LLColor4::white, - LLFontGL::LEFT, LLFontGL::TOP); + tdesc = llformat("%.1f ms |", (F32)ms.value()*.50f); + x = x_start + barw/2 - LLFontGL::getFontMonospace()->getWidth(tdesc); + LLFontGL::getFontMonospace()->renderUTF8(tdesc, 0, x, y, LLColor4::white, + LLFontGL::LEFT, LLFontGL::TOP); - tdesc = llformat("%.1f ms |", (F32)ms.value()*.75f); - x = xleft + (barw*3)/4 - LLFontGL::getFontMonospace()->getWidth(tdesc); - LLFontGL::getFontMonospace()->renderUTF8(tdesc, 0, x, y, LLColor4::white, - LLFontGL::LEFT, LLFontGL::TOP); + tdesc = llformat("%.1f ms |", (F32)ms.value()*.75f); + x = x_start + (barw*3)/4 - LLFontGL::getFontMonospace()->getWidth(tdesc); + LLFontGL::getFontMonospace()->renderUTF8(tdesc, 0, x, y, LLColor4::white, + LLFontGL::LEFT, LLFontGL::TOP); - tdesc = llformat( "%d ms |", (U32)ms.value()); - x = xleft + barw - LLFontGL::getFontMonospace()->getWidth(tdesc); - LLFontGL::getFontMonospace()->renderUTF8(tdesc, 0, x, y, LLColor4::white, - LLFontGL::LEFT, LLFontGL::TOP); - } + tdesc = llformat( "%d ms |", (U32)ms.value()); + x = x_start + barw - LLFontGL::getFontMonospace()->getWidth(tdesc); + LLFontGL::getFontMonospace()->renderUTF8(tdesc, 0, x, y, LLColor4::white, + LLFontGL::LEFT, LLFontGL::TOP); + } - // Draw borders - { - gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); - gGL.color4f(0.5f,0.5f,0.5f,0.5f); + // Draw borders + { + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); + gGL.color4f(0.5f,0.5f,0.5f,0.5f); - S32 by = y + 2; + S32 by = y + 2; - y -= ((S32)LLFontGL::getFontMonospace()->getLineHeight() + 4); + y -= ((S32)LLFontGL::getFontMonospace()->getLineHeight() + 4); - //heading - gl_rect_2d(xleft-5, by, getRect().getWidth()-5, y+5, FALSE); + //heading + gl_rect_2d(x_start-5, by, getRect().getWidth()-5, y+5, FALSE); - //tree view - gl_rect_2d(5, by, xleft-10, 5, FALSE); + //tree view + gl_rect_2d(5, by, x_start-10, 5, FALSE); - by = y + 5; - //average bar - gl_rect_2d(xleft-5, by, getRect().getWidth()-5, by-barh-dy-5, FALSE); + by = y + 5; + //average bar + gl_rect_2d(x_start-5, by, getRect().getWidth()-5, by-barh-dy-5, FALSE); - by -= barh*2+dy; + by -= barh*2+dy; - //current frame bar - gl_rect_2d(xleft-5, by, getRect().getWidth()-5, by-barh-dy-2, FALSE); + //current frame bar + gl_rect_2d(x_start-5, by, getRect().getWidth()-5, by-barh-dy-2, FALSE); - by -= barh+dy+1; + by -= barh+dy+1; - //history bars - gl_rect_2d(xleft-5, by, getRect().getWidth()-5, LINE_GRAPH_HEIGHT-barh-dy-2, FALSE); + //history bars + gl_rect_2d(x_start-5, by, getRect().getWidth()-5, LINE_GRAPH_HEIGHT-barh-dy-2, FALSE); - by = LINE_GRAPH_HEIGHT-barh-dy-7; + by = LINE_GRAPH_HEIGHT-barh-dy-7; - //line graph - mGraphRect = LLRect(xleft-5, by, getRect().getWidth()-5, 5); + //line graph + mGraphRect = LLRect(x_start-5, by, getRect().getWidth()-5, 5); - gl_rect_2d(mGraphRect, FALSE); - } + gl_rect_2d(mGraphRect, FALSE); + } - mBarStart.clear(); - mBarEnd.clear(); + mBarStart.clear(); + mBarEnd.clear(); - // Draw bars for each history entry - // Special: -1 = show running average - gGL.getTexUnit(0)->bind(box_imagep->getImage()); - for (S32 j=-1; j LINE_GRAPH_HEIGHT; j++) - { - mBarStart.push_back(std::vector()); - mBarEnd.push_back(std::vector()); - int sublevel_dx[FTV_MAX_DEPTH]; - int sublevel_left[FTV_MAX_DEPTH]; - int sublevel_right[FTV_MAX_DEPTH]; - S32 tidx; - if (j >= 0) + // Draw bars for each history entry + // Special: -1 = show running average + gGL.getTexUnit(0)->bind(box_imagep->getImage()); + for (S32 j=-1; j LINE_GRAPH_HEIGHT; j++) { - tidx = j + 1 + mScrollIndex; - } - else - { - tidx = -1; - } + mBarStart.push_back(std::vector()); + mBarEnd.push_back(std::vector()); + int sublevel_dx[FTV_MAX_DEPTH]; + int sublevel_left[FTV_MAX_DEPTH]; + int sublevel_right[FTV_MAX_DEPTH]; + S32 tidx; + if (j >= 0) + { + tidx = j + 1 + mScrollIndex; + } + else + { + tidx = -1; + } - x = xleft; + x = x_start; - // draw the bars for each stat - std::vector xpos; - std::vector deltax; - xpos.push_back(xleft); + // draw the bars for each stat + std::vector xpos; + std::vector deltax; + xpos.push_back(x_start); - LLTrace::TimeBlock* prev_id = NULL; + LLTrace::TimeBlock* prev_id = NULL; - S32 i = 0; - for(timer_tree_iterator_t it = begin_timer_tree(getFrameTimer()); - it != end_timer_tree(); - ++it, ++i) - { - LLTrace::TimeBlock* idp = (*it); - F32 frac = tidx == -1 - ? (frame_recording.getPeriodMean(*idp) / total_time) - : (frame_recording.getPrevRecordingPeriod(tidx).getSum(*idp).value() / total_time.value()); + S32 i = 0; + for(timer_tree_iterator_t it = begin_timer_tree(getFrameTimer()); + it != end_timer_tree(); + ++it, ++i) + { + LLTrace::TimeBlock* idp = (*it); + F32 frac = tidx == -1 + ? (frame_recording.getPeriodMean(*idp) / total_time) + : (frame_recording.getPrevRecordingPeriod(tidx).getSum(*idp).value() / total_time.value()); - dx = llround(frac * (F32)barw); - S32 prev_delta_x = deltax.empty() ? 0 : deltax.back(); - deltax.push_back(dx); + dx = llround(frac * (F32)barw); + S32 prev_delta_x = deltax.empty() ? 0 : deltax.back(); + deltax.push_back(dx); - int level = idp->getDepth() - 1; + int level = idp->getDepth() - 1; - while ((S32)xpos.size() > level + 1) - { - xpos.pop_back(); - } - left = xpos.back(); - - if (level == 0) - { - sublevel_left[level] = xleft; - sublevel_dx[level] = dx; - sublevel_right[level] = sublevel_left[level] + sublevel_dx[level]; - } - else if (prev_id && prev_id->getDepth() < idp->getDepth()) - { - U64 sublevelticks = 0; - - for (LLTrace::TimeBlock::child_const_iter it = prev_id->beginChildren(); - it != prev_id->endChildren(); - ++it) + while ((S32)xpos.size() > level + 1) { - sublevelticks += (tidx == -1) - ? frame_recording.getPeriodMean(**it).value() - : frame_recording.getPrevRecordingPeriod(tidx).getSum(**it).value(); + xpos.pop_back(); } - - F32 subfrac = (F32)sublevelticks / (F32)total_time.value(); - sublevel_dx[level] = (int)(subfrac * (F32)barw + .5f); - - if (mDisplayCenter == ALIGN_CENTER) + left = xpos.back(); + + if (level == 0) { - left += (prev_delta_x - sublevel_dx[level])/2; + sublevel_left[level] = x_start; + sublevel_dx[level] = dx; + sublevel_right[level] = sublevel_left[level] + sublevel_dx[level]; } - else if (mDisplayCenter == ALIGN_RIGHT) + else if (prev_id && prev_id->getDepth() < idp->getDepth()) { - left += (prev_delta_x - sublevel_dx[level]); - } - - sublevel_left[level] = left; - sublevel_right[level] = sublevel_left[level] + sublevel_dx[level]; - } - - right = left + dx; - xpos.back() = right; - xpos.push_back(left); + U64 sublevelticks = 0; + + for (LLTrace::TimeBlock::child_const_iter it = prev_id->beginChildren(); + it != prev_id->endChildren(); + ++it) + { + sublevelticks += (tidx == -1) + ? frame_recording.getPeriodMean(**it).value() + : frame_recording.getPrevRecordingPeriod(tidx).getSum(**it).value(); + } + + F32 subfrac = (F32)sublevelticks / (F32)total_time.value(); + sublevel_dx[level] = (int)(subfrac * (F32)barw + .5f); + + if (mDisplayCenter == ALIGN_CENTER) + { + left += (prev_delta_x - sublevel_dx[level])/2; + } + else if (mDisplayCenter == ALIGN_RIGHT) + { + left += (prev_delta_x - sublevel_dx[level]); + } + + sublevel_left[level] = left; + sublevel_right[level] = sublevel_left[level] + sublevel_dx[level]; + } + + right = left + dx; + xpos.back() = right; + xpos.push_back(left); - mBarStart.back().push_back(left); - mBarEnd.back().push_back(right); + mBarStart.back().push_back(left); + mBarEnd.back().push_back(right); - top = y; - bottom = y - barh; + top = y; + bottom = y - barh; - if (right > left) - { - //U32 rounded_edges = 0; - LLColor4 color = sTimerColors[idp];//*ft_display_table[i].color; - S32 scale_offset = 0; - - BOOL is_child_of_hover_item = (idp == mHoverID); - LLTrace::TimeBlock* next_parent = idp->getParent(); - while(!is_child_of_hover_item && next_parent) + if (right > left) { - is_child_of_hover_item = (mHoverID == next_parent); - if (next_parent->getParent() == next_parent) break; - next_parent = next_parent->getParent(); - } + //U32 rounded_edges = 0; + LLColor4 color = sTimerColors[idp];//*ft_display_table[i].color; + S32 scale_offset = 0; + + BOOL is_child_of_hover_item = (idp == mHoverID); + LLTrace::TimeBlock* next_parent = idp->getParent(); + while(!is_child_of_hover_item && next_parent) + { + is_child_of_hover_item = (mHoverID == next_parent); + if (next_parent->getParent() == next_parent) break; + next_parent = next_parent->getParent(); + } + + if (idp == mHoverID) + { + scale_offset = llfloor(sinf(mHighlightTimer.getElapsedTimeF32() * 6.f) * 3.f); + //color = lerp(color, LLColor4::black, -0.4f); + } + else if (mHoverID != NULL && !is_child_of_hover_item) + { + color = lerp(color, LLColor4::grey, 0.8f); + } + + gGL.color4fv(color.mV); + F32 start_fragment = llclamp((F32)(left - sublevel_left[level]) / (F32)sublevel_dx[level], 0.f, 1.f); + F32 end_fragment = llclamp((F32)(right - sublevel_left[level]) / (F32)sublevel_dx[level], 0.f, 1.f); + gl_segmented_rect_2d_fragment_tex(sublevel_left[level], top - level + scale_offset, sublevel_right[level], bottom + level - scale_offset, box_imagep->getTextureWidth(), box_imagep->getTextureHeight(), 16, start_fragment, end_fragment); - if (idp == mHoverID) - { - scale_offset = llfloor(sinf(mHighlightTimer.getElapsedTimeF32() * 6.f) * 3.f); - //color = lerp(color, LLColor4::black, -0.4f); } - else if (mHoverID != NULL && !is_child_of_hover_item) + + if ((*it)->getCollapsed()) { - color = lerp(color, LLColor4::grey, 0.8f); + it.skipDescendants(); } - - gGL.color4fv(color.mV); - F32 start_fragment = llclamp((F32)(left - sublevel_left[level]) / (F32)sublevel_dx[level], 0.f, 1.f); - F32 end_fragment = llclamp((F32)(right - sublevel_left[level]) / (F32)sublevel_dx[level], 0.f, 1.f); - gl_segmented_rect_2d_fragment_tex(sublevel_left[level], top - level + scale_offset, sublevel_right[level], bottom + level - scale_offset, box_imagep->getTextureWidth(), box_imagep->getTextureHeight(), 16, start_fragment, end_fragment); - - } - - if ((*it)->getCollapsed()) - { - it.skipDescendants(); - } - prev_id = idp; + prev_id = idp; + } + y -= (barh + dy); + if (j < 0) + y -= barh; } - y -= (barh + dy); - if (j < 0) - y -= barh; } - + //draw line graph history { gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); -- cgit v1.2.3 From c219282f5de753a044cecb53bd806145f68add9a Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Tue, 18 Dec 2012 20:07:25 -0800 Subject: SH-3406 WIP convert fast timers to lltrace system removed some potential data races got memory stats recording in trace system --- indra/newview/llfasttimerview.cpp | 52 +++++++++++++++++++++++++-------------- 1 file changed, 33 insertions(+), 19 deletions(-) (limited to 'indra/newview/llfasttimerview.cpp') diff --git a/indra/newview/llfasttimerview.cpp b/indra/newview/llfasttimerview.cpp index 8014b5712b..2cf7939e5c 100644 --- a/indra/newview/llfasttimerview.cpp +++ b/indra/newview/llfasttimerview.cpp @@ -58,6 +58,7 @@ static const S32 MAX_VISIBLE_HISTORY = 10; static const S32 LINE_GRAPH_HEIGHT = 240; const S32 FTV_MAX_DEPTH = 8; +const S32 HISTORY_NUM = 300; std::vector ft_display_idx; // line of table entry for display purposes (for collapse) @@ -77,6 +78,19 @@ static timer_tree_iterator_t end_timer_tree() return timer_tree_iterator_t(); } +S32 get_depth(const TimeBlock* blockp) +{ + S32 depth = 0; + TimeBlock* timerp = blockp->mParent; + while(timerp) + { + depth++; + if (timerp->getParent() == timerp) break; + timerp = timerp->mParent; + } + return depth; +} + LLFastTimerView::LLFastTimerView(const LLSD& key) : LLFloater(key), mHoverTimer(NULL), @@ -88,7 +102,8 @@ LLFastTimerView::LLFastTimerView(const LLSD& key) mHoverID(NULL), mHoverBarIndex(-1), mPrintStats(-1), - mRecording(&LLTrace::get_frame_recording()) + mRecording(&LLTrace::get_frame_recording()), + mPauseHistory(false) {} LLFastTimerView::~LLFastTimerView() @@ -102,13 +117,12 @@ LLFastTimerView::~LLFastTimerView() void LLFastTimerView::onPause() { - LLTrace::TimeBlock::sPauseHistory = !LLTrace::TimeBlock::sPauseHistory; + mPauseHistory = !mPauseHistory; // reset scroll to bottom when unpausing - if (!LLTrace::TimeBlock::sPauseHistory) + if (!mPauseHistory) { mRecording = new LLTrace::PeriodicRecording(LLTrace::get_frame_recording()); mScrollIndex = 0; - LLTrace::TimeBlock::sResetHistory = true; getChild("pause_btn")->setLabel(getString("pause")); } else @@ -239,14 +253,14 @@ BOOL LLFastTimerView::handleHover(S32 x, S32 y, MASK mask) if (hasMouseCapture()) { F32 lerp = llclamp(1.f - (F32) (x - mGraphRect.mLeft) / (F32) mGraphRect.getWidth(), 0.f, 1.f); - mScrollIndex = llround( lerp * (F32)(LLTrace::TimeBlock::HISTORY_NUM - MAX_VISIBLE_HISTORY)); + mScrollIndex = llround( lerp * (F32)(HISTORY_NUM - MAX_VISIBLE_HISTORY)); mScrollIndex = llclamp( mScrollIndex, 0, frame_recording.getNumPeriods()); return TRUE; } mHoverTimer = NULL; mHoverID = NULL; - if(LLTrace::TimeBlock::sPauseHistory && mBarRect.pointInRect(x, y)) + if(mPauseHistory && mBarRect.pointInRect(x, y)) { mHoverBarIndex = llmin(mRecording->getNumPeriods() - 1, MAX_VISIBLE_HISTORY - ((y - mBarRect.mBottom) * (MAX_VISIBLE_HISTORY + 2) / mBarRect.getHeight())); @@ -322,7 +336,7 @@ static std::string get_tooltip(LLTrace::TimeBlock& timer, S32 history_index, LLT BOOL LLFastTimerView::handleToolTip(S32 x, S32 y, MASK mask) { - if(LLTrace::TimeBlock::sPauseHistory && mBarRect.pointInRect(x, y)) + if(mPauseHistory && mBarRect.pointInRect(x, y)) { // tooltips for timer bars if (mHoverTimer) @@ -362,10 +376,10 @@ BOOL LLFastTimerView::handleScrollWheel(S32 x, S32 y, S32 clicks) { LLTrace::PeriodicRecording& frame_recording = *mRecording; - LLTrace::TimeBlock::sPauseHistory = TRUE; + mPauseHistory = true; mScrollIndex = llclamp( mScrollIndex + clicks, 0, - llmin(frame_recording.getNumPeriods(), (S32)LLTrace::TimeBlock::HISTORY_NUM - MAX_VISIBLE_HISTORY)); + llmin(frame_recording.getNumPeriods(), (S32)HISTORY_NUM - MAX_VISIBLE_HISTORY)); return TRUE; } @@ -448,9 +462,9 @@ void LLFastTimerView::draw() const F32 HUE_INCREMENT = 0.23f; hue = fmodf(hue + HUE_INCREMENT, 1.f); // saturation increases with depth - F32 saturation = clamp_rescale((F32)idp->getDepth(), 0.f, 3.f, 0.f, 1.f); + F32 saturation = clamp_rescale((F32)get_depth(idp), 0.f, 3.f, 0.f, 1.f); // lightness alternates with depth - F32 lightness = idp->getDepth() % 2 ? 0.5f : 0.6f; + F32 lightness = get_depth(idp) % 2 ? 0.5f : 0.6f; LLColor4 child_color; child_color.setHSL(hue, saturation, lightness); @@ -509,15 +523,15 @@ void LLFastTimerView::draw() { tdesc = llformat("%s [%.1f]",idp->getName().c_str(),ms.value()); } - dx = (texth+4) + idp->getDepth()*8; + dx = (texth+4) + get_depth(idp)*8; LLColor4 color = LLColor4::white; - if (idp->getDepth() > 0) + if (get_depth(idp) > 0) { S32 line_start_y = (top + bottom) / 2; S32 line_end_y = line_start_y + ((texth + 2) * (cur_line - display_line[idp->getParent()])) - texth; gl_line_2d(x + dx - 8, line_start_y, x + dx, line_start_y, color); - S32 line_x = x + (texth + 4) + ((idp->getDepth() - 1) * 8); + S32 line_x = x + (texth + 4) + ((get_depth(idp) - 1) * 8); gl_line_2d(line_x, line_start_y, line_x, line_end_y, color); if (idp->getCollapsed() && !idp->getChildren().empty()) { @@ -696,7 +710,7 @@ void LLFastTimerView::draw() S32 prev_delta_x = deltax.empty() ? 0 : deltax.back(); deltax.push_back(dx); - int level = idp->getDepth() - 1; + int level = get_depth(idp) - 1; while ((S32)xpos.size() > level + 1) { @@ -710,7 +724,7 @@ void LLFastTimerView::draw() sublevel_dx[level] = dx; sublevel_right[level] = sublevel_left[level] + sublevel_dx[level]; } - else if (prev_id && prev_id->getDepth() < idp->getDepth()) + else if (prev_id && prev_id->getDepth() < get_depth(idp)) { U64 sublevelticks = 0; @@ -821,10 +835,10 @@ void LLFastTimerView::draw() //highlight visible range { - S32 first_frame = LLTrace::TimeBlock::HISTORY_NUM - mScrollIndex; + S32 first_frame = HISTORY_NUM - mScrollIndex; S32 last_frame = first_frame - MAX_VISIBLE_HISTORY; - F32 frame_delta = ((F32) (mGraphRect.getWidth()))/(LLTrace::TimeBlock::HISTORY_NUM-1); + F32 frame_delta = ((F32) (mGraphRect.getWidth()))/(HISTORY_NUM-1); F32 right = (F32) mGraphRect.mLeft + frame_delta*first_frame; F32 left = (F32) mGraphRect.mLeft + frame_delta*last_frame; @@ -889,7 +903,7 @@ void LLFastTimerView::draw() cur_max = llmax(cur_max, time); cur_max_calls = llmax(cur_max_calls, calls); } - F32 x = mGraphRect.mRight - j * (F32)(mGraphRect.getWidth())/(LLTrace::TimeBlock::HISTORY_NUM-1); + F32 x = mGraphRect.mRight - j * (F32)(mGraphRect.getWidth())/(HISTORY_NUM-1); F32 y = mDisplayHz ? mGraphRect.mBottom + (1.f / time.value()) * ((F32) mGraphRect.getHeight() / (1.f / max_time.value())) : mGraphRect.mBottom + time / max_time * (F32)mGraphRect.getHeight(); -- cgit v1.2.3 From 013f04cabec8e110ee659d9b3f75a4d25f114b7b Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Fri, 21 Dec 2012 00:13:21 -0800 Subject: SH-3468 WIP add memory tracking base class improvements on lifetime of lltrace core data structures tweaks to thread local pointer handling so that static constructors/destructors can safely call functions that use lltrace --- indra/newview/llfasttimerview.cpp | 78 ++++++++++++++++++++------------------- 1 file changed, 40 insertions(+), 38 deletions(-) (limited to 'indra/newview/llfasttimerview.cpp') diff --git a/indra/newview/llfasttimerview.cpp b/indra/newview/llfasttimerview.cpp index 2cf7939e5c..56e5710726 100644 --- a/indra/newview/llfasttimerview.cpp +++ b/indra/newview/llfasttimerview.cpp @@ -54,23 +54,25 @@ ////////////////////////////////////////////////////////////////////////////// +using namespace LLTrace; + static const S32 MAX_VISIBLE_HISTORY = 10; static const S32 LINE_GRAPH_HEIGHT = 240; const S32 FTV_MAX_DEPTH = 8; const S32 HISTORY_NUM = 300; -std::vector ft_display_idx; // line of table entry for display purposes (for collapse) +std::vector ft_display_idx; // line of table entry for display purposes (for collapse) -typedef LLTreeDFSIter timer_tree_iterator_t; +typedef LLTreeDFSIter timer_tree_iterator_t; BOOL LLFastTimerView::sAnalyzePerformance = FALSE; -static timer_tree_iterator_t begin_timer_tree(LLTrace::TimeBlock& id) +static timer_tree_iterator_t begin_timer_tree(TimeBlock& id) { return timer_tree_iterator_t(&id, - boost::bind(boost::mem_fn(&LLTrace::TimeBlock::beginChildren), _1), - boost::bind(boost::mem_fn(&LLTrace::TimeBlock::endChildren), _1)); + boost::bind(boost::mem_fn(&TimeBlock::beginChildren), _1), + boost::bind(boost::mem_fn(&TimeBlock::endChildren), _1)); } static timer_tree_iterator_t end_timer_tree() @@ -81,12 +83,12 @@ static timer_tree_iterator_t end_timer_tree() S32 get_depth(const TimeBlock* blockp) { S32 depth = 0; - TimeBlock* timerp = blockp->mParent; + TimeBlock* timerp = blockp->getParent(); while(timerp) { depth++; if (timerp->getParent() == timerp) break; - timerp = timerp->mParent; + timerp = timerp->getParent(); } return depth; } @@ -102,13 +104,13 @@ LLFastTimerView::LLFastTimerView(const LLSD& key) mHoverID(NULL), mHoverBarIndex(-1), mPrintStats(-1), - mRecording(&LLTrace::get_frame_recording()), + mRecording(&get_frame_recording()), mPauseHistory(false) {} LLFastTimerView::~LLFastTimerView() { - if (mRecording != &LLTrace::get_frame_recording()) + if (mRecording != &get_frame_recording()) { delete mRecording; } @@ -121,17 +123,17 @@ void LLFastTimerView::onPause() // reset scroll to bottom when unpausing if (!mPauseHistory) { - mRecording = new LLTrace::PeriodicRecording(LLTrace::get_frame_recording()); + mRecording = new PeriodicRecording(get_frame_recording()); mScrollIndex = 0; getChild("pause_btn")->setLabel(getString("pause")); } else { - if (mRecording != &LLTrace::get_frame_recording()) + if (mRecording != &get_frame_recording()) { delete mRecording; } - mRecording = &LLTrace::get_frame_recording(); + mRecording = &get_frame_recording(); getChild("pause_btn")->setLabel(getString("run")); } @@ -170,7 +172,7 @@ BOOL LLFastTimerView::handleRightMouseDown(S32 x, S32 y, MASK mask) return LLFloater::handleRightMouseDown(x, y, mask); } -LLTrace::TimeBlock* LLFastTimerView::getLegendID(S32 y) +TimeBlock* LLFastTimerView::getLegendID(S32 y) { S32 idx = (getRect().getHeight() - y) / (LLFontGL::getFontMonospace()->getLineHeight()+2) - 5; @@ -197,7 +199,7 @@ BOOL LLFastTimerView::handleMouseDown(S32 x, S32 y, MASK mask) { if (x < mBarRect.mLeft) { - LLTrace::TimeBlock* idp = getLegendID(y); + TimeBlock* idp = getLegendID(y); if (idp) { idp->setCollapsed(!idp->getCollapsed()); @@ -248,7 +250,7 @@ BOOL LLFastTimerView::handleMouseUp(S32 x, S32 y, MASK mask) BOOL LLFastTimerView::handleHover(S32 x, S32 y, MASK mask) { - LLTrace::PeriodicRecording& frame_recording = *mRecording; + PeriodicRecording& frame_recording = *mRecording; if (hasMouseCapture()) { @@ -306,7 +308,7 @@ BOOL LLFastTimerView::handleHover(S32 x, S32 y, MASK mask) } else if (x < mBarRect.mLeft) { - LLTrace::TimeBlock* timer_id = getLegendID(y); + TimeBlock* timer_id = getLegendID(y); if (timer_id) { mHoverID = timer_id; @@ -317,9 +319,9 @@ BOOL LLFastTimerView::handleHover(S32 x, S32 y, MASK mask) } -static std::string get_tooltip(LLTrace::TimeBlock& timer, S32 history_index, LLTrace::PeriodicRecording& frame_recording) +static std::string get_tooltip(TimeBlock& timer, S32 history_index, PeriodicRecording& frame_recording) { - F64 ms_multiplier = 1000.0 / (F64)LLTrace::TimeBlock::countsPerSecond(); + F64 ms_multiplier = 1000.0 / (F64)TimeBlock::countsPerSecond(); std::string tooltip; if (history_index < 0) @@ -359,7 +361,7 @@ BOOL LLFastTimerView::handleToolTip(S32 x, S32 y, MASK mask) // tooltips for timer legend if (x < mBarRect.mLeft) { - LLTrace::TimeBlock* idp = getLegendID(y); + TimeBlock* idp = getLegendID(y); if (idp) { LLToolTipMgr::instance().show(get_tooltip(*idp, -1, *mRecording)); @@ -374,7 +376,7 @@ BOOL LLFastTimerView::handleToolTip(S32 x, S32 y, MASK mask) BOOL LLFastTimerView::handleScrollWheel(S32 x, S32 y, S32 clicks) { - LLTrace::PeriodicRecording& frame_recording = *mRecording; + PeriodicRecording& frame_recording = *mRecording; mPauseHistory = true; mScrollIndex = llclamp( mScrollIndex + clicks, @@ -383,15 +385,15 @@ BOOL LLFastTimerView::handleScrollWheel(S32 x, S32 y, S32 clicks) return TRUE; } -static LLTrace::TimeBlock FTM_RENDER_TIMER("Timers", true); +static TimeBlock FTM_RENDER_TIMER("Timers", true); -static std::map sTimerColors; +static std::map sTimerColors; void LLFastTimerView::draw() { LLFastTimer t(FTM_RENDER_TIMER); - LLTrace::PeriodicRecording& frame_recording = *mRecording; + PeriodicRecording& frame_recording = *mRecording; std::string tdesc; @@ -457,7 +459,7 @@ void LLFastTimerView::draw() it != timer_tree_iterator_t(); ++it) { - LLTrace::TimeBlock* idp = (*it); + TimeBlock* idp = (*it); const F32 HUE_INCREMENT = 0.23f; hue = fmodf(hue + HUE_INCREMENT, 1.f); @@ -480,12 +482,12 @@ void LLFastTimerView::draw() LLLocalClipRect clip(LLRect(margin, y, LEGEND_WIDTH, margin)); S32 cur_line = 0; ft_display_idx.clear(); - std::map display_line; + std::map display_line; for (timer_tree_iterator_t it = begin_timer_tree(getFrameTimer()); it != timer_tree_iterator_t(); ++it) { - LLTrace::TimeBlock* idp = (*it); + TimeBlock* idp = (*it); display_line[idp] = cur_line; ft_display_idx.push_back(idp); cur_line++; @@ -541,7 +543,7 @@ void LLFastTimerView::draw() x += dx; BOOL is_child_of_hover_item = (idp == mHoverID); - LLTrace::TimeBlock* next_parent = idp->getParent(); + TimeBlock* next_parent = idp->getParent(); while(!is_child_of_hover_item && next_parent) { is_child_of_hover_item = (mHoverID == next_parent); @@ -694,14 +696,14 @@ void LLFastTimerView::draw() std::vector deltax; xpos.push_back(x_start); - LLTrace::TimeBlock* prev_id = NULL; + TimeBlock* prev_id = NULL; S32 i = 0; for(timer_tree_iterator_t it = begin_timer_tree(getFrameTimer()); it != end_timer_tree(); ++it, ++i) { - LLTrace::TimeBlock* idp = (*it); + TimeBlock* idp = (*it); F32 frac = tidx == -1 ? (frame_recording.getPeriodMean(*idp) / total_time) : (frame_recording.getPrevRecordingPeriod(tidx).getSum(*idp).value() / total_time.value()); @@ -724,11 +726,11 @@ void LLFastTimerView::draw() sublevel_dx[level] = dx; sublevel_right[level] = sublevel_left[level] + sublevel_dx[level]; } - else if (prev_id && prev_id->getDepth() < get_depth(idp)) + else if (prev_id && get_depth(prev_id) < get_depth(idp)) { U64 sublevelticks = 0; - for (LLTrace::TimeBlock::child_const_iter it = prev_id->beginChildren(); + for (TimeBlock::child_const_iter it = prev_id->beginChildren(); it != prev_id->endChildren(); ++it) { @@ -770,7 +772,7 @@ void LLFastTimerView::draw() S32 scale_offset = 0; BOOL is_child_of_hover_item = (idp == mHoverID); - LLTrace::TimeBlock* next_parent = idp->getParent(); + TimeBlock* next_parent = idp->getParent(); while(!is_child_of_hover_item && next_parent) { is_child_of_hover_item = (mHoverID == next_parent); @@ -866,7 +868,7 @@ void LLFastTimerView::draw() it != end_timer_tree(); ++it) { - LLTrace::TimeBlock* idp = (*it); + TimeBlock* idp = (*it); //fatten highlighted timer if (mHoverID == idp) @@ -968,7 +970,7 @@ void LLFastTimerView::draw() it != end_timer_tree(); ++it) { - LLTrace::TimeBlock* idp = (*it); + TimeBlock* idp = (*it); if (!first) { @@ -990,7 +992,7 @@ void LLFastTimerView::draw() it != end_timer_tree(); ++it) { - LLTrace::TimeBlock* idp = (*it); + TimeBlock* idp = (*it); if (!first) { @@ -1527,13 +1529,13 @@ void LLFastTimerView::outputAllMetrics() //static void LLFastTimerView::doAnalysis(std::string baseline, std::string target, std::string output) { - if(LLTrace::TimeBlock::sLog) + if(TimeBlock::sLog) { doAnalysisDefault(baseline, target, output) ; return ; } - if(LLTrace::TimeBlock::sMetricLog) + if(TimeBlock::sMetricLog) { LLMetricPerformanceTesterBasic::doAnalysisMetrics(baseline, target, output) ; return ; @@ -1544,7 +1546,7 @@ void LLFastTimerView::onClickCloseBtn() setVisible(false); } -LLTrace::TimeBlock& LLFastTimerView::getFrameTimer() +TimeBlock& LLFastTimerView::getFrameTimer() { return FTM_FRAME; } -- cgit v1.2.3 From 90b5937c74f6712dfee1e90568d174a1aaca5ed7 Mon Sep 17 00:00:00 2001 From: Andrew Meadows Date: Thu, 10 Jan 2013 04:19:16 +0000 Subject: gcc fixes --- indra/newview/llfasttimerview.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'indra/newview/llfasttimerview.cpp') diff --git a/indra/newview/llfasttimerview.cpp b/indra/newview/llfasttimerview.cpp index 56e5710726..6409767285 100644 --- a/indra/newview/llfasttimerview.cpp +++ b/indra/newview/llfasttimerview.cpp @@ -514,7 +514,7 @@ void LLFastTimerView::draw() else { ms = LLUnit(frame_recording.getPeriodMean(*idp)); - calls = frame_recording.getPeriodMean(idp->callCount()); + calls = frame_recording.getPeriodMean((F32)idp->callCount()); } if (mDisplayCalls) @@ -736,7 +736,7 @@ void LLFastTimerView::draw() { sublevelticks += (tidx == -1) ? frame_recording.getPeriodMean(**it).value() - : frame_recording.getPrevRecordingPeriod(tidx).getSum(**it).value(); + : (U64)frame_recording.getPrevRecordingPeriod(tidx).getSum(**it).value(); } F32 subfrac = (F32)sublevelticks / (F32)total_time.value(); @@ -934,7 +934,7 @@ void LLFastTimerView::draw() max_time = llmax(LLUnit(1), LLUnit(cur_max)); } - max_calls = lerp((F32)max_calls, (F32) cur_max_calls, LLCriticalDamp::getInterpolant(0.1f)); + max_calls = llround(lerp((F32)max_calls, (F32) cur_max_calls, LLCriticalDamp::getInterpolant(0.1f))); if (llabs((S32)(max_calls - cur_max_calls)) <= 1) { max_calls = cur_max_calls; @@ -1011,7 +1011,7 @@ void LLFastTimerView::draw() } LLUnit ms = ticks; - timer_stat += llformat("%.1f",ms); + timer_stat += llformat("%.1f",ms.value()); if (idp->getCollapsed()) { -- cgit v1.2.3 From 27bec2b2f21f19a7c04707b03f83c8caa855872d Mon Sep 17 00:00:00 2001 From: Andrew Meadows Date: Thu, 10 Jan 2013 05:06:11 +0000 Subject: yet more gcc fixes --- indra/newview/llfasttimerview.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'indra/newview/llfasttimerview.cpp') diff --git a/indra/newview/llfasttimerview.cpp b/indra/newview/llfasttimerview.cpp index 6409767285..32ed662548 100644 --- a/indra/newview/llfasttimerview.cpp +++ b/indra/newview/llfasttimerview.cpp @@ -514,7 +514,7 @@ void LLFastTimerView::draw() else { ms = LLUnit(frame_recording.getPeriodMean(*idp)); - calls = frame_recording.getPeriodMean((F32)idp->callCount()); + calls = (S32)frame_recording.getPeriodMean((F32)idp->callCount()); } if (mDisplayCalls) @@ -728,7 +728,7 @@ void LLFastTimerView::draw() } else if (prev_id && get_depth(prev_id) < get_depth(idp)) { - U64 sublevelticks = 0; + F64 sublevelticks = 0; for (TimeBlock::child_const_iter it = prev_id->beginChildren(); it != prev_id->endChildren(); @@ -736,7 +736,7 @@ void LLFastTimerView::draw() { sublevelticks += (tidx == -1) ? frame_recording.getPeriodMean(**it).value() - : (U64)frame_recording.getPrevRecordingPeriod(tidx).getSum(**it).value(); + : frame_recording.getPrevRecordingPeriod(tidx).getSum(**it).value(); } F32 subfrac = (F32)sublevelticks / (F32)total_time.value(); -- cgit v1.2.3 From 44cc14fbee8c9cb033dcb94d9c54f532427a5768 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Fri, 11 Jan 2013 13:11:07 -0800 Subject: fix for mac builds --- indra/newview/llfasttimerview.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/newview/llfasttimerview.cpp') diff --git a/indra/newview/llfasttimerview.cpp b/indra/newview/llfasttimerview.cpp index 32ed662548..ba298ed819 100644 --- a/indra/newview/llfasttimerview.cpp +++ b/indra/newview/llfasttimerview.cpp @@ -514,7 +514,7 @@ void LLFastTimerView::draw() else { ms = LLUnit(frame_recording.getPeriodMean(*idp)); - calls = (S32)frame_recording.getPeriodMean((F32)idp->callCount()); + calls = (S32)frame_recording.getPeriodMean(idp->callCount()); } if (mDisplayCalls) -- cgit v1.2.3 From 096b2738c2213281b463d0de093c08a406f53946 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Thu, 24 Jan 2013 01:18:49 -0800 Subject: SH-3275 WIP interesting Update viewer metrics system to be more flexible clean up LLFastTimerView so it can be converted to handling LLTrace data --- indra/newview/llfasttimerview.cpp | 1924 +++++++++++++++++++------------------ 1 file changed, 969 insertions(+), 955 deletions(-) (limited to 'indra/newview/llfasttimerview.cpp') diff --git a/indra/newview/llfasttimerview.cpp b/indra/newview/llfasttimerview.cpp index ba298ed819..59a52fdaea 100644 --- a/indra/newview/llfasttimerview.cpp +++ b/indra/newview/llfasttimerview.cpp @@ -106,7 +106,9 @@ LLFastTimerView::LLFastTimerView(const LLSD& key) mPrintStats(-1), mRecording(&get_frame_recording()), mPauseHistory(false) -{} +{ + mBarRects = new std::vector[MAX_VISIBLE_HISTORY]; +} LLFastTimerView::~LLFastTimerView() { @@ -115,6 +117,7 @@ LLFastTimerView::~LLFastTimerView() delete mRecording; } mRecording = NULL; + delete [] mBarRects; } void LLFastTimerView::onPause() @@ -250,13 +253,11 @@ BOOL LLFastTimerView::handleMouseUp(S32 x, S32 y, MASK mask) BOOL LLFastTimerView::handleHover(S32 x, S32 y, MASK mask) { - PeriodicRecording& frame_recording = *mRecording; - if (hasMouseCapture()) { F32 lerp = llclamp(1.f - (F32) (x - mGraphRect.mLeft) / (F32) mGraphRect.getWidth(), 0.f, 1.f); mScrollIndex = llround( lerp * (F32)(HISTORY_NUM - MAX_VISIBLE_HISTORY)); - mScrollIndex = llclamp( mScrollIndex, 0, frame_recording.getNumPeriods()); + mScrollIndex = llclamp( mScrollIndex, 0, mRecording->getNumPeriods()); return TRUE; } mHoverTimer = NULL; @@ -281,8 +282,7 @@ BOOL LLFastTimerView::handleHover(S32 x, S32 y, MASK mask) ++it, ++i) { // is mouse over bar for this timer? - if (x > mBarStart[mHoverBarIndex][i] && - x < mBarEnd[mHoverBarIndex][i]) + if (mBarRects[mHoverBarIndex][i].pointInRect(x, y)) { mHoverID = (*it); if (mHoverTimer != *it) @@ -294,10 +294,7 @@ BOOL LLFastTimerView::handleHover(S32 x, S32 y, MASK mask) mHoverTimer = (*it); } - mToolTipRect.set(mBarStart[mHoverBarIndex][i], - mBarRect.mBottom + llround(((F32)(MAX_VISIBLE_HISTORY - mHoverBarIndex + 1)) * ((F32)mBarRect.getHeight() / ((F32)MAX_VISIBLE_HISTORY + 2.f))), - mBarEnd[mHoverBarIndex][i], - mBarRect.mBottom + llround((F32)(MAX_VISIBLE_HISTORY - mHoverBarIndex) * ((F32)mBarRect.getHeight() / ((F32)MAX_VISIBLE_HISTORY + 2.f)))); + mToolTipRect = mBarRects[mHoverBarIndex][i]; } if ((*it)->getCollapsed()) @@ -376,16 +373,16 @@ BOOL LLFastTimerView::handleToolTip(S32 x, S32 y, MASK mask) BOOL LLFastTimerView::handleScrollWheel(S32 x, S32 y, S32 clicks) { - PeriodicRecording& frame_recording = *mRecording; - mPauseHistory = true; mScrollIndex = llclamp( mScrollIndex + clicks, 0, - llmin(frame_recording.getNumPeriods(), (S32)HISTORY_NUM - MAX_VISIBLE_HISTORY)); + llmin(mRecording->getNumPeriods(), (S32)HISTORY_NUM - MAX_VISIBLE_HISTORY)); return TRUE; } static TimeBlock FTM_RENDER_TIMER("Timers", true); +static const S32 MARGIN = 10; +static const S32 LEGEND_WIDTH = 220; static std::map sTimerColors; @@ -393,574 +390,558 @@ void LLFastTimerView::draw() { LLFastTimer t(FTM_RENDER_TIMER); - PeriodicRecording& frame_recording = *mRecording; - - std::string tdesc; - - const S32 margin = 10; - const S32 height = getRect().getHeight(); - const S32 width = getRect().getWidth(); - - LLRect new_rect; - new_rect.setLeftTopAndSize(getRect().mLeft, getRect().mTop, width, height); - setRect(new_rect); - - S32 left, top, right, bottom; - S32 x, y, barw, barh, dx, dy; - const S32 texth = (S32)LLFontGL::getFontMonospace()->getLineHeight(); - LLPointer box_imagep = LLUI::getUIImage("Rounded_Square"); + generateUniqueColors(); // Draw the window background gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); - gl_rect_2d(0, getRect().getHeight(), getRect().getWidth(), 0, LLColor4(0.f, 0.f, 0.f, 0.25f)); - - // Draw some help - { - x = margin; - y = height - margin; - - char modedesc[][32] = { - "2 x Average ", - "Max ", - "Recent Max ", - "100 ms " - }; - char centerdesc[][32] = { - "Left ", - "Centered ", - "Ordered " - }; + gl_rect_2d(getLocalRect(), LLColor4(0.f, 0.f, 0.f, 0.25f)); - tdesc = llformat("Full bar = %s [Click to pause/reset] [SHIFT-Click to toggle]",modedesc[mDisplayMode]); - LLFontGL::getFontMonospace()->renderUTF8(tdesc, 0, x, y, LLColor4::white, LLFontGL::LEFT, LLFontGL::TOP); + S32 y = drawHelp(getRect().getHeight() - MARGIN); + drawLegend(y - ((S32)LLFontGL::getFontMonospace()->getLineHeight() - 2)); - x = margin, y -= (texth + 2); - tdesc = llformat("Justification = %s [CTRL-Click to toggle]",centerdesc[mDisplayCenter]); - LLFontGL::getFontMonospace()->renderUTF8(tdesc, 0, x, y, LLColor4::white, LLFontGL::LEFT, LLFontGL::TOP); - y -= (texth + 2); + // update rectangle that includes timer bars + const S32 LEGEND_WIDTH = 220; - LLFontGL::getFontMonospace()->renderUTF8(std::string("[Right-Click log selected] [ALT-Click toggle counts] [ALT-SHIFT-Click sub hidden]"), - 0, x, y, LLColor4::white, LLFontGL::LEFT, LLFontGL::TOP); - y -= (texth + 2); - } + mBarRect.mLeft = MARGIN + LEGEND_WIDTH + 8; + mBarRect.mTop = y; + mBarRect.mRight = getRect().getWidth() - MARGIN; + mBarRect.mBottom = MARGIN + LINE_GRAPH_HEIGHT; - S32 histmax = llmin(frame_recording.getNumPeriods()+1, MAX_VISIBLE_HISTORY); + drawBars(); + drawLineGraph(); + printLineStats(); + LLView::draw(); - const S32 ytop = y; - y -= (texth + 2); - - // generate unique colors - { - sTimerColors[&getFrameTimer()] = LLColor4::grey; - - F32 hue = 0.f; - - for (timer_tree_iterator_t it = begin_timer_tree(getFrameTimer()); - it != timer_tree_iterator_t(); - ++it) - { - TimeBlock* idp = (*it); - - const F32 HUE_INCREMENT = 0.23f; - hue = fmodf(hue + HUE_INCREMENT, 1.f); - // saturation increases with depth - F32 saturation = clamp_rescale((F32)get_depth(idp), 0.f, 3.f, 0.f, 1.f); - // lightness alternates with depth - F32 lightness = get_depth(idp) % 2 ? 0.5f : 0.6f; - - LLColor4 child_color; - child_color.setHSL(hue, saturation, lightness); + mAllTimeMax = llmax(mAllTimeMax, mRecording->getLastRecordingPeriod().getSum(getFrameTimer())); + mHoverID = NULL; + mHoverBarIndex = -1; +} - sTimerColors[idp] = child_color; - } - } +F64 LLFastTimerView::getTime(const std::string& name) +{ + //TODO: replace calls to this with use of timer object directly + //llstatic_assert(false, "TODO: implement"); + return 0.0; +} - // draw legend - const S32 LEGEND_WIDTH = 220; - const S32 x_start = margin + LEGEND_WIDTH + 8; - { - LLLocalClipRect clip(LLRect(margin, y, LEGEND_WIDTH, margin)); - S32 cur_line = 0; - ft_display_idx.clear(); - std::map display_line; - for (timer_tree_iterator_t it = begin_timer_tree(getFrameTimer()); - it != timer_tree_iterator_t(); - ++it) - { - TimeBlock* idp = (*it); - display_line[idp] = cur_line; - ft_display_idx.push_back(idp); - cur_line++; +void saveChart(const std::string& label, const char* suffix, LLImageRaw* scratch) +{ + //read result back into raw image + glReadPixels(0, 0, 1024, 512, GL_RGB, GL_UNSIGNED_BYTE, scratch->getData()); - x = margin; + //write results to disk + LLPointer result = new LLImagePNG(); + result->encode(scratch, 0.f); - left = x; right = x + texth; - top = y; bottom = y - texth; - S32 scale_offset = 0; - if (idp == mHoverID) - { - scale_offset = llfloor(sinf(mHighlightTimer.getElapsedTimeF32() * 6.f) * 2.f); - } - gl_rect_2d(left - scale_offset, top + scale_offset, right + scale_offset, bottom - scale_offset, sTimerColors[idp]); + std::string ext = result->getExtension(); + std::string filename = llformat("%s_%s.%s", label.c_str(), suffix, ext.c_str()); + + std::string out_file = gDirUtilp->getExpandedFilename(LL_PATH_LOGS, filename); + result->save(out_file); +} - LLUnit ms = 0; - S32 calls = 0; - if (mHoverBarIndex > 0 && mHoverID) - { - S32 hidx = mScrollIndex + mHoverBarIndex; - ms = frame_recording.getPrevRecordingPeriod(hidx).getSum(*idp); - calls = frame_recording.getPrevRecordingPeriod(hidx).getSum(idp->callCount()); - } - else - { - ms = LLUnit(frame_recording.getPeriodMean(*idp)); - calls = (S32)frame_recording.getPeriodMean(idp->callCount()); - } +//static +void LLFastTimerView::exportCharts(const std::string& base, const std::string& target) +{ + //allocate render target for drawing charts + LLRenderTarget buffer; + buffer.allocate(1024,512, GL_RGB, FALSE, FALSE); + - if (mDisplayCalls) - { - tdesc = llformat("%s (%d)",idp->getName().c_str(),calls); - } - else - { - tdesc = llformat("%s [%.1f]",idp->getName().c_str(),ms.value()); - } - dx = (texth+4) + get_depth(idp)*8; + LLSD cur; - LLColor4 color = LLColor4::white; - if (get_depth(idp) > 0) - { - S32 line_start_y = (top + bottom) / 2; - S32 line_end_y = line_start_y + ((texth + 2) * (cur_line - display_line[idp->getParent()])) - texth; - gl_line_2d(x + dx - 8, line_start_y, x + dx, line_start_y, color); - S32 line_x = x + (texth + 4) + ((get_depth(idp) - 1) * 8); - gl_line_2d(line_x, line_start_y, line_x, line_end_y, color); - if (idp->getCollapsed() && !idp->getChildren().empty()) - { - gl_line_2d(line_x+4, line_start_y-3, line_x+4, line_start_y+4, color); - } - } + LLSD base_data; - x += dx; - BOOL is_child_of_hover_item = (idp == mHoverID); - TimeBlock* next_parent = idp->getParent(); - while(!is_child_of_hover_item && next_parent) - { - is_child_of_hover_item = (mHoverID == next_parent); - if (next_parent->getParent() == next_parent) break; - next_parent = next_parent->getParent(); - } + { //read base log into memory + S32 i = 0; + std::ifstream is(base.c_str()); + while (!is.eof() && LLSDSerialize::fromXML(cur, is)) + { + base_data[i++] = cur; + } + is.close(); + } - LLFontGL::getFontMonospace()->renderUTF8(tdesc, 0, - x, y, - color, - LLFontGL::LEFT, LLFontGL::TOP, - is_child_of_hover_item ? LLFontGL::BOLD : LLFontGL::NORMAL); + LLSD cur_data; + std::set chart_names; - y -= (texth + 2); + { //read current log into memory + S32 i = 0; + std::ifstream is(target.c_str()); + while (!is.eof() && LLSDSerialize::fromXML(cur, is)) + { + cur_data[i++] = cur; - if (idp->getCollapsed()) + for (LLSD::map_iterator iter = cur.beginMap(); iter != cur.endMap(); ++iter) { - it.skipDescendants(); + std::string label = iter->first; + chart_names.insert(label); } } + is.close(); } - // update rectangle that includes timer bars - mBarRect.mLeft = x_start; - mBarRect.mRight = getRect().getWidth(); - mBarRect.mTop = ytop - (LLFontGL::getFontMonospace()->getLineHeight() + 4); - mBarRect.mBottom = margin + LINE_GRAPH_HEIGHT; - - y = ytop; - barh = (ytop - margin - LINE_GRAPH_HEIGHT) / (MAX_VISIBLE_HISTORY + 2); - dy = barh>>2; // spacing between bars - if (dy < 1) dy = 1; - barh -= dy; - barw = width - x_start - margin; - - // Draw the history bars - LLUnit total_time; - switch(mDisplayMode) + //get time domain + LLSD::Real cur_total_time = 0.0; + + for (U32 i = 0; i < cur_data.size(); ++i) { - case 0: - total_time = frame_recording.getPeriodMean(getFrameTimer())*2; - break; - case 1: - total_time = mAllTimeMax; - break; - case 2: - // Calculate the max total ticks for the current history - total_time = frame_recording.getPeriodMax(getFrameTimer()); - break; - default: - total_time = LLUnit(100); - break; + cur_total_time += cur_data[i]["Total"]["Time"].asReal(); } - if (total_time > 0) + LLSD::Real base_total_time = 0.0; + for (U32 i = 0; i < base_data.size(); ++i) { - LLLocalClipRect clip(LLRect(x_start, ytop, getRect().getWidth() - margin, margin)); - - mAllTimeMax = llmax(mAllTimeMax, frame_recording.getLastRecordingPeriod().getSum(getFrameTimer())); - - // Draw MS ticks - { - LLUnit ms = total_time; + base_total_time += base_data[i]["Total"]["Time"].asReal(); + } - tdesc = llformat("%.1f ms |", (F32)ms.value()*.25f); - x = x_start + barw/4 - LLFontGL::getFontMonospace()->getWidth(tdesc); - LLFontGL::getFontMonospace()->renderUTF8(tdesc, 0, x, y, LLColor4::white, - LLFontGL::LEFT, LLFontGL::TOP); - - tdesc = llformat("%.1f ms |", (F32)ms.value()*.50f); - x = x_start + barw/2 - LLFontGL::getFontMonospace()->getWidth(tdesc); - LLFontGL::getFontMonospace()->renderUTF8(tdesc, 0, x, y, LLColor4::white, - LLFontGL::LEFT, LLFontGL::TOP); - - tdesc = llformat("%.1f ms |", (F32)ms.value()*.75f); - x = x_start + (barw*3)/4 - LLFontGL::getFontMonospace()->getWidth(tdesc); - LLFontGL::getFontMonospace()->renderUTF8(tdesc, 0, x, y, LLColor4::white, - LLFontGL::LEFT, LLFontGL::TOP); - - tdesc = llformat( "%d ms |", (U32)ms.value()); - x = x_start + barw - LLFontGL::getFontMonospace()->getWidth(tdesc); - LLFontGL::getFontMonospace()->renderUTF8(tdesc, 0, x, y, LLColor4::white, - LLFontGL::LEFT, LLFontGL::TOP); - } + //allocate raw scratch space + LLPointer scratch = new LLImageRaw(1024, 512, 3); - // Draw borders - { - gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); - gGL.color4f(0.5f,0.5f,0.5f,0.5f); + gGL.pushMatrix(); + gGL.loadIdentity(); + gGL.matrixMode(LLRender::MM_PROJECTION); + gGL.loadIdentity(); + gGL.ortho(-0.05f, 1.05f, -0.05f, 1.05f, -1.0f, 1.0f); - S32 by = y + 2; - - y -= ((S32)LLFontGL::getFontMonospace()->getLineHeight() + 4); + //render charts + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); + + buffer.bindTarget(); - //heading - gl_rect_2d(x_start-5, by, getRect().getWidth()-5, y+5, FALSE); + for (std::set::iterator iter = chart_names.begin(); iter != chart_names.end(); ++iter) + { + std::string label = *iter; + + LLSD::Real max_time = 0.0; + LLSD::Integer max_calls = 0; + LLSD::Real max_execution = 0.0; - //tree view - gl_rect_2d(5, by, x_start-10, 5, FALSE); + std::vector cur_execution; + std::vector cur_times; + std::vector cur_calls; - by = y + 5; - //average bar - gl_rect_2d(x_start-5, by, getRect().getWidth()-5, by-barh-dy-5, FALSE); - - by -= barh*2+dy; - - //current frame bar - gl_rect_2d(x_start-5, by, getRect().getWidth()-5, by-barh-dy-2, FALSE); - - by -= barh+dy+1; - - //history bars - gl_rect_2d(x_start-5, by, getRect().getWidth()-5, LINE_GRAPH_HEIGHT-barh-dy-2, FALSE); - - by = LINE_GRAPH_HEIGHT-barh-dy-7; - - //line graph - mGraphRect = LLRect(x_start-5, by, getRect().getWidth()-5, 5); - - gl_rect_2d(mGraphRect, FALSE); - } - - mBarStart.clear(); - mBarEnd.clear(); + std::vector base_execution; + std::vector base_times; + std::vector base_calls; - // Draw bars for each history entry - // Special: -1 = show running average - gGL.getTexUnit(0)->bind(box_imagep->getImage()); - for (S32 j=-1; j LINE_GRAPH_HEIGHT; j++) + for (U32 i = 0; i < cur_data.size(); ++i) { - mBarStart.push_back(std::vector()); - mBarEnd.push_back(std::vector()); - int sublevel_dx[FTV_MAX_DEPTH]; - int sublevel_left[FTV_MAX_DEPTH]; - int sublevel_right[FTV_MAX_DEPTH]; - S32 tidx; - if (j >= 0) + LLSD::Real time = cur_data[i][label]["Time"].asReal(); + LLSD::Integer calls = cur_data[i][label]["Calls"].asInteger(); + + LLSD::Real execution = 0.0; + if (calls > 0) { - tidx = j + 1 + mScrollIndex; + execution = time/calls; + cur_execution.push_back(execution); + cur_times.push_back(time); } - else + + cur_calls.push_back(calls); + } + + for (U32 i = 0; i < base_data.size(); ++i) + { + LLSD::Real time = base_data[i][label]["Time"].asReal(); + LLSD::Integer calls = base_data[i][label]["Calls"].asInteger(); + + LLSD::Real execution = 0.0; + if (calls > 0) { - tidx = -1; + execution = time/calls; + base_execution.push_back(execution); + base_times.push_back(time); } - - x = x_start; - - // draw the bars for each stat - std::vector xpos; - std::vector deltax; - xpos.push_back(x_start); - - TimeBlock* prev_id = NULL; - S32 i = 0; - for(timer_tree_iterator_t it = begin_timer_tree(getFrameTimer()); - it != end_timer_tree(); - ++it, ++i) - { - TimeBlock* idp = (*it); - F32 frac = tidx == -1 - ? (frame_recording.getPeriodMean(*idp) / total_time) - : (frame_recording.getPrevRecordingPeriod(tidx).getSum(*idp).value() / total_time.value()); + base_calls.push_back(calls); + } + + std::sort(base_calls.begin(), base_calls.end()); + std::sort(base_times.begin(), base_times.end()); + std::sort(base_execution.begin(), base_execution.end()); + + std::sort(cur_calls.begin(), cur_calls.end()); + std::sort(cur_times.begin(), cur_times.end()); + std::sort(cur_execution.begin(), cur_execution.end()); + + //remove outliers + const U32 OUTLIER_CUTOFF = 512; + if (base_times.size() > OUTLIER_CUTOFF) + { + ll_remove_outliers(base_times, 1.f); + } + + if (base_execution.size() > OUTLIER_CUTOFF) + { + ll_remove_outliers(base_execution, 1.f); + } + + if (cur_times.size() > OUTLIER_CUTOFF) + { + ll_remove_outliers(cur_times, 1.f); + } + + if (cur_execution.size() > OUTLIER_CUTOFF) + { + ll_remove_outliers(cur_execution, 1.f); + } + + + max_time = llmax(base_times.empty() ? 0.0 : *base_times.rbegin(), cur_times.empty() ? 0.0 : *cur_times.rbegin()); + max_calls = llmax(base_calls.empty() ? 0 : *base_calls.rbegin(), cur_calls.empty() ? 0 : *cur_calls.rbegin()); + max_execution = llmax(base_execution.empty() ? 0.0 : *base_execution.rbegin(), cur_execution.empty() ? 0.0 : *cur_execution.rbegin()); + + + LLVector3 last_p; + + //==================================== + // basic + //==================================== + buffer.clear(); + + last_p.clear(); + + LLGLDisable cull(GL_CULL_FACE); + + LLVector3 base_col(0, 0.7f, 0.f); + LLVector3 cur_col(1.f, 0.f, 0.f); + + gGL.setSceneBlendType(LLRender::BT_ADD); + + gGL.color3fv(base_col.mV); + for (U32 i = 0; i < base_times.size(); ++i) + { + gGL.begin(LLRender::TRIANGLE_STRIP); + gGL.vertex3fv(last_p.mV); + gGL.vertex3f(last_p.mV[0], 0.f, 0.f); + last_p.set((F32)i/(F32) base_times.size(), base_times[i]/max_time, 0.f); + gGL.vertex3fv(last_p.mV); + gGL.vertex3f(last_p.mV[0], 0.f, 0.f); + gGL.end(); + } - dx = llround(frac * (F32)barw); - S32 prev_delta_x = deltax.empty() ? 0 : deltax.back(); - deltax.push_back(dx); - - int level = get_depth(idp) - 1; - - while ((S32)xpos.size() > level + 1) - { - xpos.pop_back(); - } - left = xpos.back(); + gGL.flush(); + + + last_p.clear(); + { + LLGLEnable blend(GL_BLEND); + + gGL.color3fv(cur_col.mV); + for (U32 i = 0; i < cur_times.size(); ++i) + { + gGL.begin(LLRender::TRIANGLE_STRIP); + gGL.vertex3f(last_p.mV[0], 0.f, 0.f); + gGL.vertex3fv(last_p.mV); + last_p.set((F32) i / (F32) cur_times.size(), cur_times[i]/max_time, 0.f); + gGL.vertex3f(last_p.mV[0], 0.f, 0.f); + gGL.vertex3fv(last_p.mV); + gGL.end(); + } + + gGL.flush(); + } + + saveChart(label, "time", scratch); + + //====================================== + // calls + //====================================== + buffer.clear(); + + last_p.clear(); + + gGL.color3fv(base_col.mV); + for (U32 i = 0; i < base_calls.size(); ++i) + { + gGL.begin(LLRender::TRIANGLE_STRIP); + gGL.vertex3fv(last_p.mV); + gGL.vertex3f(last_p.mV[0], 0.f, 0.f); + last_p.set((F32) i / (F32) base_calls.size(), (F32)base_calls[i]/max_calls, 0.f); + gGL.vertex3fv(last_p.mV); + gGL.vertex3f(last_p.mV[0], 0.f, 0.f); + gGL.end(); + } + + gGL.flush(); + + { + LLGLEnable blend(GL_BLEND); + gGL.color3fv(cur_col.mV); + last_p.clear(); + + for (U32 i = 0; i < cur_calls.size(); ++i) + { + gGL.begin(LLRender::TRIANGLE_STRIP); + gGL.vertex3f(last_p.mV[0], 0.f, 0.f); + gGL.vertex3fv(last_p.mV); + last_p.set((F32) i / (F32) cur_calls.size(), (F32) cur_calls[i]/max_calls, 0.f); + gGL.vertex3f(last_p.mV[0], 0.f, 0.f); + gGL.vertex3fv(last_p.mV); + gGL.end(); - if (level == 0) - { - sublevel_left[level] = x_start; - sublevel_dx[level] = dx; - sublevel_right[level] = sublevel_left[level] + sublevel_dx[level]; - } - else if (prev_id && get_depth(prev_id) < get_depth(idp)) - { - F64 sublevelticks = 0; - - for (TimeBlock::child_const_iter it = prev_id->beginChildren(); - it != prev_id->endChildren(); - ++it) - { - sublevelticks += (tidx == -1) - ? frame_recording.getPeriodMean(**it).value() - : frame_recording.getPrevRecordingPeriod(tidx).getSum(**it).value(); - } - - F32 subfrac = (F32)sublevelticks / (F32)total_time.value(); - sublevel_dx[level] = (int)(subfrac * (F32)barw + .5f); - - if (mDisplayCenter == ALIGN_CENTER) - { - left += (prev_delta_x - sublevel_dx[level])/2; - } - else if (mDisplayCenter == ALIGN_RIGHT) - { - left += (prev_delta_x - sublevel_dx[level]); - } - - sublevel_left[level] = left; - sublevel_right[level] = sublevel_left[level] + sublevel_dx[level]; - } - - right = left + dx; - xpos.back() = right; - xpos.push_back(left); + } + + gGL.flush(); + } + + saveChart(label, "calls", scratch); + + //====================================== + // execution + //====================================== + buffer.clear(); + + + gGL.color3fv(base_col.mV); + U32 count = 0; + U32 total_count = base_execution.size(); + + last_p.clear(); + + for (std::vector::iterator iter = base_execution.begin(); iter != base_execution.end(); ++iter) + { + gGL.begin(LLRender::TRIANGLE_STRIP); + gGL.vertex3fv(last_p.mV); + gGL.vertex3f(last_p.mV[0], 0.f, 0.f); + last_p.set((F32)count/(F32)total_count, *iter/max_execution, 0.f); + gGL.vertex3fv(last_p.mV); + gGL.vertex3f(last_p.mV[0], 0.f, 0.f); + gGL.end(); + count++; + } + + last_p.clear(); - mBarStart.back().push_back(left); - mBarEnd.back().push_back(right); + { + LLGLEnable blend(GL_BLEND); + gGL.color3fv(cur_col.mV); + count = 0; + total_count = cur_execution.size(); + + for (std::vector::iterator iter = cur_execution.begin(); iter != cur_execution.end(); ++iter) + { + gGL.begin(LLRender::TRIANGLE_STRIP); + gGL.vertex3f(last_p.mV[0], 0.f, 0.f); + gGL.vertex3fv(last_p.mV); + last_p.set((F32)count/(F32)total_count, *iter/max_execution, 0.f); + gGL.vertex3f(last_p.mV[0], 0.f, 0.f); + gGL.vertex3fv(last_p.mV); + gGL.end(); + count++; + } - top = y; - bottom = y - barh; + gGL.flush(); + } - if (right > left) - { - //U32 rounded_edges = 0; - LLColor4 color = sTimerColors[idp];//*ft_display_table[i].color; - S32 scale_offset = 0; - - BOOL is_child_of_hover_item = (idp == mHoverID); - TimeBlock* next_parent = idp->getParent(); - while(!is_child_of_hover_item && next_parent) - { - is_child_of_hover_item = (mHoverID == next_parent); - if (next_parent->getParent() == next_parent) break; - next_parent = next_parent->getParent(); - } - - if (idp == mHoverID) - { - scale_offset = llfloor(sinf(mHighlightTimer.getElapsedTimeF32() * 6.f) * 3.f); - //color = lerp(color, LLColor4::black, -0.4f); - } - else if (mHoverID != NULL && !is_child_of_hover_item) - { - color = lerp(color, LLColor4::grey, 0.8f); - } - - gGL.color4fv(color.mV); - F32 start_fragment = llclamp((F32)(left - sublevel_left[level]) / (F32)sublevel_dx[level], 0.f, 1.f); - F32 end_fragment = llclamp((F32)(right - sublevel_left[level]) / (F32)sublevel_dx[level], 0.f, 1.f); - gl_segmented_rect_2d_fragment_tex(sublevel_left[level], top - level + scale_offset, sublevel_right[level], bottom + level - scale_offset, box_imagep->getTextureWidth(), box_imagep->getTextureHeight(), 16, start_fragment, end_fragment); + saveChart(label, "execution", scratch); + } - } + buffer.flush(); - if ((*it)->getCollapsed()) - { - it.skipDescendants(); - } - - prev_id = idp; + gGL.popMatrix(); + gGL.matrixMode(LLRender::MM_MODELVIEW); + gGL.popMatrix(); +} + +//static +LLSD LLFastTimerView::analyzePerformanceLogDefault(std::istream& is) +{ + LLSD ret; + + LLSD cur; + + LLSD::Real total_time = 0.0; + LLSD::Integer total_frames = 0; + + typedef std::map stats_map_t; + stats_map_t time_stats; + stats_map_t sample_stats; + + while (!is.eof() && LLSDSerialize::fromXML(cur, is)) + { + for (LLSD::map_iterator iter = cur.beginMap(); iter != cur.endMap(); ++iter) + { + std::string label = iter->first; + + F64 time = iter->second["Time"].asReal(); + + // Skip the total figure + if(label.compare("Total") != 0) + { + total_time += time; + } + + if (time > 0.0) + { + LLSD::Integer samples = iter->second["Calls"].asInteger(); + + time_stats[label].push(time); + sample_stats[label].push(samples); } - y -= (barh + dy); - if (j < 0) - y -= barh; } + total_frames++; + } + + for(stats_map_t::iterator it = time_stats.begin(); it != time_stats.end(); ++it) + { + std::string label = it->first; + ret[label]["TotalTime"] = time_stats[label].mSum; + ret[label]["MeanTime"] = time_stats[label].getMean(); + ret[label]["MaxTime"] = time_stats[label].getMaxValue(); + ret[label]["MinTime"] = time_stats[label].getMinValue(); + ret[label]["StdDevTime"] = time_stats[label].getStdDev(); + + ret[label]["Samples"] = sample_stats[label].mSum; + ret[label]["MaxSamples"] = sample_stats[label].getMaxValue(); + ret[label]["MinSamples"] = sample_stats[label].getMinValue(); + ret[label]["StdDevSamples"] = sample_stats[label].getStdDev(); + + ret[label]["Frames"] = (LLSD::Integer)time_stats[label].getCount(); } + + ret["SessionTime"] = total_time; + ret["FrameCount"] = total_frames; + + return ret; + +} + +//static +void LLFastTimerView::doAnalysisDefault(std::string baseline, std::string target, std::string output) +{ + // Open baseline and current target, exit if one is inexistent + std::ifstream base_is(baseline.c_str()); + std::ifstream target_is(target.c_str()); + if (!base_is.is_open() || !target_is.is_open()) + { + llwarns << "'-analyzeperformance' error : baseline or current target file inexistent" << llendl; + base_is.close(); + target_is.close(); + return; + } + + //analyze baseline + LLSD base = analyzePerformanceLogDefault(base_is); + base_is.close(); + + //analyze current + LLSD current = analyzePerformanceLogDefault(target_is); + target_is.close(); + + //output comparision + std::ofstream os(output.c_str()); + + LLSD::Real session_time = current["SessionTime"].asReal(); + os << + "Label, " + "% Change, " + "% of Session, " + "Cur Min, " + "Cur Max, " + "Cur Mean/sample, " + "Cur Mean/frame, " + "Cur StdDev/frame, " + "Cur Total, " + "Cur Frames, " + "Cur Samples, " + "Base Min, " + "Base Max, " + "Base Mean/sample, " + "Base Mean/frame, " + "Base StdDev/frame, " + "Base Total, " + "Base Frames, " + "Base Samples\n"; - //draw line graph history + for (LLSD::map_iterator iter = base.beginMap(); iter != base.endMap(); ++iter) { - gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); - LLLocalClipRect clip(mGraphRect); - - //normalize based on last frame's maximum - static LLUnit max_time = 0.000001; - static U32 max_calls = 0; - static F32 alpha_interp = 0.f; - - //display y-axis range - std::string tdesc; - if (mDisplayCalls) - tdesc = llformat("%d calls", (int)max_calls); - else if (mDisplayHz) - tdesc = llformat("%d Hz", (int)(1.f / max_time.value())); - else - tdesc = llformat("%4.2f ms", max_time.value()); - - x = mGraphRect.mRight - LLFontGL::getFontMonospace()->getWidth(tdesc)-5; - y = mGraphRect.mTop - LLFontGL::getFontMonospace()->getLineHeight(); - - LLFontGL::getFontMonospace()->renderUTF8(tdesc, 0, x, y, LLColor4::white, - LLFontGL::LEFT, LLFontGL::TOP); - - //highlight visible range - { - S32 first_frame = HISTORY_NUM - mScrollIndex; - S32 last_frame = first_frame - MAX_VISIBLE_HISTORY; - - F32 frame_delta = ((F32) (mGraphRect.getWidth()))/(HISTORY_NUM-1); - - F32 right = (F32) mGraphRect.mLeft + frame_delta*first_frame; - F32 left = (F32) mGraphRect.mLeft + frame_delta*last_frame; - - gGL.color4f(0.5f,0.5f,0.5f,0.3f); - gl_rect_2d((S32) left, mGraphRect.mTop, (S32) right, mGraphRect.mBottom); - - if (mHoverBarIndex >= 0) - { - S32 bar_frame = first_frame - mHoverBarIndex; - F32 bar = (F32) mGraphRect.mLeft + frame_delta*bar_frame; + LLSD::String label = iter->first; - gGL.color4f(0.5f,0.5f,0.5f,1); - - gGL.begin(LLRender::LINES); - gGL.vertex2i((S32)bar, mGraphRect.mBottom); - gGL.vertex2i((S32)bar, mGraphRect.mTop); - gGL.end(); - } - } - - LLUnit cur_max = 0; - U32 cur_max_calls = 0; - for(timer_tree_iterator_t it = begin_timer_tree(getFrameTimer()); - it != end_timer_tree(); - ++it) + if (current[label]["Samples"].asInteger() == 0 || + base[label]["Samples"].asInteger() == 0) { - TimeBlock* idp = (*it); - - //fatten highlighted timer - if (mHoverID == idp) - { - gGL.flush(); - glLineWidth(3); - } + //cannot compare + continue; + } + LLSD::Real a = base[label]["TotalTime"].asReal() / base[label]["Samples"].asReal(); + LLSD::Real b = current[label]["TotalTime"].asReal() / current[label]["Samples"].asReal(); - const F32 * col = sTimerColors[idp].mV;// ft_display_table[idx].color->mV; - - F32 alpha = 1.f; - - if (mHoverID != NULL && - idp != mHoverID) - { //fade out non-highlighted timers - if (idp->getParent() != mHoverID) - { - alpha = alpha_interp; - } - } + LLSD::Real diff = b-a; - gGL.color4f(col[0], col[1], col[2], alpha); - gGL.begin(LLRender::TRIANGLE_STRIP); - for (U32 j = frame_recording.getNumPeriods(); - j > 0; - j--) - { - LLUnit time = llmax(frame_recording.getPrevRecordingPeriod(j).getSum(*idp), LLUnit(0.000001)); - U32 calls = frame_recording.getPrevRecordingPeriod(j).getSum(idp->callCount()); - - if (alpha == 1.f) - { - //normalize to highlighted timer - cur_max = llmax(cur_max, time); - cur_max_calls = llmax(cur_max_calls, calls); - } - F32 x = mGraphRect.mRight - j * (F32)(mGraphRect.getWidth())/(HISTORY_NUM-1); - F32 y = mDisplayHz - ? mGraphRect.mBottom + (1.f / time.value()) * ((F32) mGraphRect.getHeight() / (1.f / max_time.value())) - : mGraphRect.mBottom + time / max_time * (F32)mGraphRect.getHeight(); - gGL.vertex2f(x,y); - gGL.vertex2f(x,mGraphRect.mBottom); - } - gGL.end(); - - if (mHoverID == idp) - { - gGL.flush(); - glLineWidth(1); - } + LLSD::Real perc = diff/a * 100; - if (idp->getCollapsed()) - { - //skip hidden timers - it.skipDescendants(); - } - } - - //interpolate towards new maximum - max_time = lerp(max_time.value(), cur_max.value(), LLCriticalDamp::getInterpolant(0.1f)); - if (max_time - cur_max <= 1 || cur_max - max_time <= 1) - { - max_time = llmax(LLUnit(1), LLUnit(cur_max)); - } + os << llformat("%s, %.2f, %.4f, %.4f, %.4f, %.4f, %.4f, %.4f, %.4f, %d, %d, %.4f, %.4f, %.4f, %.4f, %.4f, %.4f, %d, %d\n", + label.c_str(), + (F32) perc, + (F32) (current[label]["TotalTime"].asReal()/session_time * 100.0), - max_calls = llround(lerp((F32)max_calls, (F32) cur_max_calls, LLCriticalDamp::getInterpolant(0.1f))); - if (llabs((S32)(max_calls - cur_max_calls)) <= 1) - { - max_calls = cur_max_calls; - } + (F32) current[label]["MinTime"].asReal(), + (F32) current[label]["MaxTime"].asReal(), + (F32) b, + (F32) current[label]["MeanTime"].asReal(), + (F32) current[label]["StdDevTime"].asReal(), + (F32) current[label]["TotalTime"].asReal(), + current[label]["Frames"].asInteger(), + current[label]["Samples"].asInteger(), + (F32) base[label]["MinTime"].asReal(), + (F32) base[label]["MaxTime"].asReal(), + (F32) a, + (F32) base[label]["MeanTime"].asReal(), + (F32) base[label]["StdDevTime"].asReal(), + (F32) base[label]["TotalTime"].asReal(), + base[label]["Frames"].asInteger(), + base[label]["Samples"].asInteger()); + } - // TODO: make sure alpha is correct in DisplayHz mode - F32 alpha_target = (max_time > cur_max) - ? llmin(max_time / cur_max - 1.f,1.f) - : llmin(cur_max/ max_time - 1.f,1.f); - alpha_interp = lerp(alpha_interp, alpha_target, LLCriticalDamp::getInterpolant(0.1f)); + exportCharts(baseline, target); + + os.flush(); + os.close(); +} - if (mHoverID != NULL) +//static +void LLFastTimerView::outputAllMetrics() +{ + if (LLMetricPerformanceTesterBasic::hasMetricPerformanceTesters()) + { + for (LLMetricPerformanceTesterBasic::name_tester_map_t::iterator iter = LLMetricPerformanceTesterBasic::sTesterMap.begin(); + iter != LLMetricPerformanceTesterBasic::sTesterMap.end(); ++iter) { - x = (mGraphRect.mRight + mGraphRect.mLeft)/2; - y = mGraphRect.mBottom + 8; + LLMetricPerformanceTesterBasic* tester = ((LLMetricPerformanceTesterBasic*)iter->second); + tester->outputTestResults(); + } + } +} - LLFontGL::getFontMonospace()->renderUTF8( - mHoverID->getName(), - 0, - x, y, - LLColor4::white, - LLFontGL::LEFT, LLFontGL::BOTTOM); - } +//static +void LLFastTimerView::doAnalysis(std::string baseline, std::string target, std::string output) +{ + if(TimeBlock::sLog) + { + doAnalysisDefault(baseline, target, output) ; + return ; + } + + if(TimeBlock::sMetricLog) + { + LLMetricPerformanceTesterBasic::doAnalysisMetrics(baseline, target, output) ; + return ; } +} +void LLFastTimerView::onClickCloseBtn() +{ + setVisible(false); +} +TimeBlock& LLFastTimerView::getFrameTimer() +{ + return FTM_FRAME; +} +void LLFastTimerView::printLineStats() +{ // Output stats for clicked bar to log if (mPrintStats >= 0) { @@ -1003,11 +984,11 @@ void LLFastTimerView::draw() LLUnit ticks; if (mPrintStats > 0) { - ticks = frame_recording.getPrevRecordingPeriod(mPrintStats).getSum(*idp); + ticks = mRecording->getPrevRecordingPeriod(mPrintStats).getSum(*idp); } else { - ticks = frame_recording.getPeriodMean(*idp); + ticks = mRecording->getPeriodMean(*idp); } LLUnit ms = ticks; @@ -1021,534 +1002,567 @@ void LLFastTimerView::draw() llinfos << timer_stat << llendl; mPrintStats = -1; } - - mHoverID = NULL; - mHoverBarIndex = -1; - - LLView::draw(); -} - -F64 LLFastTimerView::getTime(const std::string& name) -{ - //TODO: replace calls to this with use of timer object directly - //llstatic_assert(false, "TODO: implement"); - return 0.0; -} - -void saveChart(const std::string& label, const char* suffix, LLImageRaw* scratch) -{ - //read result back into raw image - glReadPixels(0, 0, 1024, 512, GL_RGB, GL_UNSIGNED_BYTE, scratch->getData()); - - //write results to disk - LLPointer result = new LLImagePNG(); - result->encode(scratch, 0.f); - - std::string ext = result->getExtension(); - std::string filename = llformat("%s_%s.%s", label.c_str(), suffix, ext.c_str()); - - std::string out_file = gDirUtilp->getExpandedFilename(LL_PATH_LOGS, filename); - result->save(out_file); } -//static -void LLFastTimerView::exportCharts(const std::string& base, const std::string& target) +void LLFastTimerView::drawLineGraph() { - //allocate render target for drawing charts - LLRenderTarget buffer; - buffer.allocate(1024,512, GL_RGB, FALSE, FALSE); - - - LLSD cur; - - LLSD base_data; - - { //read base log into memory - S32 i = 0; - std::ifstream is(base.c_str()); - while (!is.eof() && LLSDSerialize::fromXML(cur, is)) - { - base_data[i++] = cur; - } - is.close(); - } - - LLSD cur_data; - std::set chart_names; - - { //read current log into memory - S32 i = 0; - std::ifstream is(target.c_str()); - while (!is.eof() && LLSDSerialize::fromXML(cur, is)) - { - cur_data[i++] = cur; - - for (LLSD::map_iterator iter = cur.beginMap(); iter != cur.endMap(); ++iter) - { - std::string label = iter->first; - chart_names.insert(label); - } - } - is.close(); - } - - //get time domain - LLSD::Real cur_total_time = 0.0; - - for (U32 i = 0; i < cur_data.size(); ++i) - { - cur_total_time += cur_data[i]["Total"]["Time"].asReal(); - } - - LLSD::Real base_total_time = 0.0; - for (U32 i = 0; i < base_data.size(); ++i) - { - base_total_time += base_data[i]["Total"]["Time"].asReal(); - } - - //allocate raw scratch space - LLPointer scratch = new LLImageRaw(1024, 512, 3); - - gGL.pushMatrix(); - gGL.loadIdentity(); - gGL.matrixMode(LLRender::MM_PROJECTION); - gGL.loadIdentity(); - gGL.ortho(-0.05f, 1.05f, -0.05f, 1.05f, -1.0f, 1.0f); - - //render charts + //draw line graph history + S32 x = mBarRect.mLeft; + S32 y = LINE_GRAPH_HEIGHT; gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); - - buffer.bindTarget(); - - for (std::set::iterator iter = chart_names.begin(); iter != chart_names.end(); ++iter) - { - std::string label = *iter; - - LLSD::Real max_time = 0.0; - LLSD::Integer max_calls = 0; - LLSD::Real max_execution = 0.0; - - std::vector cur_execution; - std::vector cur_times; - std::vector cur_calls; + LLLocalClipRect clip(mGraphRect); + + //normalize based on last frame's maximum + static LLUnit max_time = 0.000001; + static U32 max_calls = 0; + static F32 alpha_interp = 0.f; + + //display y-axis range + std::string axis_label; + if (mDisplayCalls) + axis_label = llformat("%d calls", (int)max_calls); + else if (mDisplayHz) + axis_label = llformat("%d Hz", (int)(1.f / max_time.value())); + else + axis_label = llformat("%4.2f ms", max_time.value()); - std::vector base_execution; - std::vector base_times; - std::vector base_calls; + x = mGraphRect.mRight - LLFontGL::getFontMonospace()->getWidth(axis_label)-5; + y = mGraphRect.mTop - LLFontGL::getFontMonospace()->getLineHeight(); - for (U32 i = 0; i < cur_data.size(); ++i) - { - LLSD::Real time = cur_data[i][label]["Time"].asReal(); - LLSD::Integer calls = cur_data[i][label]["Calls"].asInteger(); + LLFontGL::getFontMonospace()->renderUTF8(axis_label, 0, x, y, LLColor4::white, + LLFontGL::LEFT, LLFontGL::TOP); - LLSD::Real execution = 0.0; - if (calls > 0) - { - execution = time/calls; - cur_execution.push_back(execution); - cur_times.push_back(time); - } + //highlight visible range + { + S32 first_frame = HISTORY_NUM - mScrollIndex; + S32 last_frame = first_frame - MAX_VISIBLE_HISTORY; - cur_calls.push_back(calls); - } + F32 frame_delta = ((F32) (mGraphRect.getWidth()))/(HISTORY_NUM-1); - for (U32 i = 0; i < base_data.size(); ++i) + F32 right = (F32) mGraphRect.mLeft + frame_delta*first_frame; + F32 left = (F32) mGraphRect.mLeft + frame_delta*last_frame; + + gGL.color4f(0.5f,0.5f,0.5f,0.3f); + gl_rect_2d((S32) left, mGraphRect.mTop, (S32) right, mGraphRect.mBottom); + + if (mHoverBarIndex >= 0) { - LLSD::Real time = base_data[i][label]["Time"].asReal(); - LLSD::Integer calls = base_data[i][label]["Calls"].asInteger(); + S32 bar_frame = first_frame - mHoverBarIndex; + F32 bar = (F32) mGraphRect.mLeft + frame_delta*bar_frame; - LLSD::Real execution = 0.0; - if (calls > 0) - { - execution = time/calls; - base_execution.push_back(execution); - base_times.push_back(time); - } + gGL.color4f(0.5f,0.5f,0.5f,1); - base_calls.push_back(calls); + gGL.begin(LLRender::LINES); + gGL.vertex2i((S32)bar, mGraphRect.mBottom); + gGL.vertex2i((S32)bar, mGraphRect.mTop); + gGL.end(); } + } - std::sort(base_calls.begin(), base_calls.end()); - std::sort(base_times.begin(), base_times.end()); - std::sort(base_execution.begin(), base_execution.end()); + LLUnit cur_max = 0; + U32 cur_max_calls = 0; + for(timer_tree_iterator_t it = begin_timer_tree(getFrameTimer()); + it != end_timer_tree(); + ++it) + { + TimeBlock* idp = (*it); - std::sort(cur_calls.begin(), cur_calls.end()); - std::sort(cur_times.begin(), cur_times.end()); - std::sort(cur_execution.begin(), cur_execution.end()); + //fatten highlighted timer + if (mHoverID == idp) + { + gGL.flush(); + glLineWidth(3); + } - //remove outliers - const U32 OUTLIER_CUTOFF = 512; - if (base_times.size() > OUTLIER_CUTOFF) - { - ll_remove_outliers(base_times, 1.f); + const F32 * col = sTimerColors[idp].mV;// ft_display_table[idx].color->mV; + + F32 alpha = 1.f; + + if (mHoverID != NULL && + idp != mHoverID) + { //fade out non-highlighted timers + if (idp->getParent() != mHoverID) + { + alpha = alpha_interp; + } } - if (base_execution.size() > OUTLIER_CUTOFF) - { - ll_remove_outliers(base_execution, 1.f); + gGL.color4f(col[0], col[1], col[2], alpha); + gGL.begin(LLRender::TRIANGLE_STRIP); + for (U32 j = mRecording->getNumPeriods(); + j > 0; + j--) + { + LLUnit time = llmax(mRecording->getPrevRecordingPeriod(j).getSum(*idp), LLUnit(0.000001)); + U32 calls = mRecording->getPrevRecordingPeriod(j).getSum(idp->callCount()); + + if (alpha == 1.f) + { + //normalize to highlighted timer + cur_max = llmax(cur_max, time); + cur_max_calls = llmax(cur_max_calls, calls); + } + F32 x = mGraphRect.mRight - j * (F32)(mGraphRect.getWidth())/(HISTORY_NUM-1); + F32 y = mDisplayHz + ? mGraphRect.mBottom + (1.f / time.value()) * ((F32) mGraphRect.getHeight() / (1.f / max_time.value())) + : mGraphRect.mBottom + time / max_time * (F32)mGraphRect.getHeight(); + gGL.vertex2f(x,y); + gGL.vertex2f(x,mGraphRect.mBottom); } + gGL.end(); - if (cur_times.size() > OUTLIER_CUTOFF) - { - ll_remove_outliers(cur_times, 1.f); + if (mHoverID == idp) + { + gGL.flush(); + glLineWidth(1); } - if (cur_execution.size() > OUTLIER_CUTOFF) - { - ll_remove_outliers(cur_execution, 1.f); + if (idp->getCollapsed()) + { + //skip hidden timers + it.skipDescendants(); } + } + //interpolate towards new maximum + max_time = lerp(max_time.value(), cur_max.value(), LLCriticalDamp::getInterpolant(0.1f)); + if (max_time - cur_max <= 1 || cur_max - max_time <= 1) + { + max_time = llmax(LLUnit(1), LLUnit(cur_max)); + } - max_time = llmax(base_times.empty() ? 0.0 : *base_times.rbegin(), cur_times.empty() ? 0.0 : *cur_times.rbegin()); - max_calls = llmax(base_calls.empty() ? 0 : *base_calls.rbegin(), cur_calls.empty() ? 0 : *cur_calls.rbegin()); - max_execution = llmax(base_execution.empty() ? 0.0 : *base_execution.rbegin(), cur_execution.empty() ? 0.0 : *cur_execution.rbegin()); + max_calls = llround(lerp((F32)max_calls, (F32) cur_max_calls, LLCriticalDamp::getInterpolant(0.1f))); + if (llabs((S32)(max_calls - cur_max_calls)) <= 1) + { + max_calls = cur_max_calls; + } + // TODO: make sure alpha is correct in DisplayHz mode + F32 alpha_target = (max_time > cur_max) + ? llmin(max_time / cur_max - 1.f,1.f) + : llmin(cur_max/ max_time - 1.f,1.f); + alpha_interp = lerp(alpha_interp, alpha_target, LLCriticalDamp::getInterpolant(0.1f)); - LLVector3 last_p; + if (mHoverID != NULL) + { + x = (mGraphRect.mRight + mGraphRect.mLeft)/2; + y = mGraphRect.mBottom + 8; + + LLFontGL::getFontMonospace()->renderUTF8( + mHoverID->getName(), + 0, + x, y, + LLColor4::white, + LLFontGL::LEFT, LLFontGL::BOTTOM); + } +} - //==================================== - // basic - //==================================== - buffer.clear(); +void LLFastTimerView::drawLegend( S32 y ) +{ + // draw legend + S32 dx; + S32 x = MARGIN; + const S32 TEXT_HEIGHT = (S32)LLFontGL::getFontMonospace()->getLineHeight(); - last_p.clear(); + { + LLLocalClipRect clip(LLRect(MARGIN, y, LEGEND_WIDTH, MARGIN)); + S32 cur_line = 0; + ft_display_idx.clear(); + std::map display_line; + for (timer_tree_iterator_t it = begin_timer_tree(getFrameTimer()); + it != timer_tree_iterator_t(); + ++it) + { + TimeBlock* idp = (*it); + display_line[idp] = cur_line; + ft_display_idx.push_back(idp); + cur_line++; - LLGLDisable cull(GL_CULL_FACE); + x = MARGIN; - LLVector3 base_col(0, 0.7f, 0.f); - LLVector3 cur_col(1.f, 0.f, 0.f); + LLRect bar_rect(x, y, x + TEXT_HEIGHT, y - TEXT_HEIGHT); + S32 scale_offset = 0; + if (idp == mHoverID) + { + scale_offset = llfloor(sinf(mHighlightTimer.getElapsedTimeF32() * 6.f) * 2.f); + } + bar_rect.stretch(scale_offset); + gl_rect_2d(bar_rect, sTimerColors[idp]); - gGL.setSceneBlendType(LLRender::BT_ADD); + LLUnit ms = 0; + S32 calls = 0; + if (mHoverBarIndex > 0 && mHoverID) + { + S32 hidx = mScrollIndex + mHoverBarIndex; + ms = mRecording->getPrevRecordingPeriod(hidx).getSum(*idp); + calls = mRecording->getPrevRecordingPeriod(hidx).getSum(idp->callCount()); + } + else + { + ms = LLUnit(mRecording->getPeriodMean(*idp)); + calls = (S32)mRecording->getPeriodMean(idp->callCount()); + } - gGL.color3fv(base_col.mV); - for (U32 i = 0; i < base_times.size(); ++i) - { - gGL.begin(LLRender::TRIANGLE_STRIP); - gGL.vertex3fv(last_p.mV); - gGL.vertex3f(last_p.mV[0], 0.f, 0.f); - last_p.set((F32)i/(F32) base_times.size(), base_times[i]/max_time, 0.f); - gGL.vertex3fv(last_p.mV); - gGL.vertex3f(last_p.mV[0], 0.f, 0.f); - gGL.end(); - } - - gGL.flush(); + std::string timer_label; + if (mDisplayCalls) + { + timer_label = llformat("%s (%d)",idp->getName().c_str(),calls); + } + else + { + timer_label = llformat("%s [%.1f]",idp->getName().c_str(),ms.value()); + } + dx = (TEXT_HEIGHT+4) + get_depth(idp)*8; - - last_p.clear(); - { - LLGLEnable blend(GL_BLEND); - - gGL.color3fv(cur_col.mV); - for (U32 i = 0; i < cur_times.size(); ++i) + LLColor4 color = LLColor4::white; + if (get_depth(idp) > 0) { - gGL.begin(LLRender::TRIANGLE_STRIP); - gGL.vertex3f(last_p.mV[0], 0.f, 0.f); - gGL.vertex3fv(last_p.mV); - last_p.set((F32) i / (F32) cur_times.size(), cur_times[i]/max_time, 0.f); - gGL.vertex3f(last_p.mV[0], 0.f, 0.f); - gGL.vertex3fv(last_p.mV); - gGL.end(); + S32 line_start_y = bar_rect.getCenterY(); + S32 line_end_y = line_start_y + ((TEXT_HEIGHT + 2) * (cur_line - display_line[idp->getParent()])) - TEXT_HEIGHT; + gl_line_2d(x + dx - 8, line_start_y, x + dx, line_start_y, color); + S32 line_x = x + (TEXT_HEIGHT + 4) + ((get_depth(idp) - 1) * 8); + gl_line_2d(line_x, line_start_y, line_x, line_end_y, color); + if (idp->getCollapsed() && !idp->getChildren().empty()) + { + gl_line_2d(line_x+4, line_start_y-3, line_x+4, line_start_y+4, color); + } } - - gGL.flush(); - } - saveChart(label, "time", scratch); - - //====================================== - // calls - //====================================== - buffer.clear(); + x += dx; + BOOL is_child_of_hover_item = (idp == mHoverID); + TimeBlock* next_parent = idp->getParent(); + while(!is_child_of_hover_item && next_parent) + { + is_child_of_hover_item = (mHoverID == next_parent); + if (next_parent->getParent() == next_parent) break; + next_parent = next_parent->getParent(); + } - last_p.clear(); + LLFontGL::getFontMonospace()->renderUTF8(timer_label, 0, + x, y, + color, + LLFontGL::LEFT, LLFontGL::TOP, + is_child_of_hover_item ? LLFontGL::BOLD : LLFontGL::NORMAL); - gGL.color3fv(base_col.mV); - for (U32 i = 0; i < base_calls.size(); ++i) - { - gGL.begin(LLRender::TRIANGLE_STRIP); - gGL.vertex3fv(last_p.mV); - gGL.vertex3f(last_p.mV[0], 0.f, 0.f); - last_p.set((F32) i / (F32) base_calls.size(), (F32)base_calls[i]/max_calls, 0.f); - gGL.vertex3fv(last_p.mV); - gGL.vertex3f(last_p.mV[0], 0.f, 0.f); - gGL.end(); + y -= (TEXT_HEIGHT + 2); + + if (idp->getCollapsed()) + { + it.skipDescendants(); + } } - - gGL.flush(); + } +} + +void LLFastTimerView::generateUniqueColors() +{ + // generate unique colors + { + sTimerColors[&getFrameTimer()] = LLColor4::grey; + + F32 hue = 0.f; + for (timer_tree_iterator_t it = begin_timer_tree(getFrameTimer()); + it != timer_tree_iterator_t(); + ++it) { - LLGLEnable blend(GL_BLEND); - gGL.color3fv(cur_col.mV); - last_p.clear(); + TimeBlock* idp = (*it); - for (U32 i = 0; i < cur_calls.size(); ++i) - { - gGL.begin(LLRender::TRIANGLE_STRIP); - gGL.vertex3f(last_p.mV[0], 0.f, 0.f); - gGL.vertex3fv(last_p.mV); - last_p.set((F32) i / (F32) cur_calls.size(), (F32) cur_calls[i]/max_calls, 0.f); - gGL.vertex3f(last_p.mV[0], 0.f, 0.f); - gGL.vertex3fv(last_p.mV); - gGL.end(); - - } - - gGL.flush(); + const F32 HUE_INCREMENT = 0.23f; + hue = fmodf(hue + HUE_INCREMENT, 1.f); + // saturation increases with depth + F32 saturation = clamp_rescale((F32)get_depth(idp), 0.f, 3.f, 0.f, 1.f); + // lightness alternates with depth + F32 lightness = get_depth(idp) % 2 ? 0.5f : 0.6f; + + LLColor4 child_color; + child_color.setHSL(hue, saturation, lightness); + + sTimerColors[idp] = child_color; } + } +} - saveChart(label, "calls", scratch); +S32 LLFastTimerView::drawHelp( S32 y ) +{ + // Draw some help + { + const S32 texth = (S32)LLFontGL::getFontMonospace()->getLineHeight(); - //====================================== - // execution - //====================================== - buffer.clear(); + char modedesc[][32] = { + "2 x Average ", + "Max ", + "Recent Max ", + "100 ms " + }; + char centerdesc[][32] = { + "Left ", + "Centered ", + "Ordered " + }; + + std::string text; + text = llformat("Full bar = %s [Click to pause/reset] [SHIFT-Click to toggle]",modedesc[mDisplayMode]); + LLFontGL::getFontMonospace()->renderUTF8(text, 0, MARGIN, y, LLColor4::white, LLFontGL::LEFT, LLFontGL::TOP); + + y -= (texth + 2); + text = llformat("Justification = %s [CTRL-Click to toggle]",centerdesc[mDisplayCenter]); + LLFontGL::getFontMonospace()->renderUTF8(text, 0, MARGIN, y, LLColor4::white, LLFontGL::LEFT, LLFontGL::TOP); + y -= (texth + 2); + + LLFontGL::getFontMonospace()->renderUTF8(std::string("[Right-Click log selected] [ALT-Click toggle counts] [ALT-SHIFT-Click sub hidden]"), + 0, MARGIN, y, LLColor4::white, LLFontGL::LEFT, LLFontGL::TOP); + y -= (texth + 2); + } return y; +} + +void LLFastTimerView::drawTicks( LLUnit total_time ) +{ + // Draw MS ticks + { + LLUnit ms = total_time; + std::string tick_label; + S32 x; + S32 barw = mBarRect.getWidth(); + + tick_label = llformat("%.1f ms |", (F32)ms.value()*.25f); + x = mBarRect.mLeft + barw/4 - LLFontGL::getFontMonospace()->getWidth(tick_label); + LLFontGL::getFontMonospace()->renderUTF8(tick_label, 0, x, mBarRect.mTop, LLColor4::white, + LLFontGL::LEFT, LLFontGL::TOP); + + tick_label = llformat("%.1f ms |", (F32)ms.value()*.50f); + x = mBarRect.mLeft + barw/2 - LLFontGL::getFontMonospace()->getWidth(tick_label); + LLFontGL::getFontMonospace()->renderUTF8(tick_label, 0, x, mBarRect.mTop, LLColor4::white, + LLFontGL::LEFT, LLFontGL::TOP); + + tick_label = llformat("%.1f ms |", (F32)ms.value()*.75f); + x = mBarRect.mLeft + (barw*3)/4 - LLFontGL::getFontMonospace()->getWidth(tick_label); + LLFontGL::getFontMonospace()->renderUTF8(tick_label, 0, x, mBarRect.mTop, LLColor4::white, + LLFontGL::LEFT, LLFontGL::TOP); + + tick_label = llformat( "%d ms |", (U32)ms.value()); + x = mBarRect.mLeft + barw - LLFontGL::getFontMonospace()->getWidth(tick_label); + LLFontGL::getFontMonospace()->renderUTF8(tick_label, 0, x, mBarRect.mTop, LLColor4::white, + LLFontGL::LEFT, LLFontGL::TOP); + } +} + +void LLFastTimerView::drawBorders( S32 y, const S32 x_start, S32 bar_height, S32 dy ) +{ + // Draw borders + { + S32 by = y + 6 + (S32)LLFontGL::getFontMonospace()->getLineHeight(); + + //heading + gl_rect_2d(x_start-5, by, getRect().getWidth()-5, y+5, LLColor4::grey, FALSE); + //tree view + gl_rect_2d(5, by, x_start-10, 5, LLColor4::grey, FALSE); - gGL.color3fv(base_col.mV); - U32 count = 0; - U32 total_count = base_execution.size(); + by = y + 5; + //average bar + gl_rect_2d(x_start-5, by, getRect().getWidth()-5, by-bar_height-dy-5, LLColor4::grey, FALSE); - last_p.clear(); + by -= bar_height*2+dy; - for (std::vector::iterator iter = base_execution.begin(); iter != base_execution.end(); ++iter) - { - gGL.begin(LLRender::TRIANGLE_STRIP); - gGL.vertex3fv(last_p.mV); - gGL.vertex3f(last_p.mV[0], 0.f, 0.f); - last_p.set((F32)count/(F32)total_count, *iter/max_execution, 0.f); - gGL.vertex3fv(last_p.mV); - gGL.vertex3f(last_p.mV[0], 0.f, 0.f); - gGL.end(); - count++; - } + //current frame bar + gl_rect_2d(x_start-5, by, getRect().getWidth()-5, by-bar_height-dy-2, LLColor4::grey, FALSE); - last_p.clear(); - - { - LLGLEnable blend(GL_BLEND); - gGL.color3fv(cur_col.mV); - count = 0; - total_count = cur_execution.size(); + by -= bar_height+dy+1; - for (std::vector::iterator iter = cur_execution.begin(); iter != cur_execution.end(); ++iter) - { - gGL.begin(LLRender::TRIANGLE_STRIP); - gGL.vertex3f(last_p.mV[0], 0.f, 0.f); - gGL.vertex3fv(last_p.mV); - last_p.set((F32)count/(F32)total_count, *iter/max_execution, 0.f); - gGL.vertex3f(last_p.mV[0], 0.f, 0.f); - gGL.vertex3fv(last_p.mV); - gGL.end(); - count++; - } + //history bars + gl_rect_2d(x_start-5, by, getRect().getWidth()-5, LINE_GRAPH_HEIGHT-bar_height-dy-2, LLColor4::grey, FALSE); - gGL.flush(); - } + by = LINE_GRAPH_HEIGHT-bar_height-dy-7; - saveChart(label, "execution", scratch); - } + //line graph + mGraphRect = LLRect(x_start-5, by, getRect().getWidth()-5, 5); - buffer.flush(); + gl_rect_2d(mGraphRect, FALSE); + } +} - gGL.popMatrix(); - gGL.matrixMode(LLRender::MM_MODELVIEW); - gGL.popMatrix(); +LLUnit LLFastTimerView::getTotalTime() +{ + LLUnit total_time; + switch(mDisplayMode) + { + case 0: + total_time = mRecording->getPeriodMean(getFrameTimer())*2; + break; + case 1: + total_time = mAllTimeMax; + break; + case 2: + // Calculate the max total ticks for the current history + total_time = mRecording->getPeriodMax(getFrameTimer()); + break; + default: + total_time = LLUnit(100); + break; + } + return total_time; } -//static -LLSD LLFastTimerView::analyzePerformanceLogDefault(std::istream& is) +void LLFastTimerView::drawBars() { - LLSD ret; + LLUnit total_time = getTotalTime(); + if (total_time <= 0.0) return; - LLSD cur; + LLPointer box_imagep = LLUI::getUIImage("Rounded_Square"); + LLLocalClipRect clip(mBarRect); - LLSD::Real total_time = 0.0; - LLSD::Integer total_frames = 0; + S32 bar_height = (mBarRect.mTop - MARGIN - LINE_GRAPH_HEIGHT) / (MAX_VISIBLE_HISTORY + 2); + S32 vpad = llmax(1, bar_height / 4); // spacing between bars + bar_height -= vpad; - typedef std::map stats_map_t; - stats_map_t time_stats; - stats_map_t sample_stats; + drawTicks(total_time); + S32 y = mBarRect.mTop - ((S32)LLFontGL::getFontMonospace()->getLineHeight() + 4); + drawBorders(y, mBarRect.mLeft, bar_height, vpad); - while (!is.eof() && LLSDSerialize::fromXML(cur, is)) + // Draw bars for each history entry + // Special: -1 = show running average + gGL.getTexUnit(0)->bind(box_imagep->getImage()); + const S32 histmax = llmin(mRecording->getNumPeriods()+1, MAX_VISIBLE_HISTORY); + + for (S32 j = -1; j < histmax && y > LINE_GRAPH_HEIGHT; j++) { - for (LLSD::map_iterator iter = cur.beginMap(); iter != cur.endMap(); ++iter) + mBarRects[llmax(j, 0)].clear(); + int sublevel_dx[FTV_MAX_DEPTH]; + int sublevel_left[FTV_MAX_DEPTH]; + int sublevel_right[FTV_MAX_DEPTH]; + S32 tidx = (j >= 0) + ? j + 1 + mScrollIndex + : -1; + + // draw the bars for each stat + std::vector xpos; + S32 deltax = 0; + xpos.push_back(mBarRect.mLeft); + + TimeBlock* prev_id = NULL; + + S32 i = 0; + for(timer_tree_iterator_t it = begin_timer_tree(getFrameTimer()); + it != end_timer_tree(); + ++it, ++i) { - std::string label = iter->first; + TimeBlock* idp = (*it); + F32 frac = tidx == -1 + ? (mRecording->getPeriodMean(*idp) / total_time) + : (mRecording->getPrevRecordingPeriod(tidx).getSum(*idp).value() / total_time.value()); - F64 time = iter->second["Time"].asReal(); + S32 dx = llround(frac * (F32)mBarRect.getWidth()); + S32 prev_delta_x = deltax; + deltax = dx; - // Skip the total figure - if(label.compare("Total") != 0) + const int level = get_depth(idp) - 1; + while ((S32)xpos.size() > level + 1) { - total_time += time; - } + xpos.pop_back(); + } - if (time > 0.0) - { - LLSD::Integer samples = iter->second["Calls"].asInteger(); + LLRect bar_rect; + bar_rect.setLeftTopAndSize(xpos.back(), y, dx, bar_height); + mBarRects[llmax(j, 0)].push_back(bar_rect); - time_stats[label].push(time); - sample_stats[label].push(samples); + if (level == 0) + { + sublevel_left[level] = mBarRect.mLeft; + sublevel_dx[level] = dx; + sublevel_right[level] = sublevel_left[level] + sublevel_dx[level]; } - } - total_frames++; - } + else if (prev_id && get_depth(prev_id) < get_depth(idp)) + { + F64 sublevelticks = 0; - for(stats_map_t::iterator it = time_stats.begin(); it != time_stats.end(); ++it) - { - std::string label = it->first; - ret[label]["TotalTime"] = time_stats[label].mSum; - ret[label]["MeanTime"] = time_stats[label].getMean(); - ret[label]["MaxTime"] = time_stats[label].getMaxValue(); - ret[label]["MinTime"] = time_stats[label].getMinValue(); - ret[label]["StdDevTime"] = time_stats[label].getStdDev(); - - ret[label]["Samples"] = sample_stats[label].mSum; - ret[label]["MaxSamples"] = sample_stats[label].getMaxValue(); - ret[label]["MinSamples"] = sample_stats[label].getMinValue(); - ret[label]["StdDevSamples"] = sample_stats[label].getStdDev(); + for (TimeBlock::child_const_iter it = prev_id->beginChildren(); + it != prev_id->endChildren(); + ++it) + { + sublevelticks += (tidx == -1) + ? mRecording->getPeriodMean(**it).value() + : mRecording->getPrevRecordingPeriod(tidx).getSum(**it).value(); + } - ret[label]["Frames"] = (LLSD::Integer)time_stats[label].getCount(); - } - - ret["SessionTime"] = total_time; - ret["FrameCount"] = total_frames; + F32 subfrac = (F32)sublevelticks / (F32)total_time.value(); + sublevel_dx[level] = (int)(subfrac * (F32)mBarRect.getWidth() + .5f); - return ret; + if (mDisplayCenter == ALIGN_CENTER) + { + bar_rect.mLeft += (prev_delta_x - sublevel_dx[level])/2; + } + else if (mDisplayCenter == ALIGN_RIGHT) + { + bar_rect.mLeft += (prev_delta_x - sublevel_dx[level]); + } -} + sublevel_left[level] = bar_rect.mLeft; + sublevel_right[level] = sublevel_left[level] + sublevel_dx[level]; + } -//static -void LLFastTimerView::doAnalysisDefault(std::string baseline, std::string target, std::string output) -{ - // Open baseline and current target, exit if one is inexistent - std::ifstream base_is(baseline.c_str()); - std::ifstream target_is(target.c_str()); - if (!base_is.is_open() || !target_is.is_open()) - { - llwarns << "'-analyzeperformance' error : baseline or current target file inexistent" << llendl; - base_is.close(); - target_is.close(); - return; - } + xpos.back() = bar_rect.mRight; + xpos.push_back(bar_rect.mLeft); - //analyze baseline - LLSD base = analyzePerformanceLogDefault(base_is); - base_is.close(); + if (bar_rect.getWidth() > 0) + { + LLColor4 color = sTimerColors[idp]; + S32 scale_offset = 0; - //analyze current - LLSD current = analyzePerformanceLogDefault(target_is); - target_is.close(); + BOOL is_child_of_hover_item = (idp == mHoverID); + TimeBlock* next_parent = idp->getParent(); + while(!is_child_of_hover_item && next_parent) + { + is_child_of_hover_item = (mHoverID == next_parent); + if (next_parent->getParent() == next_parent) break; + next_parent = next_parent->getParent(); + } - //output comparision - std::ofstream os(output.c_str()); + if (idp == mHoverID) + { + scale_offset = llfloor(sinf(mHighlightTimer.getElapsedTimeF32() * 6.f) * 3.f); + //color = lerp(color, LLColor4::black, -0.4f); + } + else if (mHoverID != NULL && !is_child_of_hover_item) + { + color = lerp(color, LLColor4::grey, 0.8f); + } - LLSD::Real session_time = current["SessionTime"].asReal(); - os << - "Label, " - "% Change, " - "% of Session, " - "Cur Min, " - "Cur Max, " - "Cur Mean/sample, " - "Cur Mean/frame, " - "Cur StdDev/frame, " - "Cur Total, " - "Cur Frames, " - "Cur Samples, " - "Base Min, " - "Base Max, " - "Base Mean/sample, " - "Base Mean/frame, " - "Base StdDev/frame, " - "Base Total, " - "Base Frames, " - "Base Samples\n"; + gGL.color4fv(color.mV); + F32 start_fragment = llclamp((F32)(bar_rect.mLeft - sublevel_left[level]) / (F32)sublevel_dx[level], 0.f, 1.f); + F32 end_fragment = llclamp((F32)(bar_rect.mRight - sublevel_left[level]) / (F32)sublevel_dx[level], 0.f, 1.f); + gl_segmented_rect_2d_fragment_tex( + sublevel_left[level], + bar_rect.mTop - level + scale_offset, + sublevel_right[level], + bar_rect.mBottom + level - scale_offset, + box_imagep->getTextureWidth(), box_imagep->getTextureHeight(), + 16, + start_fragment, end_fragment); + } - for (LLSD::map_iterator iter = base.beginMap(); iter != base.endMap(); ++iter) - { - LLSD::String label = iter->first; + if ((*it)->getCollapsed()) + { + it.skipDescendants(); + } + + prev_id = idp; + } + y -= (bar_height + vpad); + if (j < 0) + y -= bar_height; + } + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); +} - if (current[label]["Samples"].asInteger() == 0 || - base[label]["Samples"].asInteger() == 0) - { - //cannot compare - continue; - } - LLSD::Real a = base[label]["TotalTime"].asReal() / base[label]["Samples"].asReal(); - LLSD::Real b = current[label]["TotalTime"].asReal() / current[label]["Samples"].asReal(); - - LLSD::Real diff = b-a; - LLSD::Real perc = diff/a * 100; - os << llformat("%s, %.2f, %.4f, %.4f, %.4f, %.4f, %.4f, %.4f, %.4f, %d, %d, %.4f, %.4f, %.4f, %.4f, %.4f, %.4f, %d, %d\n", - label.c_str(), - (F32) perc, - (F32) (current[label]["TotalTime"].asReal()/session_time * 100.0), - (F32) current[label]["MinTime"].asReal(), - (F32) current[label]["MaxTime"].asReal(), - (F32) b, - (F32) current[label]["MeanTime"].asReal(), - (F32) current[label]["StdDevTime"].asReal(), - (F32) current[label]["TotalTime"].asReal(), - current[label]["Frames"].asInteger(), - current[label]["Samples"].asInteger(), - (F32) base[label]["MinTime"].asReal(), - (F32) base[label]["MaxTime"].asReal(), - (F32) a, - (F32) base[label]["MeanTime"].asReal(), - (F32) base[label]["StdDevTime"].asReal(), - (F32) base[label]["TotalTime"].asReal(), - base[label]["Frames"].asInteger(), - base[label]["Samples"].asInteger()); - } - exportCharts(baseline, target); - os.flush(); - os.close(); -} -//static -void LLFastTimerView::outputAllMetrics() -{ - if (LLMetricPerformanceTesterBasic::hasMetricPerformanceTesters()) - { - for (LLMetricPerformanceTesterBasic::name_tester_map_t::iterator iter = LLMetricPerformanceTesterBasic::sTesterMap.begin(); - iter != LLMetricPerformanceTesterBasic::sTesterMap.end(); ++iter) - { - LLMetricPerformanceTesterBasic* tester = ((LLMetricPerformanceTesterBasic*)iter->second); - tester->outputTestResults(); - } - } -} -//static -void LLFastTimerView::doAnalysis(std::string baseline, std::string target, std::string output) -{ - if(TimeBlock::sLog) - { - doAnalysisDefault(baseline, target, output) ; - return ; - } - if(TimeBlock::sMetricLog) - { - LLMetricPerformanceTesterBasic::doAnalysisMetrics(baseline, target, output) ; - return ; - } -} -void LLFastTimerView::onClickCloseBtn() -{ - setVisible(false); -} -TimeBlock& LLFastTimerView::getFrameTimer() -{ - return FTM_FRAME; -} -- cgit v1.2.3 From 3a555a2ff84d9b340e33673d7a03f37c966f06e6 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Thu, 24 Jan 2013 19:53:17 -0800 Subject: SH-3275 WIP interesting Update viewer metrics system to be more flexible removed LLFastTimerView::getFrameTimer() dead code elimination fixed off by one array access crash --- indra/newview/llfasttimerview.cpp | 31 +++++++++++++------------------ 1 file changed, 13 insertions(+), 18 deletions(-) (limited to 'indra/newview/llfasttimerview.cpp') diff --git a/indra/newview/llfasttimerview.cpp b/indra/newview/llfasttimerview.cpp index 59a52fdaea..7858378f00 100644 --- a/indra/newview/llfasttimerview.cpp +++ b/indra/newview/llfasttimerview.cpp @@ -107,7 +107,7 @@ LLFastTimerView::LLFastTimerView(const LLSD& key) mRecording(&get_frame_recording()), mPauseHistory(false) { - mBarRects = new std::vector[MAX_VISIBLE_HISTORY]; + mBarRects = new std::vector[MAX_VISIBLE_HISTORY + 1]; } LLFastTimerView::~LLFastTimerView() @@ -189,7 +189,7 @@ TimeBlock* LLFastTimerView::getLegendID(S32 y) BOOL LLFastTimerView::handleDoubleClick(S32 x, S32 y, MASK mask) { - for(timer_tree_iterator_t it = begin_timer_tree(getFrameTimer()); + for(timer_tree_iterator_t it = begin_timer_tree(FTM_FRAME); it != end_timer_tree(); ++it) { @@ -277,7 +277,7 @@ BOOL LLFastTimerView::handleHover(S32 x, S32 y, MASK mask) } S32 i = 0; - for(timer_tree_iterator_t it = begin_timer_tree(getFrameTimer()); + for(timer_tree_iterator_t it = begin_timer_tree(FTM_FRAME); it != end_timer_tree(); ++it, ++i) { @@ -412,7 +412,7 @@ void LLFastTimerView::draw() printLineStats(); LLView::draw(); - mAllTimeMax = llmax(mAllTimeMax, mRecording->getLastRecordingPeriod().getSum(getFrameTimer())); + mAllTimeMax = llmax(mAllTimeMax, mRecording->getLastRecordingPeriod().getSum(FTM_FRAME)); mHoverID = NULL; mHoverBarIndex = -1; } @@ -935,11 +935,6 @@ void LLFastTimerView::onClickCloseBtn() setVisible(false); } -TimeBlock& LLFastTimerView::getFrameTimer() -{ - return FTM_FRAME; -} - void LLFastTimerView::printLineStats() { // Output stats for clicked bar to log @@ -947,7 +942,7 @@ void LLFastTimerView::printLineStats() { std::string legend_stat; bool first = true; - for(timer_tree_iterator_t it = begin_timer_tree(getFrameTimer()); + for(timer_tree_iterator_t it = begin_timer_tree(FTM_FRAME); it != end_timer_tree(); ++it) { @@ -969,7 +964,7 @@ void LLFastTimerView::printLineStats() std::string timer_stat; first = true; - for(timer_tree_iterator_t it = begin_timer_tree(getFrameTimer()); + for(timer_tree_iterator_t it = begin_timer_tree(FTM_FRAME); it != end_timer_tree(); ++it) { @@ -1061,7 +1056,7 @@ void LLFastTimerView::drawLineGraph() LLUnit cur_max = 0; U32 cur_max_calls = 0; - for(timer_tree_iterator_t it = begin_timer_tree(getFrameTimer()); + for(timer_tree_iterator_t it = begin_timer_tree(FTM_FRAME); it != end_timer_tree(); ++it) { @@ -1169,7 +1164,7 @@ void LLFastTimerView::drawLegend( S32 y ) S32 cur_line = 0; ft_display_idx.clear(); std::map display_line; - for (timer_tree_iterator_t it = begin_timer_tree(getFrameTimer()); + for (timer_tree_iterator_t it = begin_timer_tree(FTM_FRAME); it != timer_tree_iterator_t(); ++it) { @@ -1258,11 +1253,11 @@ void LLFastTimerView::generateUniqueColors() { // generate unique colors { - sTimerColors[&getFrameTimer()] = LLColor4::grey; + sTimerColors[&FTM_FRAME] = LLColor4::grey; F32 hue = 0.f; - for (timer_tree_iterator_t it = begin_timer_tree(getFrameTimer()); + for (timer_tree_iterator_t it = begin_timer_tree(FTM_FRAME); it != timer_tree_iterator_t(); ++it) { @@ -1388,14 +1383,14 @@ LLUnit LLFastTimerView::getTotalTime() switch(mDisplayMode) { case 0: - total_time = mRecording->getPeriodMean(getFrameTimer())*2; + total_time = mRecording->getPeriodMean(FTM_FRAME)*2; break; case 1: total_time = mAllTimeMax; break; case 2: // Calculate the max total ticks for the current history - total_time = mRecording->getPeriodMax(getFrameTimer()); + total_time = mRecording->getPeriodMax(FTM_FRAME); break; default: total_time = LLUnit(100); @@ -1443,7 +1438,7 @@ void LLFastTimerView::drawBars() TimeBlock* prev_id = NULL; S32 i = 0; - for(timer_tree_iterator_t it = begin_timer_tree(getFrameTimer()); + for(timer_tree_iterator_t it = begin_timer_tree(FTM_FRAME); it != end_timer_tree(); ++it, ++i) { -- cgit v1.2.3 From 2c68d5367c5c44aceb4ff23d9672c35642e030f7 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Sun, 27 Jan 2013 21:35:20 -0800 Subject: SH-3275 WIP interesting Update viewer metrics system to be more flexible fixed memory leak fixed glitching of fast timer display --- indra/newview/llfasttimerview.cpp | 245 ++++++++++++++++++-------------------- 1 file changed, 114 insertions(+), 131 deletions(-) (limited to 'indra/newview/llfasttimerview.cpp') diff --git a/indra/newview/llfasttimerview.cpp b/indra/newview/llfasttimerview.cpp index 7858378f00..948b6f8e89 100644 --- a/indra/newview/llfasttimerview.cpp +++ b/indra/newview/llfasttimerview.cpp @@ -107,7 +107,7 @@ LLFastTimerView::LLFastTimerView(const LLSD& key) mRecording(&get_frame_recording()), mPauseHistory(false) { - mBarRects = new std::vector[MAX_VISIBLE_HISTORY + 1]; + mTimerBars = new std::vector[MAX_VISIBLE_HISTORY + 1]; } LLFastTimerView::~LLFastTimerView() @@ -117,7 +117,7 @@ LLFastTimerView::~LLFastTimerView() delete mRecording; } mRecording = NULL; - delete [] mBarRects; + delete [] mTimerBars; } void LLFastTimerView::onPause() @@ -282,7 +282,7 @@ BOOL LLFastTimerView::handleHover(S32 x, S32 y, MASK mask) ++it, ++i) { // is mouse over bar for this timer? - if (mBarRects[mHoverBarIndex][i].pointInRect(x, y)) + if (mTimerBars[mHoverBarIndex][i].mRect.pointInRect(x, y)) { mHoverID = (*it); if (mHoverTimer != *it) @@ -294,7 +294,7 @@ BOOL LLFastTimerView::handleHover(S32 x, S32 y, MASK mask) mHoverTimer = (*it); } - mToolTipRect = mBarRects[mHoverBarIndex][i]; + mToolTipRect = mTimerBars[mHoverBarIndex][i].mRect; } if ((*it)->getCollapsed()) @@ -1311,11 +1311,11 @@ S32 LLFastTimerView::drawHelp( S32 y ) } return y; } -void LLFastTimerView::drawTicks( LLUnit total_time ) +void LLFastTimerView::drawTicks() { // Draw MS ticks { - LLUnit ms = total_time; + LLUnit ms = mTotalTimeDisplay; std::string tick_label; S32 x; S32 barw = mBarRect.getWidth(); @@ -1377,187 +1377,170 @@ void LLFastTimerView::drawBorders( S32 y, const S32 x_start, S32 bar_height, S32 } } -LLUnit LLFastTimerView::getTotalTime() +void LLFastTimerView::updateTotalTime() { - LLUnit total_time; switch(mDisplayMode) { case 0: - total_time = mRecording->getPeriodMean(FTM_FRAME)*2; + mTotalTimeDisplay = mRecording->getPeriodMean(FTM_FRAME)*2; break; case 1: - total_time = mAllTimeMax; + mTotalTimeDisplay = mAllTimeMax; break; case 2: // Calculate the max total ticks for the current history - total_time = mRecording->getPeriodMax(FTM_FRAME); + mTotalTimeDisplay = mRecording->getPeriodMax(FTM_FRAME); break; default: - total_time = LLUnit(100); + mTotalTimeDisplay = LLUnit(100); break; } - return total_time; } void LLFastTimerView::drawBars() { - LLUnit total_time = getTotalTime(); - if (total_time <= 0.0) return; + updateTotalTime(); + if (mTotalTimeDisplay <= 0.0) return; - LLPointer box_imagep = LLUI::getUIImage("Rounded_Square"); LLLocalClipRect clip(mBarRect); S32 bar_height = (mBarRect.mTop - MARGIN - LINE_GRAPH_HEIGHT) / (MAX_VISIBLE_HISTORY + 2); S32 vpad = llmax(1, bar_height / 4); // spacing between bars bar_height -= vpad; - drawTicks(total_time); + drawTicks(); S32 y = mBarRect.mTop - ((S32)LLFontGL::getFontMonospace()->getLineHeight() + 4); drawBorders(y, mBarRect.mLeft, bar_height, vpad); // Draw bars for each history entry // Special: -1 = show running average - gGL.getTexUnit(0)->bind(box_imagep->getImage()); + LLPointer bar_image = LLUI::getUIImage("Rounded_Square"); + gGL.getTexUnit(0)->bind(bar_image->getImage()); const S32 histmax = llmin(mRecording->getNumPeriods()+1, MAX_VISIBLE_HISTORY); for (S32 j = -1; j < histmax && y > LINE_GRAPH_HEIGHT; j++) { - mBarRects[llmax(j, 0)].clear(); - int sublevel_dx[FTV_MAX_DEPTH]; - int sublevel_left[FTV_MAX_DEPTH]; - int sublevel_right[FTV_MAX_DEPTH]; - S32 tidx = (j >= 0) + S32 history_index = (j >= 0) ? j + 1 + mScrollIndex : -1; + S32 rect_index = llmax(j, 0); + mTimerBars[rect_index].clear(); - // draw the bars for each stat - std::vector xpos; - S32 deltax = 0; - xpos.push_back(mBarRect.mLeft); + updateTimerBars(&FTM_FRAME, LLRect(mBarRect.mLeft, 0, mBarRect.mRight, -bar_height), mTimerBars[rect_index], history_index); - TimeBlock* prev_id = NULL; - - S32 i = 0; - for(timer_tree_iterator_t it = begin_timer_tree(FTM_FRAME); - it != end_timer_tree(); - ++it, ++i) + for (std::vector::iterator it = mTimerBars[rect_index].begin(), end_it = mTimerBars[rect_index].end(); + it != end_it; + ++it) { - TimeBlock* idp = (*it); - F32 frac = tidx == -1 - ? (mRecording->getPeriodMean(*idp) / total_time) - : (mRecording->getPrevRecordingPeriod(tidx).getSum(*idp).value() / total_time.value()); - - S32 dx = llround(frac * (F32)mBarRect.getWidth()); - S32 prev_delta_x = deltax; - deltax = dx; - - const int level = get_depth(idp) - 1; - while ((S32)xpos.size() > level + 1) - { - xpos.pop_back(); - } - - LLRect bar_rect; - bar_rect.setLeftTopAndSize(xpos.back(), y, dx, bar_height); - mBarRects[llmax(j, 0)].push_back(bar_rect); - - if (level == 0) - { - sublevel_left[level] = mBarRect.mLeft; - sublevel_dx[level] = dx; - sublevel_right[level] = sublevel_left[level] + sublevel_dx[level]; - } - else if (prev_id && get_depth(prev_id) < get_depth(idp)) - { - F64 sublevelticks = 0; - - for (TimeBlock::child_const_iter it = prev_id->beginChildren(); - it != prev_id->endChildren(); - ++it) - { - sublevelticks += (tidx == -1) - ? mRecording->getPeriodMean(**it).value() - : mRecording->getPrevRecordingPeriod(tidx).getSum(**it).value(); - } - - F32 subfrac = (F32)sublevelticks / (F32)total_time.value(); - sublevel_dx[level] = (int)(subfrac * (F32)mBarRect.getWidth() + .5f); + TimerBar& timer_bar = *it; + gGL.color4fv(timer_bar.mColor.mV); + gl_segmented_rect_2d_fragment_tex(timer_bar.mRect.mLeft, timer_bar.mRect.mTop, timer_bar.mRect.mRight, timer_bar.mRect.mBottom, + bar_image->getTextureWidth(), bar_image->getTextureHeight(), + 16, + timer_bar.mStartFraction, timer_bar.mEndFraction); - if (mDisplayCenter == ALIGN_CENTER) - { - bar_rect.mLeft += (prev_delta_x - sublevel_dx[level])/2; - } - else if (mDisplayCenter == ALIGN_RIGHT) - { - bar_rect.mLeft += (prev_delta_x - sublevel_dx[level]); - } - - sublevel_left[level] = bar_rect.mLeft; - sublevel_right[level] = sublevel_left[level] + sublevel_dx[level]; - } + } + + y -= (bar_height + vpad); + if (j < 0) + y -= bar_height; + } + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); +} - xpos.back() = bar_rect.mRight; - xpos.push_back(bar_rect.mLeft); +LLRect LLFastTimerView::updateTimerBars(LLTrace::TimeBlock* time_block, LLRect bar_rect, std::vector& bars, S32 history_index) +{ + F32 self_time_frame_fraction = history_index == -1 + ? (mRecording->getPeriodMean(time_block->selfTime()) / mTotalTimeDisplay) + : (mRecording->getPrevRecordingPeriod(history_index).getSum(time_block->selfTime()) / mTotalTimeDisplay); - if (bar_rect.getWidth() > 0) - { - LLColor4 color = sTimerColors[idp]; - S32 scale_offset = 0; + S32 self_time_width = llround(self_time_frame_fraction * (F32)mBarRect.getWidth()); + LLRect child_rect = bar_rect; - BOOL is_child_of_hover_item = (idp == mHoverID); - TimeBlock* next_parent = idp->getParent(); - while(!is_child_of_hover_item && next_parent) - { - is_child_of_hover_item = (mHoverID == next_parent); - if (next_parent->getParent() == next_parent) break; - next_parent = next_parent->getParent(); - } + if (mDisplayCenter == ALIGN_CENTER) + { + child_rect.mLeft += self_time_width / 2; + self_time_width -= self_time_width / 2; + } + else if (mDisplayCenter == ALIGN_RIGHT) + { + child_rect.mLeft += self_time_width; + self_time_width = 0; + } - if (idp == mHoverID) - { - scale_offset = llfloor(sinf(mHighlightTimer.getElapsedTimeF32() * 6.f) * 3.f); - //color = lerp(color, LLColor4::black, -0.4f); - } - else if (mHoverID != NULL && !is_child_of_hover_item) - { - color = lerp(color, LLColor4::grey, 0.8f); - } + if (child_rect.getHeight() > 3) + { + child_rect.mTop -= 1; + child_rect.mBottom += 1; + } + child_rect.mRight = child_rect.mLeft; - gGL.color4fv(color.mV); - F32 start_fragment = llclamp((F32)(bar_rect.mLeft - sublevel_left[level]) / (F32)sublevel_dx[level], 0.f, 1.f); - F32 end_fragment = llclamp((F32)(bar_rect.mRight - sublevel_left[level]) / (F32)sublevel_dx[level], 0.f, 1.f); - gl_segmented_rect_2d_fragment_tex( - sublevel_left[level], - bar_rect.mTop - level + scale_offset, - sublevel_right[level], - bar_rect.mBottom + level - scale_offset, - box_imagep->getTextureWidth(), box_imagep->getTextureHeight(), - 16, - start_fragment, end_fragment); - } + // reserve a spot for this bar to be rendered before its children + // even though we don't know its size yet + S32 first_child_left = child_rect.mLeft; + S32 bar_rect_index = bars.size(); + bars.push_back(TimerBar()); - if ((*it)->getCollapsed()) - { - it.skipDescendants(); - } + for (TimeBlock::child_iter it = time_block->beginChildren(), end_it = time_block->endChildren(); it != end_it; ++it) + { + child_rect = updateTimerBars(*it, child_rect, bars, history_index); - prev_id = idp; - } - y -= (bar_height + vpad); - if (j < 0) - y -= bar_height; + // advance for next child + child_rect.mLeft = child_rect.mRight; } - gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); -} + // now loop through children and figure out portion of bar image covered by each bar, now that we know the + // sum of all children + //S32 total_width_children = child_rect.mRight - first_child_left; + //S32 child_bar_index = bar_rect_index + 1; + //F32 bar_fraction_start = 0.f; + //for (TimeBlock::child_iter it = time_block->beginChildren(), end_it = time_block->endChildren(); + // it != end_it; + // ++it) + //{ + // TimerBar& child_timer_bar = bars[child_bar_index]; + // child_timer_bar.mStartFraction = bar_fraction_start; + // child_timer_bar.mEndFraction = (F32)child_timer_bar.mRect.getWidth() / (F32)total_width_children; + // bar_fraction_start = child_timer_bar.mEndFraction; + // // advance for next child + // child_bar_index++; + //} + bar_rect.mRight = child_rect.mRight + self_time_width; + if (bar_rect.getWidth() > 0) + { + LLColor4 color = sTimerColors[time_block]; + S32 scale_offset = 0; + BOOL is_child_of_hover_item = (time_block == mHoverID); + TimeBlock* next_parent = time_block->getParent(); + while(!is_child_of_hover_item && next_parent) + { + is_child_of_hover_item = (mHoverID == next_parent); + if (next_parent->getParent() == next_parent) break; + next_parent = next_parent->getParent(); + } + if (time_block == mHoverID) + { + scale_offset = llfloor(sinf(mHighlightTimer.getElapsedTimeF32() * 6.f) * 3.f); + } + else if (mHoverID != NULL && !is_child_of_hover_item) + { + color = lerp(color, LLColor4::grey, 0.8f); + } + bar_rect.mTop += scale_offset; + bar_rect.mBottom -= scale_offset; + bars[bar_rect_index].mRect = bar_rect; + bars[bar_rect_index].mColor = color; + } + return bar_rect; +} -- cgit v1.2.3 From a441664c109e4fca4154dbf80e108c27b3e9e601 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Thu, 31 Jan 2013 00:50:54 -0800 Subject: SH-3275 WIP interesting Update viewer metrics system to be more flexible fast timer bars render correctly --- indra/newview/llfasttimerview.cpp | 263 +++++++++++++++++++++----------------- 1 file changed, 148 insertions(+), 115 deletions(-) (limited to 'indra/newview/llfasttimerview.cpp') diff --git a/indra/newview/llfasttimerview.cpp b/indra/newview/llfasttimerview.cpp index 948b6f8e89..c75f25c0f0 100644 --- a/indra/newview/llfasttimerview.cpp +++ b/indra/newview/llfasttimerview.cpp @@ -58,9 +58,8 @@ using namespace LLTrace; static const S32 MAX_VISIBLE_HISTORY = 10; static const S32 LINE_GRAPH_HEIGHT = 240; - -const S32 FTV_MAX_DEPTH = 8; -const S32 HISTORY_NUM = 300; +static const S32 HISTORY_NUM = 300; +static const S32 MIN_BAR_HEIGHT = 3; std::vector ft_display_idx; // line of table entry for display purposes (for collapse) @@ -123,20 +122,25 @@ LLFastTimerView::~LLFastTimerView() void LLFastTimerView::onPause() { mPauseHistory = !mPauseHistory; + updatePauseState(); +} + +void LLFastTimerView::updatePauseState() +{ // reset scroll to bottom when unpausing if (!mPauseHistory) - { - mRecording = new PeriodicRecording(get_frame_recording()); - mScrollIndex = 0; - getChild("pause_btn")->setLabel(getString("pause")); - } - else { if (mRecording != &get_frame_recording()) { delete mRecording; } mRecording = &get_frame_recording(); + getChild("pause_btn")->setLabel(getString("pause")); + } + else + { + mRecording = new PeriodicRecording(get_frame_recording()); + mScrollIndex = 0; getChild("pause_btn")->setLabel(getString("run")); } @@ -177,7 +181,7 @@ BOOL LLFastTimerView::handleRightMouseDown(S32 x, S32 y, MASK mask) TimeBlock* LLFastTimerView::getLegendID(S32 y) { - S32 idx = (getRect().getHeight() - y) / (LLFontGL::getFontMonospace()->getLineHeight()+2) - 5; + S32 idx = (mBarRect.mTop - y) / (LLFontGL::getFontMonospace()->getLineHeight()+2) - 1; if (idx >= 0 && idx < (S32)ft_display_idx.size()) { @@ -282,7 +286,7 @@ BOOL LLFastTimerView::handleHover(S32 x, S32 y, MASK mask) ++it, ++i) { // is mouse over bar for this timer? - if (mTimerBars[mHoverBarIndex][i].mRect.pointInRect(x, y)) + if (mTimerBars[mHoverBarIndex][i].mVisibleRect.pointInRect(x, y)) { mHoverID = (*it); if (mHoverTimer != *it) @@ -294,7 +298,7 @@ BOOL LLFastTimerView::handleHover(S32 x, S32 y, MASK mask) mHoverTimer = (*it); } - mToolTipRect = mTimerBars[mHoverBarIndex][i].mRect; + mToolTipRect = mTimerBars[mHoverBarIndex][i].mVisibleRect; } if ((*it)->getCollapsed()) @@ -374,6 +378,7 @@ BOOL LLFastTimerView::handleToolTip(S32 x, S32 y, MASK mask) BOOL LLFastTimerView::handleScrollWheel(S32 x, S32 y, S32 clicks) { mPauseHistory = true; + updatePauseState(); mScrollIndex = llclamp( mScrollIndex + clicks, 0, llmin(mRecording->getNumPeriods(), (S32)HISTORY_NUM - MAX_VISIBLE_HISTORY)); @@ -397,7 +402,7 @@ void LLFastTimerView::draw() gl_rect_2d(getLocalRect(), LLColor4(0.f, 0.f, 0.f, 0.25f)); S32 y = drawHelp(getRect().getHeight() - MARGIN); - drawLegend(y - ((S32)LLFontGL::getFontMonospace()->getLineHeight() - 2)); + drawLegend(y - ((S32)LLFontGL::getFontMonospace()->getLineHeight() + 2)); // update rectangle that includes timer bars const S32 LEGEND_WIDTH = 220; @@ -1074,7 +1079,7 @@ void LLFastTimerView::drawLineGraph() F32 alpha = 1.f; if (mHoverID != NULL && - idp != mHoverID) + mHoverID != idp) { //fade out non-highlighted timers if (idp->getParent() != mHoverID) { @@ -1281,34 +1286,33 @@ void LLFastTimerView::generateUniqueColors() S32 LLFastTimerView::drawHelp( S32 y ) { // Draw some help - { - const S32 texth = (S32)LLFontGL::getFontMonospace()->getLineHeight(); - - char modedesc[][32] = { - "2 x Average ", - "Max ", - "Recent Max ", - "100 ms " - }; - char centerdesc[][32] = { - "Left ", - "Centered ", - "Ordered " - }; - - std::string text; - text = llformat("Full bar = %s [Click to pause/reset] [SHIFT-Click to toggle]",modedesc[mDisplayMode]); - LLFontGL::getFontMonospace()->renderUTF8(text, 0, MARGIN, y, LLColor4::white, LLFontGL::LEFT, LLFontGL::TOP); - - y -= (texth + 2); - text = llformat("Justification = %s [CTRL-Click to toggle]",centerdesc[mDisplayCenter]); - LLFontGL::getFontMonospace()->renderUTF8(text, 0, MARGIN, y, LLColor4::white, LLFontGL::LEFT, LLFontGL::TOP); - y -= (texth + 2); - - LLFontGL::getFontMonospace()->renderUTF8(std::string("[Right-Click log selected] [ALT-Click toggle counts] [ALT-SHIFT-Click sub hidden]"), - 0, MARGIN, y, LLColor4::white, LLFontGL::LEFT, LLFontGL::TOP); - y -= (texth + 2); - } return y; + const S32 texth = (S32)LLFontGL::getFontMonospace()->getLineHeight(); + + char modedesc[][32] = { + "2 x Average ", + "Max ", + "Recent Max ", + "100 ms " + }; + char centerdesc[][32] = { + "Left ", + "Centered ", + "Ordered " + }; + + std::string text; + text = llformat("Full bar = %s [Click to pause/reset] [SHIFT-Click to toggle]",modedesc[mDisplayMode]); + LLFontGL::getFontMonospace()->renderUTF8(text, 0, MARGIN, y, LLColor4::white, LLFontGL::LEFT, LLFontGL::TOP); + + y -= (texth + 2); + text = llformat("Justification = %s [CTRL-Click to toggle]",centerdesc[mDisplayCenter]); + LLFontGL::getFontMonospace()->renderUTF8(text, 0, MARGIN, y, LLColor4::white, LLFontGL::LEFT, LLFontGL::TOP); + y -= (texth + 2); + + LLFontGL::getFontMonospace()->renderUTF8(std::string("[Right-Click log selected] [ALT-Click toggle counts] [ALT-SHIFT-Click sub hidden]"), + 0, MARGIN, y, LLColor4::white, LLFontGL::LEFT, LLFontGL::TOP); + y -= (texth + 2); + return y; } void LLFastTimerView::drawTicks() @@ -1425,21 +1429,13 @@ void LLFastTimerView::drawBars() : -1; S32 rect_index = llmax(j, 0); mTimerBars[rect_index].clear(); + mTimerBars[rect_index].reserve(LLInstanceTracker::instanceCount()); - updateTimerBars(&FTM_FRAME, LLRect(mBarRect.mLeft, 0, mBarRect.mRight, -bar_height), mTimerBars[rect_index], history_index); - - for (std::vector::iterator it = mTimerBars[rect_index].begin(), end_it = mTimerBars[rect_index].end(); - it != end_it; - ++it) - { - TimerBar& timer_bar = *it; - gGL.color4fv(timer_bar.mColor.mV); - gl_segmented_rect_2d_fragment_tex(timer_bar.mRect.mLeft, timer_bar.mRect.mTop, timer_bar.mRect.mRight, timer_bar.mRect.mBottom, - bar_image->getTextureWidth(), bar_image->getTextureHeight(), - 16, - timer_bar.mStartFraction, timer_bar.mEndFraction); - - } + LLRect frame_bar_rect(mBarRect.mLeft, y, mBarRect.mLeft + mTimerBars[rect_index][0].mWidth, y-bar_height); + updateTimerBarWidths(&FTM_FRAME, mTimerBars[rect_index], history_index); + mTimerBars[rect_index][0].mVisibleRect = frame_bar_rect; + updateTimerBarFractions(&FTM_FRAME, 0, mTimerBars[rect_index], history_index, true); + drawBar(&FTM_FRAME, frame_bar_rect, mTimerBars[rect_index], 0, bar_image); y -= (bar_height + vpad); if (j < 0) @@ -1448,99 +1444,136 @@ void LLFastTimerView::drawBars() gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); } -LLRect LLFastTimerView::updateTimerBars(LLTrace::TimeBlock* time_block, LLRect bar_rect, std::vector& bars, S32 history_index) + +S32 LLFastTimerView::updateTimerBarWidths(LLTrace::TimeBlock* time_block, std::vector& bars, S32 history_index) { F32 self_time_frame_fraction = history_index == -1 ? (mRecording->getPeriodMean(time_block->selfTime()) / mTotalTimeDisplay) : (mRecording->getPrevRecordingPeriod(history_index).getSum(time_block->selfTime()) / mTotalTimeDisplay); S32 self_time_width = llround(self_time_frame_fraction * (F32)mBarRect.getWidth()); - LLRect child_rect = bar_rect; + S32 full_width = self_time_width; - if (mDisplayCenter == ALIGN_CENTER) + // reserve a spot for this bar to be rendered before its children + // even though we don't know its size yet + S32 bar_rect_index = bars.size(); + bars.push_back(TimerBar()); + + for (TimeBlock::child_iter it = time_block->beginChildren(), end_it = time_block->endChildren(); it != end_it; ++it) { - child_rect.mLeft += self_time_width / 2; - self_time_width -= self_time_width / 2; + full_width += updateTimerBarWidths(*it, bars, history_index); } - else if (mDisplayCenter == ALIGN_RIGHT) + + TimerBar& timer_bar = bars[bar_rect_index]; + + timer_bar.mWidth = full_width; + timer_bar.mSelfWidth = self_time_width; + timer_bar.mColor = sTimerColors[time_block]; + + BOOL is_child_of_hover_item = (time_block == mHoverID); + TimeBlock* next_parent = time_block->getParent(); + while(!is_child_of_hover_item && next_parent) { - child_rect.mLeft += self_time_width; - self_time_width = 0; + is_child_of_hover_item = (mHoverID == next_parent); + if (next_parent->getParent() == next_parent) break; + next_parent = next_parent->getParent(); } - if (child_rect.getHeight() > 3) + if (mHoverID != NULL + && time_block != mHoverID + && !is_child_of_hover_item) { - child_rect.mTop -= 1; - child_rect.mBottom += 1; + timer_bar.mColor = lerp(timer_bar.mColor, LLColor4::grey, 0.8f); } - child_rect.mRight = child_rect.mLeft; - // reserve a spot for this bar to be rendered before its children - // even though we don't know its size yet - S32 first_child_left = child_rect.mLeft; - S32 bar_rect_index = bars.size(); - bars.push_back(TimerBar()); + return full_width; +} - for (TimeBlock::child_iter it = time_block->beginChildren(), end_it = time_block->endChildren(); it != end_it; ++it) +S32 LLFastTimerView::updateTimerBarFractions(LLTrace::TimeBlock* time_block, S32 timer_bar_index, std::vector& bars, S32 history_index, bool draw) +{ + TimerBar& timer_bar = bars[timer_bar_index]; + S32 child_time_width = timer_bar.mWidth - timer_bar.mSelfWidth; + LLRect children_rect = timer_bar.mVisibleRect; + + if (mDisplayCenter == ALIGN_CENTER) + { + children_rect.mLeft += timer_bar.mSelfWidth / 2; + } + else if (mDisplayCenter == ALIGN_RIGHT) + { + children_rect.mLeft += timer_bar.mSelfWidth; + } + children_rect.mRight = children_rect.mLeft + timer_bar.mWidth - timer_bar.mSelfWidth; + + if (children_rect.getHeight() > MIN_BAR_HEIGHT) { - child_rect = updateTimerBars(*it, child_rect, bars, history_index); + children_rect.mTop -= 1; + children_rect.mBottom += 1; + } + timer_bar.mChildrenRect = children_rect; + timer_bar.mVisible = draw; - // advance for next child - child_rect.mLeft = child_rect.mRight; + if (time_block->getCollapsed()) + { + draw = false; } - // now loop through children and figure out portion of bar image covered by each bar, now that we know the - // sum of all children - //S32 total_width_children = child_rect.mRight - first_child_left; - //S32 child_bar_index = bar_rect_index + 1; - //F32 bar_fraction_start = 0.f; - //for (TimeBlock::child_iter it = time_block->beginChildren(), end_it = time_block->endChildren(); - // it != end_it; - // ++it) - //{ - // TimerBar& child_timer_bar = bars[child_bar_index]; + //now loop through children and figure out portion of bar image covered by each bar, now that we know the + //sum of all children + F32 bar_fraction_start = 0.f; + for (TimeBlock::child_iter it = time_block->beginChildren(), end_it = time_block->endChildren(); + it != end_it; + ++it) + { + timer_bar_index++; - // child_timer_bar.mStartFraction = bar_fraction_start; - // child_timer_bar.mEndFraction = (F32)child_timer_bar.mRect.getWidth() / (F32)total_width_children; + TimerBar& child_timer_bar = bars[timer_bar_index]; + TimeBlock* child_time_block = *it; - // bar_fraction_start = child_timer_bar.mEndFraction; + child_timer_bar.mStartFraction = bar_fraction_start; + child_timer_bar.mEndFraction = child_time_width > 0 + ? bar_fraction_start + (F32)child_timer_bar.mWidth / child_time_width + : 1.f; + child_timer_bar.mVisibleRect.set(children_rect.mLeft + llround(child_timer_bar.mStartFraction * children_rect.getWidth()), + children_rect.mTop, + children_rect.mLeft + llround(child_timer_bar.mEndFraction * children_rect.getWidth()), + children_rect.mBottom); - // // advance for next child - // child_bar_index++; - //} + timer_bar_index = updateTimerBarFractions(child_time_block, timer_bar_index, bars, history_index, draw); + bar_fraction_start = child_timer_bar.mEndFraction; + } + return timer_bar_index; +} - bar_rect.mRight = child_rect.mRight + self_time_width; +S32 LLFastTimerView::drawBar(LLTrace::TimeBlock* time_block, LLRect bar_rect, std::vector& bars, S32 bar_index, LLPointer& bar_image) +{ + TimerBar& timer_bar = bars[bar_index]; - if (bar_rect.getWidth() > 0) + // animate scale of bar when hovering over that particular timer + if (bar_rect.getWidth() > 0 && timer_bar.mVisible) { - LLColor4 color = sTimerColors[time_block]; + LLRect render_rect(bar_rect); S32 scale_offset = 0; - - BOOL is_child_of_hover_item = (time_block == mHoverID); - TimeBlock* next_parent = time_block->getParent(); - while(!is_child_of_hover_item && next_parent) - { - is_child_of_hover_item = (mHoverID == next_parent); - if (next_parent->getParent() == next_parent) break; - next_parent = next_parent->getParent(); - } - if (time_block == mHoverID) { scale_offset = llfloor(sinf(mHighlightTimer.getElapsedTimeF32() * 6.f) * 3.f); - } - else if (mHoverID != NULL && !is_child_of_hover_item) - { - color = lerp(color, LLColor4::grey, 0.8f); + render_rect.mTop += scale_offset; + render_rect.mBottom -= scale_offset; } - bar_rect.mTop += scale_offset; - bar_rect.mBottom -= scale_offset; + gGL.color4fv(timer_bar.mColor.mV); + gl_segmented_rect_2d_fragment_tex(render_rect, + bar_image->getTextureWidth(), bar_image->getTextureHeight(), + 16, + timer_bar.mStartFraction, timer_bar.mEndFraction); + } - bars[bar_rect_index].mRect = bar_rect; - bars[bar_rect_index].mColor = color; + for (TimeBlock::child_iter it = time_block->beginChildren(), end_it = time_block->endChildren(); it != end_it; ++it) + { + ++bar_index; + bar_index = drawBar(*it, timer_bar.mChildrenRect, bars, bar_index, bar_image); } - return bar_rect; + return bar_index; } -- cgit v1.2.3 From eb6c8959ca5b8b3c100114d4d659a48bb4d56b2c Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Sat, 2 Feb 2013 01:09:52 -0800 Subject: SH-3275 WIP interesting Update viewer metrics system to be more flexible fixed most fast timer display and interaction issues --- indra/newview/llfasttimerview.cpp | 198 +++++++++++++++++++++----------------- 1 file changed, 108 insertions(+), 90 deletions(-) (limited to 'indra/newview/llfasttimerview.cpp') diff --git a/indra/newview/llfasttimerview.cpp b/indra/newview/llfasttimerview.cpp index c75f25c0f0..1562d0e13d 100644 --- a/indra/newview/llfasttimerview.cpp +++ b/indra/newview/llfasttimerview.cpp @@ -58,7 +58,6 @@ using namespace LLTrace; static const S32 MAX_VISIBLE_HISTORY = 10; static const S32 LINE_GRAPH_HEIGHT = 240; -static const S32 HISTORY_NUM = 300; static const S32 MIN_BAR_HEIGHT = 3; std::vector ft_display_idx; // line of table entry for display purposes (for collapse) @@ -121,14 +120,15 @@ LLFastTimerView::~LLFastTimerView() void LLFastTimerView::onPause() { - mPauseHistory = !mPauseHistory; - updatePauseState(); + setPauseState(!mPauseHistory); } -void LLFastTimerView::updatePauseState() +void LLFastTimerView::setPauseState(bool pause_state) { + if (pause_state == mPauseHistory) return; + // reset scroll to bottom when unpausing - if (!mPauseHistory) + if (!pause_state) { if (mRecording != &get_frame_recording()) { @@ -144,6 +144,8 @@ void LLFastTimerView::updatePauseState() getChild("pause_btn")->setLabel(getString("run")); } + + mPauseHistory = pause_state; } BOOL LLFastTimerView::postBuild() @@ -260,7 +262,7 @@ BOOL LLFastTimerView::handleHover(S32 x, S32 y, MASK mask) if (hasMouseCapture()) { F32 lerp = llclamp(1.f - (F32) (x - mGraphRect.mLeft) / (F32) mGraphRect.getWidth(), 0.f, 1.f); - mScrollIndex = llround( lerp * (F32)(HISTORY_NUM - MAX_VISIBLE_HISTORY)); + mScrollIndex = llround( lerp * (F32)(mRecording->getNumPeriods() - MAX_VISIBLE_HISTORY)); mScrollIndex = llclamp( mScrollIndex, 0, mRecording->getNumPeriods()); return TRUE; } @@ -269,8 +271,9 @@ BOOL LLFastTimerView::handleHover(S32 x, S32 y, MASK mask) if(mPauseHistory && mBarRect.pointInRect(x, y)) { - mHoverBarIndex = llmin(mRecording->getNumPeriods() - 1, - MAX_VISIBLE_HISTORY - ((y - mBarRect.mBottom) * (MAX_VISIBLE_HISTORY + 2) / mBarRect.getHeight())); + mHoverBarIndex = llmin((mBarRect.mTop - y) / (mBarRect.getHeight() / (MAX_VISIBLE_HISTORY + 2)) - 1, + mRecording->getNumPeriods() - 1, + MAX_VISIBLE_HISTORY); if (mHoverBarIndex == 0) { return TRUE; @@ -322,17 +325,15 @@ BOOL LLFastTimerView::handleHover(S32 x, S32 y, MASK mask) static std::string get_tooltip(TimeBlock& timer, S32 history_index, PeriodicRecording& frame_recording) { - F64 ms_multiplier = 1000.0 / (F64)TimeBlock::countsPerSecond(); - std::string tooltip; - if (history_index < 0) + if (history_index == 0) { // by default, show average number of call - tooltip = llformat("%s (%d ms, %d calls)", timer.getName().c_str(), (S32)(frame_recording.getPeriodMean(timer) * ms_multiplier).value(), (S32)frame_recording.getPeriodMean(timer.callCount())); + tooltip = llformat("%s (%d ms, %d calls)", timer.getName().c_str(), (S32)LLUnit(frame_recording.getPeriodMean(timer)).value(), (S32)frame_recording.getPeriodMean(timer.callCount())); } else { - tooltip = llformat("%s (%d ms, %d calls)", timer.getName().c_str(), (S32)(frame_recording.getPrevRecordingPeriod(history_index).getSum(timer) * ms_multiplier).value(), (S32)frame_recording.getPrevRecordingPeriod(history_index).getSum(timer.callCount())); + tooltip = llformat("%s (%d ms, %d calls)", timer.getName().c_str(), (S32)LLUnit(frame_recording.getPrevRecordingPeriod(history_index).getSum(timer)).value(), (S32)frame_recording.getPrevRecordingPeriod(history_index).getSum(timer.callCount())); } return tooltip; } @@ -347,7 +348,7 @@ BOOL LLFastTimerView::handleToolTip(S32 x, S32 y, MASK mask) LLRect screen_rect; localRectToScreen(mToolTipRect, &screen_rect); - std::string tooltip = get_tooltip(*mHoverTimer, mScrollIndex + mHoverBarIndex, *mRecording); + std::string tooltip = get_tooltip(*mHoverTimer, mHoverBarIndex > 0 ? mScrollIndex + mHoverBarIndex : 0, *mRecording); LLToolTipMgr::instance().show(LLToolTip::Params() .message(tooltip) @@ -365,7 +366,7 @@ BOOL LLFastTimerView::handleToolTip(S32 x, S32 y, MASK mask) TimeBlock* idp = getLegendID(y); if (idp) { - LLToolTipMgr::instance().show(get_tooltip(*idp, -1, *mRecording)); + LLToolTipMgr::instance().show(get_tooltip(*idp, 0, *mRecording)); return TRUE; } @@ -377,11 +378,10 @@ BOOL LLFastTimerView::handleToolTip(S32 x, S32 y, MASK mask) BOOL LLFastTimerView::handleScrollWheel(S32 x, S32 y, S32 clicks) { - mPauseHistory = true; - updatePauseState(); + setPauseState(true); mScrollIndex = llclamp( mScrollIndex + clicks, 0, - llmin(mRecording->getNumPeriods(), (S32)HISTORY_NUM - MAX_VISIBLE_HISTORY)); + llmin(mRecording->getNumPeriods(), (S32)mRecording->getNumPeriods() - MAX_VISIBLE_HISTORY)); return TRUE; } @@ -1004,8 +1004,11 @@ void LLFastTimerView::printLineStats() } } +static LLFastTimer::DeclareTimer FTM_DRAW_LINE_GRAPH("Draw line graph"); + void LLFastTimerView::drawLineGraph() { + LLFastTimer _(FTM_DRAW_LINE_GRAPH); //draw line graph history S32 x = mBarRect.mLeft; S32 y = LINE_GRAPH_HEIGHT; @@ -1024,7 +1027,7 @@ void LLFastTimerView::drawLineGraph() else if (mDisplayHz) axis_label = llformat("%d Hz", (int)(1.f / max_time.value())); else - axis_label = llformat("%4.2f ms", max_time.value()); + axis_label = llformat("%4.2f ms", LLUnit(max_time).value()); x = mGraphRect.mRight - LLFontGL::getFontMonospace()->getWidth(axis_label)-5; y = mGraphRect.mTop - LLFontGL::getFontMonospace()->getLineHeight(); @@ -1034,10 +1037,10 @@ void LLFastTimerView::drawLineGraph() //highlight visible range { - S32 first_frame = HISTORY_NUM - mScrollIndex; + S32 first_frame = mRecording->getNumPeriods() - mScrollIndex; S32 last_frame = first_frame - MAX_VISIBLE_HISTORY; - F32 frame_delta = ((F32) (mGraphRect.getWidth()))/(HISTORY_NUM-1); + F32 frame_delta = ((F32) (mGraphRect.getWidth()))/(mRecording->getNumPeriods()-1); F32 right = (F32) mGraphRect.mLeft + frame_delta*first_frame; F32 left = (F32) mGraphRect.mLeft + frame_delta*last_frame; @@ -1045,9 +1048,9 @@ void LLFastTimerView::drawLineGraph() gGL.color4f(0.5f,0.5f,0.5f,0.3f); gl_rect_2d((S32) left, mGraphRect.mTop, (S32) right, mGraphRect.mBottom); - if (mHoverBarIndex >= 0) + if (mHoverBarIndex > 0) { - S32 bar_frame = first_frame - mHoverBarIndex; + S32 bar_frame = first_frame - mHoverBarIndex - 1; F32 bar = (F32) mGraphRect.mLeft + frame_delta*bar_frame; gGL.color4f(0.5f,0.5f,0.5f,1); @@ -1102,7 +1105,7 @@ void LLFastTimerView::drawLineGraph() cur_max = llmax(cur_max, time); cur_max_calls = llmax(cur_max_calls, calls); } - F32 x = mGraphRect.mRight - j * (F32)(mGraphRect.getWidth())/(HISTORY_NUM-1); + F32 x = mGraphRect.mRight - j * (F32)(mGraphRect.getWidth())/(mRecording->getNumPeriods()-1); F32 y = mDisplayHz ? mGraphRect.mBottom + (1.f / time.value()) * ((F32) mGraphRect.getHeight() / (1.f / max_time.value())) : mGraphRect.mBottom + time / max_time * (F32)mGraphRect.getHeight(); @@ -1123,7 +1126,7 @@ void LLFastTimerView::drawLineGraph() it.skipDescendants(); } } - + //interpolate towards new maximum max_time = lerp(max_time.value(), cur_max.value(), LLCriticalDamp::getInterpolant(0.1f)); if (max_time - cur_max <= 1 || cur_max - max_time <= 1) @@ -1408,7 +1411,7 @@ void LLFastTimerView::drawBars() LLLocalClipRect clip(mBarRect); - S32 bar_height = (mBarRect.mTop - MARGIN - LINE_GRAPH_HEIGHT) / (MAX_VISIBLE_HISTORY + 2); + S32 bar_height = mBarRect.getHeight() / (MAX_VISIBLE_HISTORY + 2); S32 vpad = llmax(1, bar_height / 4); // spacing between bars bar_height -= vpad; @@ -1420,33 +1423,34 @@ void LLFastTimerView::drawBars() // Special: -1 = show running average LLPointer bar_image = LLUI::getUIImage("Rounded_Square"); gGL.getTexUnit(0)->bind(bar_image->getImage()); - const S32 histmax = llmin(mRecording->getNumPeriods()+1, MAX_VISIBLE_HISTORY); + const S32 histmax = llmin(mRecording->getNumPeriods(), MAX_VISIBLE_HISTORY) + 1; - for (S32 j = -1; j < histmax && y > LINE_GRAPH_HEIGHT; j++) + for (S32 bar_index = 0; bar_index < histmax && y > LINE_GRAPH_HEIGHT; bar_index++) { - S32 history_index = (j >= 0) - ? j + 1 + mScrollIndex + S32 history_index = (bar_index > 0) + ? bar_index + mScrollIndex : -1; - S32 rect_index = llmax(j, 0); - mTimerBars[rect_index].clear(); - mTimerBars[rect_index].reserve(LLInstanceTracker::instanceCount()); - - LLRect frame_bar_rect(mBarRect.mLeft, y, mBarRect.mLeft + mTimerBars[rect_index][0].mWidth, y-bar_height); - updateTimerBarWidths(&FTM_FRAME, mTimerBars[rect_index], history_index); - mTimerBars[rect_index][0].mVisibleRect = frame_bar_rect; - updateTimerBarFractions(&FTM_FRAME, 0, mTimerBars[rect_index], history_index, true); - drawBar(&FTM_FRAME, frame_bar_rect, mTimerBars[rect_index], 0, bar_image); - + mTimerBars[bar_index].clear(); + mTimerBars[bar_index].reserve(LLInstanceTracker::instanceCount()); + + updateTimerBarWidths(&FTM_FRAME, mTimerBars[bar_index], history_index, true); + LLRect frame_bar_rect(mBarRect.mLeft, y, mBarRect.mLeft + mTimerBars[bar_index][0].mWidth, y-bar_height); + mTimerBars[bar_index][0].mVisibleRect = frame_bar_rect; + updateTimerBarFractions(&FTM_FRAME, 0, mTimerBars[bar_index]); + drawBar(&FTM_FRAME, frame_bar_rect, mTimerBars[bar_index], 0, bar_image); + y -= (bar_height + vpad); - if (j < 0) + if (bar_index == 0) y -= bar_height; } gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); } +static LLFastTimer::DeclareTimer FTM_UPDATE_TIMER_BAR_WIDTHS("Update timer bar widths"); -S32 LLFastTimerView::updateTimerBarWidths(LLTrace::TimeBlock* time_block, std::vector& bars, S32 history_index) +S32 LLFastTimerView::updateTimerBarWidths(LLTrace::TimeBlock* time_block, std::vector& bars, S32 history_index, bool visible) { + LLFastTimer _(FTM_UPDATE_TIMER_BAR_WIDTHS); F32 self_time_frame_fraction = history_index == -1 ? (mRecording->getPeriodMean(time_block->selfTime()) / mTotalTimeDisplay) : (mRecording->getPrevRecordingPeriod(history_index).getSum(time_block->selfTime()) / mTotalTimeDisplay); @@ -1454,43 +1458,57 @@ S32 LLFastTimerView::updateTimerBarWidths(LLTrace::TimeBlock* time_block, std::v S32 self_time_width = llround(self_time_frame_fraction * (F32)mBarRect.getWidth()); S32 full_width = self_time_width; + bool children_visible = visible; + // reserve a spot for this bar to be rendered before its children // even though we don't know its size yet S32 bar_rect_index = bars.size(); - bars.push_back(TimerBar()); + if (visible) + { + bars.push_back(TimerBar()); + } + if (time_block->getCollapsed()) + { + children_visible = false; + } for (TimeBlock::child_iter it = time_block->beginChildren(), end_it = time_block->endChildren(); it != end_it; ++it) { - full_width += updateTimerBarWidths(*it, bars, history_index); + full_width += updateTimerBarWidths(*it, bars, history_index, children_visible); } - TimerBar& timer_bar = bars[bar_rect_index]; + if (visible) + { + TimerBar& timer_bar = bars[bar_rect_index]; - timer_bar.mWidth = full_width; - timer_bar.mSelfWidth = self_time_width; - timer_bar.mColor = sTimerColors[time_block]; + timer_bar.mWidth = full_width; + timer_bar.mSelfWidth = self_time_width; + timer_bar.mColor = sTimerColors[time_block]; - BOOL is_child_of_hover_item = (time_block == mHoverID); - TimeBlock* next_parent = time_block->getParent(); - while(!is_child_of_hover_item && next_parent) - { - is_child_of_hover_item = (mHoverID == next_parent); - if (next_parent->getParent() == next_parent) break; - next_parent = next_parent->getParent(); - } + BOOL is_child_of_hover_item = (time_block == mHoverID); + TimeBlock* next_parent = time_block->getParent(); + while(!is_child_of_hover_item && next_parent) + { + is_child_of_hover_item = (mHoverID == next_parent); + if (next_parent->getParent() == next_parent) break; + next_parent = next_parent->getParent(); + } - if (mHoverID != NULL - && time_block != mHoverID - && !is_child_of_hover_item) - { - timer_bar.mColor = lerp(timer_bar.mColor, LLColor4::grey, 0.8f); + if (mHoverID != NULL + && time_block != mHoverID + && !is_child_of_hover_item) + { + timer_bar.mColor = lerp(timer_bar.mColor, LLColor4::grey, 0.8f); + } } - return full_width; } -S32 LLFastTimerView::updateTimerBarFractions(LLTrace::TimeBlock* time_block, S32 timer_bar_index, std::vector& bars, S32 history_index, bool draw) +static LLFastTimer::DeclareTimer FTM_UPDATE_TIMER_BAR_FRACTIONS("Update timer bar fractions"); + +S32 LLFastTimerView::updateTimerBarFractions(LLTrace::TimeBlock* time_block, S32 timer_bar_index, std::vector& bars) { + LLFastTimer _(FTM_UPDATE_TIMER_BAR_FRACTIONS); TimerBar& timer_bar = bars[timer_bar_index]; S32 child_time_width = timer_bar.mWidth - timer_bar.mSelfWidth; LLRect children_rect = timer_bar.mVisibleRect; @@ -1511,37 +1529,34 @@ S32 LLFastTimerView::updateTimerBarFractions(LLTrace::TimeBlock* time_block, S32 children_rect.mBottom += 1; } timer_bar.mChildrenRect = children_rect; - timer_bar.mVisible = draw; - - if (time_block->getCollapsed()) - { - draw = false; - } //now loop through children and figure out portion of bar image covered by each bar, now that we know the //sum of all children - F32 bar_fraction_start = 0.f; - for (TimeBlock::child_iter it = time_block->beginChildren(), end_it = time_block->endChildren(); - it != end_it; - ++it) + if (!time_block->getCollapsed()) { - timer_bar_index++; + F32 bar_fraction_start = 0.f; + for (TimeBlock::child_iter it = time_block->beginChildren(), end_it = time_block->endChildren(); + it != end_it; + ++it) + { + timer_bar_index++; - TimerBar& child_timer_bar = bars[timer_bar_index]; - TimeBlock* child_time_block = *it; + TimerBar& child_timer_bar = bars[timer_bar_index]; + TimeBlock* child_time_block = *it; - child_timer_bar.mStartFraction = bar_fraction_start; - child_timer_bar.mEndFraction = child_time_width > 0 - ? bar_fraction_start + (F32)child_timer_bar.mWidth / child_time_width - : 1.f; - child_timer_bar.mVisibleRect.set(children_rect.mLeft + llround(child_timer_bar.mStartFraction * children_rect.getWidth()), - children_rect.mTop, - children_rect.mLeft + llround(child_timer_bar.mEndFraction * children_rect.getWidth()), - children_rect.mBottom); + child_timer_bar.mStartFraction = bar_fraction_start; + child_timer_bar.mEndFraction = child_time_width > 0 + ? bar_fraction_start + (F32)child_timer_bar.mWidth / child_time_width + : 1.f; + child_timer_bar.mVisibleRect.set(children_rect.mLeft + llround(child_timer_bar.mStartFraction * children_rect.getWidth()), + children_rect.mTop, + children_rect.mLeft + llround(child_timer_bar.mEndFraction * children_rect.getWidth()), + children_rect.mBottom); - timer_bar_index = updateTimerBarFractions(child_time_block, timer_bar_index, bars, history_index, draw); + timer_bar_index = updateTimerBarFractions(child_time_block, timer_bar_index, bars); - bar_fraction_start = child_timer_bar.mEndFraction; + bar_fraction_start = child_timer_bar.mEndFraction; + } } return timer_bar_index; } @@ -1551,7 +1566,7 @@ S32 LLFastTimerView::drawBar(LLTrace::TimeBlock* time_block, LLRect bar_rect, st TimerBar& timer_bar = bars[bar_index]; // animate scale of bar when hovering over that particular timer - if (bar_rect.getWidth() > 0 && timer_bar.mVisible) + if (bar_rect.getWidth() > 0) { LLRect render_rect(bar_rect); S32 scale_offset = 0; @@ -1569,10 +1584,13 @@ S32 LLFastTimerView::drawBar(LLTrace::TimeBlock* time_block, LLRect bar_rect, st timer_bar.mStartFraction, timer_bar.mEndFraction); } - for (TimeBlock::child_iter it = time_block->beginChildren(), end_it = time_block->endChildren(); it != end_it; ++it) + if (!time_block->getCollapsed()) { - ++bar_index; - bar_index = drawBar(*it, timer_bar.mChildrenRect, bars, bar_index, bar_image); + for (TimeBlock::child_iter it = time_block->beginChildren(), end_it = time_block->endChildren(); it != end_it; ++it) + { + ++bar_index; + bar_index = drawBar(*it, timer_bar.mChildrenRect, bars, bar_index, bar_image); + } } return bar_index; -- cgit v1.2.3 From b49cdb1c7aee0f02e9f7eedee9295424e4dec213 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Tue, 5 Feb 2013 11:31:45 -0800 Subject: SH-3275 WIP interesting Update viewer metrics system to be more flexible quantized fast timer range to nearest 20ms for easier reading --- indra/newview/llfasttimerview.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'indra/newview/llfasttimerview.cpp') diff --git a/indra/newview/llfasttimerview.cpp b/indra/newview/llfasttimerview.cpp index 1562d0e13d..7d23687e21 100644 --- a/indra/newview/llfasttimerview.cpp +++ b/indra/newview/llfasttimerview.cpp @@ -1402,6 +1402,8 @@ void LLFastTimerView::updateTotalTime() mTotalTimeDisplay = LLUnit(100); break; } + + mTotalTimeDisplay = LLUnit(llceil(mTotalTimeDisplay.as().value() / (20.f)) * 20.f); } void LLFastTimerView::drawBars() -- cgit v1.2.3 From 438cbfe489cc34261ac600bbb22983164e59b1d9 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Thu, 7 Feb 2013 20:07:31 -0800 Subject: SH-3275 WIP interesting Update viewer metrics system to be more flexible fix for timings for recursive fast timers not being correct --- indra/newview/llfasttimerview.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/newview/llfasttimerview.cpp') diff --git a/indra/newview/llfasttimerview.cpp b/indra/newview/llfasttimerview.cpp index 7d23687e21..1a1a4a8b44 100644 --- a/indra/newview/llfasttimerview.cpp +++ b/indra/newview/llfasttimerview.cpp @@ -1403,7 +1403,7 @@ void LLFastTimerView::updateTotalTime() break; } - mTotalTimeDisplay = LLUnit(llceil(mTotalTimeDisplay.as().value() / (20.f)) * 20.f); + mTotalTimeDisplay = LLUnit(llceil(mTotalTimeDisplay.as().value() / (20.f)) * 20.f); } void LLFastTimerView::drawBars() -- cgit v1.2.3 From a6bb68b6e530df91d03abfc062c700ebc4e856aa Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Wed, 13 Feb 2013 15:21:20 -0800 Subject: SH-3275 FIX interesting Update viewer metrics system to be more flexible fix for inaccurate optimization of full block time calculations --- indra/newview/llfasttimerview.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/newview/llfasttimerview.cpp') diff --git a/indra/newview/llfasttimerview.cpp b/indra/newview/llfasttimerview.cpp index 1a1a4a8b44..3893b0e772 100644 --- a/indra/newview/llfasttimerview.cpp +++ b/indra/newview/llfasttimerview.cpp @@ -1403,7 +1403,7 @@ void LLFastTimerView::updateTotalTime() break; } - mTotalTimeDisplay = LLUnit(llceil(mTotalTimeDisplay.as().value() / (20.f)) * 20.f); + mTotalTimeDisplay = LLUnit(llceil(mTotalTimeDisplay.as().value() / 20.f) * 20.f); } void LLFastTimerView::drawBars() -- cgit v1.2.3 From 8de397b19ec9e2f6206fd5ae57dba96c70e78b74 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Mon, 18 Mar 2013 08:43:03 -0700 Subject: SH-3931 WIP Interesting: Add graphs to visualize scene load metrics changed LLCriticalDamp to LLSmoothInterpolation and sped up interpolator lookup improvements to stats display of llstatbar added scene load stats floater accessed with ctrl|shift|2 --- indra/newview/llfasttimerview.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'indra/newview/llfasttimerview.cpp') diff --git a/indra/newview/llfasttimerview.cpp b/indra/newview/llfasttimerview.cpp index 3893b0e772..f55535b6e3 100644 --- a/indra/newview/llfasttimerview.cpp +++ b/indra/newview/llfasttimerview.cpp @@ -1128,13 +1128,13 @@ void LLFastTimerView::drawLineGraph() } //interpolate towards new maximum - max_time = lerp(max_time.value(), cur_max.value(), LLCriticalDamp::getInterpolant(0.1f)); + max_time = lerp(max_time.value(), cur_max.value(), LLSmoothInterpolation::getInterpolant(0.1f)); if (max_time - cur_max <= 1 || cur_max - max_time <= 1) { max_time = llmax(LLUnit(1), LLUnit(cur_max)); } - max_calls = llround(lerp((F32)max_calls, (F32) cur_max_calls, LLCriticalDamp::getInterpolant(0.1f))); + max_calls = llround(lerp((F32)max_calls, (F32) cur_max_calls, LLSmoothInterpolation::getInterpolant(0.1f))); if (llabs((S32)(max_calls - cur_max_calls)) <= 1) { max_calls = cur_max_calls; @@ -1144,7 +1144,7 @@ void LLFastTimerView::drawLineGraph() F32 alpha_target = (max_time > cur_max) ? llmin(max_time / cur_max - 1.f,1.f) : llmin(cur_max/ max_time - 1.f,1.f); - alpha_interp = lerp(alpha_interp, alpha_target, LLCriticalDamp::getInterpolant(0.1f)); + alpha_interp = lerp(alpha_interp, alpha_target, LLSmoothInterpolation::getInterpolant(0.1f)); if (mHoverID != NULL) { -- cgit v1.2.3 From 1f507c3cfca0c7722ebeaf71883fbaa83988e1a9 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Thu, 21 Mar 2013 00:37:20 -0700 Subject: SH-3931 WIP Interesting: Add graphs to visualize scene load metrics copied over scene load frame differencing changes from viewer-interesting made periodicrecording flexible enough to allow for indefinite number of periods added scene loading stats floater fixed collapsing behavior of container views --- indra/newview/llfasttimerview.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'indra/newview/llfasttimerview.cpp') diff --git a/indra/newview/llfasttimerview.cpp b/indra/newview/llfasttimerview.cpp index f55535b6e3..6caa89a611 100644 --- a/indra/newview/llfasttimerview.cpp +++ b/indra/newview/llfasttimerview.cpp @@ -263,7 +263,7 @@ BOOL LLFastTimerView::handleHover(S32 x, S32 y, MASK mask) { F32 lerp = llclamp(1.f - (F32) (x - mGraphRect.mLeft) / (F32) mGraphRect.getWidth(), 0.f, 1.f); mScrollIndex = llround( lerp * (F32)(mRecording->getNumPeriods() - MAX_VISIBLE_HISTORY)); - mScrollIndex = llclamp( mScrollIndex, 0, mRecording->getNumPeriods()); + mScrollIndex = llclamp( mScrollIndex, 0, (S32)mRecording->getNumPeriods()); return TRUE; } mHoverTimer = NULL; @@ -272,7 +272,7 @@ BOOL LLFastTimerView::handleHover(S32 x, S32 y, MASK mask) if(mPauseHistory && mBarRect.pointInRect(x, y)) { mHoverBarIndex = llmin((mBarRect.mTop - y) / (mBarRect.getHeight() / (MAX_VISIBLE_HISTORY + 2)) - 1, - mRecording->getNumPeriods() - 1, + (S32)mRecording->getNumPeriods() - 1, MAX_VISIBLE_HISTORY); if (mHoverBarIndex == 0) { @@ -381,7 +381,7 @@ BOOL LLFastTimerView::handleScrollWheel(S32 x, S32 y, S32 clicks) setPauseState(true); mScrollIndex = llclamp( mScrollIndex + clicks, 0, - llmin(mRecording->getNumPeriods(), (S32)mRecording->getNumPeriods() - MAX_VISIBLE_HISTORY)); + llmin((S32)mRecording->getNumPeriods(), (S32)mRecording->getNumPeriods() - MAX_VISIBLE_HISTORY)); return TRUE; } @@ -1425,7 +1425,7 @@ void LLFastTimerView::drawBars() // Special: -1 = show running average LLPointer bar_image = LLUI::getUIImage("Rounded_Square"); gGL.getTexUnit(0)->bind(bar_image->getImage()); - const S32 histmax = llmin(mRecording->getNumPeriods(), MAX_VISIBLE_HISTORY) + 1; + const S32 histmax = llmin((S32)mRecording->getNumPeriods(), MAX_VISIBLE_HISTORY) + 1; for (S32 bar_index = 0; bar_index < histmax && y > LINE_GRAPH_HEIGHT; bar_index++) { -- cgit v1.2.3 From 07ca6fce7c9cffe1b8f215f25bb826fedf57a5b7 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Wed, 10 Apr 2013 21:51:56 -0700 Subject: SH-3931 WIP Interesting: Add graphs to visualize scene load metrics removed PeriodicRecording::getTotalRecording as it was showing up at the top on the profiler renamed getPrevRecordingPeriod, etc. to getPrevRecording --- indra/newview/llfasttimerview.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'indra/newview/llfasttimerview.cpp') diff --git a/indra/newview/llfasttimerview.cpp b/indra/newview/llfasttimerview.cpp index 80d845c70e..45ffe56ac1 100644 --- a/indra/newview/llfasttimerview.cpp +++ b/indra/newview/llfasttimerview.cpp @@ -333,7 +333,7 @@ static std::string get_tooltip(TimeBlock& timer, S32 history_index, PeriodicReco } else { - tooltip = llformat("%s (%d ms, %d calls)", timer.getName().c_str(), (S32)LLUnit(frame_recording.getPrevRecordingPeriod(history_index).getSum(timer)).value(), (S32)frame_recording.getPrevRecordingPeriod(history_index).getSum(timer.callCount())); + tooltip = llformat("%s (%d ms, %d calls)", timer.getName().c_str(), (S32)LLUnit(frame_recording.getPrevRecording(history_index).getSum(timer)).value(), (S32)frame_recording.getPrevRecording(history_index).getSum(timer.callCount())); } return tooltip; } @@ -417,7 +417,7 @@ void LLFastTimerView::draw() printLineStats(); LLView::draw(); - mAllTimeMax = llmax(mAllTimeMax, mRecording->getLastRecordingPeriod().getSum(FTM_FRAME)); + mAllTimeMax = llmax(mAllTimeMax, mRecording->getLastRecording().getSum(FTM_FRAME)); mHoverID = NULL; mHoverBarIndex = -1; } @@ -984,7 +984,7 @@ void LLFastTimerView::printLineStats() LLUnit ticks; if (mPrintStats > 0) { - ticks = mRecording->getPrevRecordingPeriod(mPrintStats).getSum(*idp); + ticks = mRecording->getPrevRecording(mPrintStats).getSum(*idp); } else { @@ -1096,8 +1096,8 @@ void LLFastTimerView::drawLineGraph() j > 0; j--) { - LLUnit time = llmax(mRecording->getPrevRecordingPeriod(j).getSum(*idp), LLUnit(0.000001)); - U32 calls = mRecording->getPrevRecordingPeriod(j).getSum(idp->callCount()); + LLUnit time = llmax(mRecording->getPrevRecording(j).getSum(*idp), LLUnit(0.000001)); + U32 calls = mRecording->getPrevRecording(j).getSum(idp->callCount()); if (alpha == 1.f) { @@ -1197,8 +1197,8 @@ void LLFastTimerView::drawLegend( S32 y ) if (mHoverBarIndex > 0 && mHoverID) { S32 hidx = mScrollIndex + mHoverBarIndex; - ms = mRecording->getPrevRecordingPeriod(hidx).getSum(*idp); - calls = mRecording->getPrevRecordingPeriod(hidx).getSum(idp->callCount()); + ms = mRecording->getPrevRecording(hidx).getSum(*idp); + calls = mRecording->getPrevRecording(hidx).getSum(idp->callCount()); } else { @@ -1455,7 +1455,7 @@ S32 LLFastTimerView::updateTimerBarWidths(LLTrace::TimeBlock* time_block, std::v LLFastTimer _(FTM_UPDATE_TIMER_BAR_WIDTHS); F32 self_time_frame_fraction = history_index == -1 ? (mRecording->getPeriodMean(time_block->selfTime()) / mTotalTimeDisplay) - : (mRecording->getPrevRecordingPeriod(history_index).getSum(time_block->selfTime()) / mTotalTimeDisplay); + : (mRecording->getPrevRecording(history_index).getSum(time_block->selfTime()) / mTotalTimeDisplay); S32 self_time_width = llround(self_time_frame_fraction * (F32)mBarRect.getWidth()); S32 full_width = self_time_width; -- cgit v1.2.3 From fbce0030494ccb6fa8f6cf45e1ec95a2fa922bcd Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Mon, 20 May 2013 12:47:23 -0700 Subject: SH-3931 WIP Interesting: Add graphs to visualize scene load metrics killed LLFastTimerView::getTime fixed block time stats always being 0 --- indra/newview/llfasttimerview.cpp | 7 ------- 1 file changed, 7 deletions(-) (limited to 'indra/newview/llfasttimerview.cpp') diff --git a/indra/newview/llfasttimerview.cpp b/indra/newview/llfasttimerview.cpp index 45ffe56ac1..b78dd08bf1 100644 --- a/indra/newview/llfasttimerview.cpp +++ b/indra/newview/llfasttimerview.cpp @@ -422,13 +422,6 @@ void LLFastTimerView::draw() mHoverBarIndex = -1; } -F64 LLFastTimerView::getTime(const std::string& name) -{ - //TODO: replace calls to this with use of timer object directly - //llstatic_assert(false, "TODO: implement"); - return 0.0; -} - void saveChart(const std::string& label, const char* suffix, LLImageRaw* scratch) { //read result back into raw image -- cgit v1.2.3 From 9fd3af3c389ed491b515cbb5136b344b069913e4 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Thu, 13 Jun 2013 15:29:15 -0700 Subject: SH-3931 WIP Interesting: Add graphs to visualize scene load metrics changed Units macros and argument order to make it more clear optimized units for integer types fixed merging of periodicrecordings...should eliminate duplicate entries in sceneloadmonitor history --- indra/newview/llfasttimerview.cpp | 303 ++++++++++++++++++++------------------ 1 file changed, 162 insertions(+), 141 deletions(-) (limited to 'indra/newview/llfasttimerview.cpp') diff --git a/indra/newview/llfasttimerview.cpp b/indra/newview/llfasttimerview.cpp index 40526d3357..8e061ec87c 100755 --- a/indra/newview/llfasttimerview.cpp +++ b/indra/newview/llfasttimerview.cpp @@ -101,21 +101,15 @@ LLFastTimerView::LLFastTimerView(const LLSD& key) mScrollIndex(0), mHoverID(NULL), mHoverBarIndex(-1), - mPrintStats(-1), - mRecording(&get_frame_recording()), - mPauseHistory(false) + mStatsIndex(-1), + mPauseHistory(false), + mRecording(512) { - mTimerBars = new std::vector[MAX_VISIBLE_HISTORY + 1]; + mTimerBarRows.resize(MAX_VISIBLE_HISTORY); } LLFastTimerView::~LLFastTimerView() { - if (mRecording != &get_frame_recording()) - { - delete mRecording; - } - mRecording = NULL; - delete [] mTimerBars; } void LLFastTimerView::onPause() @@ -130,16 +124,11 @@ void LLFastTimerView::setPauseState(bool pause_state) // reset scroll to bottom when unpausing if (!pause_state) { - if (mRecording != &get_frame_recording()) - { - delete mRecording; - } - mRecording = &get_frame_recording(); + getChild("pause_btn")->setLabel(getString("pause")); } else { - mRecording = new PeriodicRecording(get_frame_recording()); mScrollIndex = 0; getChild("pause_btn")->setLabel(getString("run")); @@ -175,7 +164,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 = mScrollIndex + bar_idx; + mStatsIndex = mScrollIndex + bar_idx; return TRUE; } return LLFloater::handleRightMouseDown(x, y, mask); @@ -262,8 +251,8 @@ BOOL LLFastTimerView::handleHover(S32 x, S32 y, MASK mask) if (hasMouseCapture()) { F32 lerp = llclamp(1.f - (F32) (x - mGraphRect.mLeft) / (F32) mGraphRect.getWidth(), 0.f, 1.f); - mScrollIndex = llround( lerp * (F32)(mRecording->getNumPeriods() - MAX_VISIBLE_HISTORY)); - mScrollIndex = llclamp( mScrollIndex, 0, (S32)mRecording->getNumPeriods()); + mScrollIndex = llround( lerp * (F32)(mRecording.getNumRecordedPeriods() - MAX_VISIBLE_HISTORY)); + mScrollIndex = llclamp( mScrollIndex, 0, (S32)mRecording.getNumRecordedPeriods()); return TRUE; } mHoverTimer = NULL; @@ -272,7 +261,7 @@ BOOL LLFastTimerView::handleHover(S32 x, S32 y, MASK mask) if(mPauseHistory && mBarRect.pointInRect(x, y)) { mHoverBarIndex = llmin((mBarRect.mTop - y) / (mBarRect.getHeight() / (MAX_VISIBLE_HISTORY + 2)) - 1, - (S32)mRecording->getNumPeriods() - 1, + (S32)mRecording.getNumRecordedPeriods() - 1, MAX_VISIBLE_HISTORY); if (mHoverBarIndex == 0) { @@ -289,7 +278,8 @@ BOOL LLFastTimerView::handleHover(S32 x, S32 y, MASK mask) ++it, ++i) { // is mouse over bar for this timer? - if (mTimerBars[mHoverBarIndex][i].mVisibleRect.pointInRect(x, y)) + TimerBarRow& row = mHoverBarIndex == 0 ? mAverageTimerRow : mTimerBarRows[mHoverBarIndex - 1]; + if (row.mBars[i].mVisibleRect.pointInRect(x, y - row.mBottom)) { mHoverID = (*it); if (mHoverTimer != *it) @@ -301,7 +291,8 @@ BOOL LLFastTimerView::handleHover(S32 x, S32 y, MASK mask) mHoverTimer = (*it); } - mToolTipRect = mTimerBars[mHoverBarIndex][i].mVisibleRect; + mToolTipRect = row.mBars[i].mVisibleRect; + mToolTipRect.translate(0, row.mBottom); } if ((*it)->getCollapsed()) @@ -329,11 +320,11 @@ static std::string get_tooltip(TimeBlock& timer, S32 history_index, PeriodicReco if (history_index == 0) { // by default, show average number of call - tooltip = llformat("%s (%d ms, %d calls)", timer.getName().c_str(), (S32)LLUnit(frame_recording.getPeriodMean(timer)).value(), (S32)frame_recording.getPeriodMean(timer.callCount())); + tooltip = llformat("%s (%d ms, %d calls)", timer.getName().c_str(), (S32)LLUnit(frame_recording.getPeriodMean(timer)).value(), (S32)frame_recording.getPeriodMean(timer.callCount())); } else { - tooltip = llformat("%s (%d ms, %d calls)", timer.getName().c_str(), (S32)LLUnit(frame_recording.getPrevRecording(history_index).getSum(timer)).value(), (S32)frame_recording.getPrevRecording(history_index).getSum(timer.callCount())); + tooltip = llformat("%s (%d ms, %d calls)", timer.getName().c_str(), (S32)LLUnit(frame_recording.getPrevRecording(history_index).getSum(timer)).value(), (S32)frame_recording.getPrevRecording(history_index).getSum(timer.callCount())); } return tooltip; } @@ -348,7 +339,7 @@ BOOL LLFastTimerView::handleToolTip(S32 x, S32 y, MASK mask) LLRect screen_rect; localRectToScreen(mToolTipRect, &screen_rect); - std::string tooltip = get_tooltip(*mHoverTimer, mHoverBarIndex > 0 ? mScrollIndex + mHoverBarIndex : 0, *mRecording); + std::string tooltip = get_tooltip(*mHoverTimer, mHoverBarIndex > 0 ? mScrollIndex + mHoverBarIndex : 0, mRecording); LLToolTipMgr::instance().show(LLToolTip::Params() .message(tooltip) @@ -366,7 +357,7 @@ BOOL LLFastTimerView::handleToolTip(S32 x, S32 y, MASK mask) TimeBlock* idp = getLegendID(y); if (idp) { - LLToolTipMgr::instance().show(get_tooltip(*idp, 0, *mRecording)); + LLToolTipMgr::instance().show(get_tooltip(*idp, 0, mRecording)); return TRUE; } @@ -381,7 +372,7 @@ BOOL LLFastTimerView::handleScrollWheel(S32 x, S32 y, S32 clicks) setPauseState(true); mScrollIndex = llclamp( mScrollIndex + clicks, 0, - llmin((S32)mRecording->getNumPeriods(), (S32)mRecording->getNumPeriods() - MAX_VISIBLE_HISTORY)); + llmin((S32)mRecording.getNumRecordedPeriods(), (S32)mRecording.getNumRecordedPeriods() - MAX_VISIBLE_HISTORY)); return TRUE; } @@ -389,12 +380,19 @@ static TimeBlock FTM_RENDER_TIMER("Timers", true); static const S32 MARGIN = 10; static const S32 LEGEND_WIDTH = 220; -static std::map sTimerColors; +static std::vector sTimerColors; void LLFastTimerView::draw() { LLFastTimer t(FTM_RENDER_TIMER); + if (!mPauseHistory) + { + mRecording.appendRecording(LLTrace::get_frame_recording().getLastRecording()); + mTimerBarRows.pop_back(); + mTimerBarRows.push_front(TimerBarRow()); + } + generateUniqueColors(); // Draw the window background @@ -417,11 +415,20 @@ void LLFastTimerView::draw() printLineStats(); LLView::draw(); - mAllTimeMax = llmax(mAllTimeMax, mRecording->getLastRecording().getSum(FTM_FRAME)); + mAllTimeMax = llmax(mAllTimeMax, mRecording.getLastRecording().getSum(FTM_FRAME)); mHoverID = NULL; mHoverBarIndex = -1; } +void LLFastTimerView::onOpen(const LLSD& key) +{ + if (mRecording.getNumRecordedPeriods() == 0) + { + mRecording.appendPeriodicRecording(LLTrace::get_frame_recording()); + } +} + + void saveChart(const std::string& label, const char* suffix, LLImageRaw* scratch) { //read result back into raw image @@ -828,7 +835,7 @@ void LLFastTimerView::doAnalysisDefault(std::string baseline, std::string target LLSD current = analyzePerformanceLogDefault(target_is); target_is.close(); - //output comparision + //output comparison std::ofstream os(output.c_str()); LLSD::Real session_time = current["SessionTime"].asReal(); @@ -936,7 +943,7 @@ void LLFastTimerView::onClickCloseBtn() void LLFastTimerView::printLineStats() { // Output stats for clicked bar to log - if (mPrintStats >= 0) + if (mStatsIndex >= 0) { std::string legend_stat; bool first = true; @@ -974,16 +981,16 @@ void LLFastTimerView::printLineStats() } first = false; - LLUnit ticks; - if (mPrintStats > 0) + LLUnit ticks; + if (mStatsIndex == 0) { - ticks = mRecording->getPrevRecording(mPrintStats).getSum(*idp); + ticks = mRecording.getPeriodMean(*idp); } else { - ticks = mRecording->getPeriodMean(*idp); + ticks = mRecording.getPrevRecording(mStatsIndex).getSum(*idp); } - LLUnit ms = ticks; + LLUnit ms = ticks; timer_stat += llformat("%.1f",ms.value()); @@ -993,7 +1000,7 @@ void LLFastTimerView::printLineStats() } } llinfos << timer_stat << llendl; - mPrintStats = -1; + mStatsIndex = -1; } } @@ -1009,7 +1016,7 @@ void LLFastTimerView::drawLineGraph() LLLocalClipRect clip(mGraphRect); //normalize based on last frame's maximum - static LLUnit max_time = 0.000001; + static LLUnit max_time = 0.000001; static U32 max_calls = 0; static F32 alpha_interp = 0.f; @@ -1020,7 +1027,7 @@ void LLFastTimerView::drawLineGraph() else if (mDisplayHz) axis_label = llformat("%d Hz", (int)(1.f / max_time.value())); else - axis_label = llformat("%4.2f ms", LLUnit(max_time).value()); + axis_label = llformat("%4.2f ms", LLUnit(max_time).value()); x = mGraphRect.mRight - LLFontGL::getFontMonospace()->getWidth(axis_label)-5; y = mGraphRect.mTop - LLFontGL::getFontMonospace()->getLineHeight(); @@ -1030,10 +1037,10 @@ void LLFastTimerView::drawLineGraph() //highlight visible range { - S32 first_frame = mRecording->getNumPeriods() - mScrollIndex; + S32 first_frame = mRecording.getNumRecordedPeriods() - mScrollIndex; S32 last_frame = first_frame - MAX_VISIBLE_HISTORY; - F32 frame_delta = ((F32) (mGraphRect.getWidth()))/(mRecording->getNumPeriods()-1); + F32 frame_delta = ((F32) (mGraphRect.getWidth()))/(mRecording.getNumRecordedPeriods()-1); F32 right = (F32) mGraphRect.mLeft + frame_delta*first_frame; F32 left = (F32) mGraphRect.mLeft + frame_delta*last_frame; @@ -1055,7 +1062,7 @@ void LLFastTimerView::drawLineGraph() } } - LLUnit cur_max = 0; + LLUnit cur_max = 0; U32 cur_max_calls = 0; for(timer_tree_iterator_t it = begin_timer_tree(FTM_FRAME); it != end_timer_tree(); @@ -1070,7 +1077,7 @@ void LLFastTimerView::drawLineGraph() glLineWidth(3); } - const F32 * col = sTimerColors[idp].mV;// ft_display_table[idx].color->mV; + const F32 * col = sTimerColors[idp->getIndex()].mV;// ft_display_table[idx].color->mV; F32 alpha = 1.f; @@ -1085,12 +1092,13 @@ void LLFastTimerView::drawLineGraph() gGL.color4f(col[0], col[1], col[2], alpha); gGL.begin(LLRender::TRIANGLE_STRIP); - for (U32 j = mRecording->getNumPeriods(); + for (U32 j = mRecording.getNumRecordedPeriods(); j > 0; j--) { - LLUnit time = llmax(mRecording->getPrevRecording(j).getSum(*idp), LLUnit(0.000001)); - U32 calls = mRecording->getPrevRecording(j).getSum(idp->callCount()); + LLTrace::Recording& recording = mRecording.getPrevRecording(j); + LLUnit time = llmax(recording.getSum(*idp), LLUnit(0.000001)); + U32 calls = recording.getSum(idp->callCount()); if (alpha == 1.f) { @@ -1098,7 +1106,7 @@ void LLFastTimerView::drawLineGraph() cur_max = llmax(cur_max, time); cur_max_calls = llmax(cur_max_calls, calls); } - F32 x = mGraphRect.mRight - j * (F32)(mGraphRect.getWidth())/(mRecording->getNumPeriods()-1); + F32 x = mGraphRect.mRight - j * (F32)(mGraphRect.getWidth())/(mRecording.getNumRecordedPeriods()-1); F32 y = mDisplayHz ? mGraphRect.mBottom + (1.f / time.value()) * ((F32) mGraphRect.getHeight() / (1.f / max_time.value())) : mGraphRect.mBottom + time / max_time * (F32)mGraphRect.getHeight(); @@ -1124,7 +1132,7 @@ void LLFastTimerView::drawLineGraph() max_time = lerp(max_time.value(), cur_max.value(), LLSmoothInterpolation::getInterpolant(0.1f)); if (max_time - cur_max <= 1 || cur_max - max_time <= 1) { - max_time = llmax(LLUnit(1), LLUnit(cur_max)); + max_time = llmax(LLUnit(1), LLUnit(cur_max)); } max_calls = llround(lerp((F32)max_calls, (F32) cur_max_calls, LLSmoothInterpolation::getInterpolant(0.1f))); @@ -1183,20 +1191,20 @@ void LLFastTimerView::drawLegend( S32 y ) scale_offset = llfloor(sinf(mHighlightTimer.getElapsedTimeF32() * 6.f) * 2.f); } bar_rect.stretch(scale_offset); - gl_rect_2d(bar_rect, sTimerColors[idp]); + gl_rect_2d(bar_rect, sTimerColors[idp->getIndex()]); - LLUnit ms = 0; + LLUnit ms = 0; S32 calls = 0; if (mHoverBarIndex > 0 && mHoverID) { S32 hidx = mScrollIndex + mHoverBarIndex; - ms = mRecording->getPrevRecording(hidx).getSum(*idp); - calls = mRecording->getPrevRecording(hidx).getSum(idp->callCount()); + ms = mRecording.getPrevRecording(hidx).getSum(*idp); + calls = mRecording.getPrevRecording(hidx).getSum(idp->callCount()); } else { - ms = LLUnit(mRecording->getPeriodMean(*idp)); - calls = (S32)mRecording->getPeriodMean(idp->callCount()); + ms = LLUnit(mRecording.getPeriodMean(*idp)); + calls = (S32)mRecording.getPeriodMean(idp->callCount()); } std::string timer_label; @@ -1254,7 +1262,8 @@ void LLFastTimerView::generateUniqueColors() { // generate unique colors { - sTimerColors[&FTM_FRAME] = LLColor4::grey; + sTimerColors.reserve(LLTrace::TimeBlock::getNumIndices()); + sTimerColors[FTM_FRAME.getIndex()] = LLColor4::grey; F32 hue = 0.f; @@ -1274,7 +1283,7 @@ void LLFastTimerView::generateUniqueColors() LLColor4 child_color; child_color.setHSL(hue, saturation, lightness); - sTimerColors[idp] = child_color; + sTimerColors[idp->getIndex()] = child_color; } } } @@ -1315,7 +1324,7 @@ void LLFastTimerView::drawTicks() { // Draw MS ticks { - LLUnit ms = mTotalTimeDisplay; + LLUnit ms = mTotalTimeDisplay; std::string tick_label; S32 x; S32 barw = mBarRect.getWidth(); @@ -1382,127 +1391,127 @@ void LLFastTimerView::updateTotalTime() switch(mDisplayMode) { case 0: - mTotalTimeDisplay = mRecording->getPeriodMean(FTM_FRAME)*2; + mTotalTimeDisplay = mRecording.getPeriodMean(FTM_FRAME)*2; break; case 1: mTotalTimeDisplay = mAllTimeMax; break; case 2: // Calculate the max total ticks for the current history - mTotalTimeDisplay = mRecording->getPeriodMax(FTM_FRAME); + mTotalTimeDisplay = mRecording.getPeriodMax(FTM_FRAME); break; default: - mTotalTimeDisplay = LLUnit(100); + mTotalTimeDisplay = LLUnit(100); break; } - mTotalTimeDisplay = LLUnit(llceil(mTotalTimeDisplay.as().value() / 20.f) * 20.f); + mTotalTimeDisplay = LLUnit(llceil(mTotalTimeDisplay.as().value() / 20.f) * 20.f); } void LLFastTimerView::drawBars() { - updateTotalTime(); - if (mTotalTimeDisplay <= 0.0) return; - LLLocalClipRect clip(mBarRect); S32 bar_height = mBarRect.getHeight() / (MAX_VISIBLE_HISTORY + 2); - S32 vpad = llmax(1, bar_height / 4); // spacing between bars + const S32 vpad = llmax(1, bar_height / 4); // spacing between bars bar_height -= vpad; + updateTotalTime(); + if (mTotalTimeDisplay <= 0.0) return; + drawTicks(); - S32 y = mBarRect.mTop - ((S32)LLFontGL::getFontMonospace()->getLineHeight() + 4); - drawBorders(y, mBarRect.mLeft, bar_height, vpad); + const S32 bars_top = mBarRect.mTop - ((S32)LLFontGL::getFontMonospace()->getLineHeight() + 4); + drawBorders(bars_top, mBarRect.mLeft, bar_height, vpad); // Draw bars for each history entry - // Special: -1 = show running average + // Special: 0 = show running average LLPointer bar_image = LLUI::getUIImage("Rounded_Square"); + + const S32 image_width = bar_image->getTextureWidth(); + const S32 image_height = bar_image->getTextureHeight(); + gGL.getTexUnit(0)->bind(bar_image->getImage()); - const S32 histmax = llmin((S32)mRecording->getNumPeriods(), MAX_VISIBLE_HISTORY) + 1; + { + const S32 histmax = llmin((S32)mRecording.getNumRecordedPeriods(), MAX_VISIBLE_HISTORY); - for (S32 bar_index = 0; bar_index < histmax && y > LINE_GRAPH_HEIGHT; bar_index++) - { - S32 history_index = (bar_index > 0) - ? bar_index + mScrollIndex - : -1; - mTimerBars[bar_index].clear(); - mTimerBars[bar_index].reserve(LLInstanceTracker::instanceCount()); - - updateTimerBarWidths(&FTM_FRAME, mTimerBars[bar_index], history_index, true); - LLRect frame_bar_rect(mBarRect.mLeft, y, mBarRect.mLeft + mTimerBars[bar_index][0].mWidth, y-bar_height); - mTimerBars[bar_index][0].mVisibleRect = frame_bar_rect; - updateTimerBarFractions(&FTM_FRAME, 0, mTimerBars[bar_index]); - drawBar(&FTM_FRAME, frame_bar_rect, mTimerBars[bar_index], 0, bar_image); - - y -= (bar_height + vpad); - if (bar_index == 0) - y -= bar_height; - } + llassert(mTimerBarRows.size() >= histmax); + + // update widths + updateTimerBarWidths(&FTM_FRAME, mAverageTimerRow, -1); + mAverageTimerRow.mBars[0].mVisibleRect = LLRect(mBarRect.mLeft, 0, mBarRect.mLeft + mAverageTimerRow.mBars[0].mWidth, -bar_height); + updateTimerBarFractions(&FTM_FRAME, mAverageTimerRow); + + for (S32 history_index = 0; history_index < histmax; history_index++) + { + TimerBarRow& row = mTimerBarRows[history_index]; + if (row.mBars.empty()) + { + row.mBars.reserve(LLInstanceTracker::instanceCount()); + updateTimerBarWidths(&FTM_FRAME, row, history_index); + row.mBars[0].mVisibleRect = LLRect(mBarRect.mLeft, 0, mBarRect.mLeft + row.mBars[0].mWidth, -1); + updateTimerBarFractions(&FTM_FRAME, row); + } + } + + // draw bars + LLRect frame_bar_rect( mBarRect.mLeft, + bars_top, + mBarRect.mLeft + mAverageTimerRow.mBars[0].mWidth, + bars_top - bar_height); + mAverageTimerRow.mBottom = frame_bar_rect.mBottom; + drawBar(&FTM_FRAME, frame_bar_rect, mAverageTimerRow, image_width, image_height, false); + frame_bar_rect.translate(0, -(bar_height + vpad + bar_height)); + + for(S32 bar_index = mScrollIndex; bar_index < llmin(histmax, mScrollIndex + MAX_VISIBLE_HISTORY); ++bar_index) + { + TimerBarRow& row = mTimerBarRows[bar_index]; + row.mBottom = frame_bar_rect.mBottom; + drawBar(&FTM_FRAME, frame_bar_rect, row, image_width, image_height, false); + + frame_bar_rect.translate(0, -(bar_height + vpad)); + } + + } gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); } static LLFastTimer::DeclareTimer FTM_UPDATE_TIMER_BAR_WIDTHS("Update timer bar widths"); -S32 LLFastTimerView::updateTimerBarWidths(LLTrace::TimeBlock* time_block, std::vector& bars, S32 history_index, bool visible) +S32 LLFastTimerView::updateTimerBarWidths(LLTrace::TimeBlock* time_block, TimerBarRow& row, S32 history_index, bool visible) { + std::vector& bars = row.mBars; LLFastTimer _(FTM_UPDATE_TIMER_BAR_WIDTHS); - F32 self_time_frame_fraction = history_index == -1 - ? (mRecording->getPeriodMean(time_block->selfTime()) / mTotalTimeDisplay) - : (mRecording->getPrevRecording(history_index).getSum(time_block->selfTime()) / mTotalTimeDisplay); + const F32 self_time_frame_fraction = history_index == -1 + ? (mRecording.getPeriodMean(time_block->selfTime()) / mTotalTimeDisplay) + : (mRecording.getPrevRecording(history_index).getSum(time_block->selfTime()) / mTotalTimeDisplay); - S32 self_time_width = llround(self_time_frame_fraction * (F32)mBarRect.getWidth()); + const S32 self_time_width = llround(self_time_frame_fraction * (F32)mBarRect.getWidth()); S32 full_width = self_time_width; - bool children_visible = visible; - // reserve a spot for this bar to be rendered before its children // even though we don't know its size yet - S32 bar_rect_index = bars.size(); - if (visible) - { - bars.push_back(TimerBar()); - } + bars.push_back(TimerBar()); + TimerBar& timer_bar = bars.back(); - if (time_block->getCollapsed()) - { - children_visible = false; - } + const bool children_visible = visible && !time_block->getCollapsed(); for (TimeBlock::child_iter it = time_block->beginChildren(), end_it = time_block->endChildren(); it != end_it; ++it) { - full_width += updateTimerBarWidths(*it, bars, history_index, children_visible); + full_width += updateTimerBarWidths(*it, row, history_index, children_visible); } - if (visible) - { - TimerBar& timer_bar = bars[bar_rect_index]; - - timer_bar.mWidth = full_width; - timer_bar.mSelfWidth = self_time_width; - timer_bar.mColor = sTimerColors[time_block]; - - BOOL is_child_of_hover_item = (time_block == mHoverID); - TimeBlock* next_parent = time_block->getParent(); - while(!is_child_of_hover_item && next_parent) - { - is_child_of_hover_item = (mHoverID == next_parent); - if (next_parent->getParent() == next_parent) break; - next_parent = next_parent->getParent(); - } - - if (mHoverID != NULL - && time_block != mHoverID - && !is_child_of_hover_item) - { - timer_bar.mColor = lerp(timer_bar.mColor, LLColor4::grey, 0.8f); - } - } + timer_bar.mWidth = full_width; + timer_bar.mSelfWidth = self_time_width; + timer_bar.mTimeBlock = time_block; + timer_bar.mVisible = visible; + return full_width; } static LLFastTimer::DeclareTimer FTM_UPDATE_TIMER_BAR_FRACTIONS("Update timer bar fractions"); -S32 LLFastTimerView::updateTimerBarFractions(LLTrace::TimeBlock* time_block, S32 timer_bar_index, std::vector& bars) +S32 LLFastTimerView::updateTimerBarFractions(LLTrace::TimeBlock* time_block, TimerBarRow& row, S32 timer_bar_index) { + std::vector& bars = row.mBars; LLFastTimer _(FTM_UPDATE_TIMER_BAR_FRACTIONS); TimerBar& timer_bar = bars[timer_bar_index]; S32 child_time_width = timer_bar.mWidth - timer_bar.mSelfWidth; @@ -1518,11 +1527,6 @@ S32 LLFastTimerView::updateTimerBarFractions(LLTrace::TimeBlock* time_block, S32 } children_rect.mRight = children_rect.mLeft + timer_bar.mWidth - timer_bar.mSelfWidth; - if (children_rect.getHeight() > MIN_BAR_HEIGHT) - { - children_rect.mTop -= 1; - children_rect.mBottom += 1; - } timer_bar.mChildrenRect = children_rect; //now loop through children and figure out portion of bar image covered by each bar, now that we know the @@ -1548,7 +1552,7 @@ S32 LLFastTimerView::updateTimerBarFractions(LLTrace::TimeBlock* time_block, S32 children_rect.mLeft + llround(child_timer_bar.mEndFraction * children_rect.getWidth()), children_rect.mBottom); - timer_bar_index = updateTimerBarFractions(child_time_block, timer_bar_index, bars); + timer_bar_index = updateTimerBarFractions(child_time_block, row, timer_bar_index); bar_fraction_start = child_timer_bar.mEndFraction; } @@ -1556,25 +1560,29 @@ S32 LLFastTimerView::updateTimerBarFractions(LLTrace::TimeBlock* time_block, S32 return timer_bar_index; } -S32 LLFastTimerView::drawBar(LLTrace::TimeBlock* time_block, LLRect bar_rect, std::vector& bars, S32 bar_index, LLPointer& bar_image) +S32 LLFastTimerView::drawBar(LLTrace::TimeBlock* time_block, LLRect bar_rect, TimerBarRow& row, S32 image_width, S32 image_height, bool hovered, S32 bar_index) { - TimerBar& timer_bar = bars[bar_index]; + TimerBar& timer_bar = row.mBars[bar_index]; + + hovered |= mHoverID == time_block; // animate scale of bar when hovering over that particular timer if (bar_rect.getWidth() > 0) { LLRect render_rect(bar_rect); S32 scale_offset = 0; - if (time_block == mHoverID) + if (mHoverID == time_block) { scale_offset = llfloor(sinf(mHighlightTimer.getElapsedTimeF32() * 6.f) * 3.f); render_rect.mTop += scale_offset; render_rect.mBottom -= scale_offset; } - gGL.color4fv(timer_bar.mColor.mV); + LLColor4 color = sTimerColors[time_block->getIndex()]; + if (!hovered) color = lerp(color, LLColor4::grey, 0.8f); + gGL.color4fv(color.mV); gl_segmented_rect_2d_fragment_tex(render_rect, - bar_image->getTextureWidth(), bar_image->getTextureHeight(), + image_width, image_height, 16, timer_bar.mStartFraction, timer_bar.mEndFraction); } @@ -1584,7 +1592,20 @@ S32 LLFastTimerView::drawBar(LLTrace::TimeBlock* time_block, LLRect bar_rect, st for (TimeBlock::child_iter it = time_block->beginChildren(), end_it = time_block->endChildren(); it != end_it; ++it) { ++bar_index; - bar_index = drawBar(*it, timer_bar.mChildrenRect, bars, bar_index, bar_image); + LLRect children_rect = timer_bar.mChildrenRect; + children_rect.translate(0, row.mBottom); + if (bar_rect.getHeight() > MIN_BAR_HEIGHT) + { + // shrink as we go down a level + children_rect.mTop = bar_rect.mTop - 1; + children_rect.mBottom = bar_rect.mBottom + 1; + } + else + { + children_rect.mTop = bar_rect.mTop; + children_rect.mBottom = bar_rect.mBottom; + } + bar_index = drawBar(*it, children_rect, row, image_width, image_height, hovered, bar_index); } } -- cgit v1.2.3 From 3f2de87340b1c831ea59e4a3ca960d49f343c9fd Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Mon, 17 Jun 2013 01:18:21 -0700 Subject: SH-3931 WIP Interesting: Add graphs to visualize scene load metrics added getAs and setAs to LLUnit to make it clearer how you specify units removed accidental 0-based indexing of periodicRecording history... should now be consistently 1-based, with 0 accessing current active recording removed per frame timer updates of all historical timer bars in fast timer display added missing assignment operator to recordings --- indra/newview/llfasttimerview.cpp | 257 ++++++++++++++++++++++---------------- 1 file changed, 149 insertions(+), 108 deletions(-) (limited to 'indra/newview/llfasttimerview.cpp') diff --git a/indra/newview/llfasttimerview.cpp b/indra/newview/llfasttimerview.cpp index 8e061ec87c..231ece4bbd 100755 --- a/indra/newview/llfasttimerview.cpp +++ b/indra/newview/llfasttimerview.cpp @@ -56,7 +56,7 @@ using namespace LLTrace; -static const S32 MAX_VISIBLE_HISTORY = 10; +static const S32 MAX_VISIBLE_HISTORY = 12; static const S32 LINE_GRAPH_HEIGHT = 240; static const S32 MIN_BAR_HEIGHT = 3; @@ -105,7 +105,7 @@ LLFastTimerView::LLFastTimerView(const LLSD& key) mPauseHistory(false), mRecording(512) { - mTimerBarRows.resize(MAX_VISIBLE_HISTORY); + mTimerBarRows.resize(512); } LLFastTimerView::~LLFastTimerView() @@ -272,32 +272,36 @@ BOOL LLFastTimerView::handleHover(S32 x, S32 y, MASK mask) mHoverBarIndex = 0; } - S32 i = 0; - for(timer_tree_iterator_t it = begin_timer_tree(FTM_FRAME); - it != end_timer_tree(); - ++it, ++i) + TimerBarRow& row = mHoverBarIndex == 0 ? mAverageTimerRow : mTimerBarRows[mHoverBarIndex - 1]; + + TimerBar* hover_bar = NULL; + LLUnit mouse_time_offset = ((F32)(x - mBarRect.mLeft) / (F32)mBarRect.getWidth()) * mTotalTimeDisplay; + for (std::vector::iterator it = row.mBars.begin(), end_it = row.mBars.end(); + it != end_it; + ++it) { - // is mouse over bar for this timer? - TimerBarRow& row = mHoverBarIndex == 0 ? mAverageTimerRow : mTimerBarRows[mHoverBarIndex - 1]; - if (row.mBars[i].mVisibleRect.pointInRect(x, y - row.mBottom)) + if (it->mSelfStart > mouse_time_offset) { - mHoverID = (*it); - if (mHoverTimer != *it) - { - // could be that existing tooltip is for a parent and is thus - // covering region for this new timer, go ahead and unblock - // so we can create a new tooltip - LLToolTipMgr::instance().unblockToolTips(); - mHoverTimer = (*it); - } - - mToolTipRect = row.mBars[i].mVisibleRect; - mToolTipRect.translate(0, row.mBottom); + break; } + hover_bar = &(*it); + } - if ((*it)->getCollapsed()) + if (hover_bar) + { + mHoverID = hover_bar->mTimeBlock; + mHoverTimer = mHoverID; + if (mHoverTimer != mHoverID) { - it.skipDescendants(); + // could be that existing tooltip is for a parent and is thus + // covering region for this new timer, go ahead and unblock + // so we can create a new tooltip + LLToolTipMgr::instance().unblockToolTips(); + mHoverTimer = mHoverID; + mToolTipRect.set(mBarRect.mLeft + (hover_bar->mSelfStart / mTotalTimeDisplay) * mBarRect.getWidth(), + row.mTop, + mBarRect.mLeft + (hover_bar->mSelfStart / mTotalTimeDisplay) * mBarRect.getWidth(), + row.mBottom); } } } @@ -422,9 +426,14 @@ void LLFastTimerView::draw() void LLFastTimerView::onOpen(const LLSD& key) { - if (mRecording.getNumRecordedPeriods() == 0) + setPauseState(false); + mRecording.reset(); + mRecording.appendPeriodicRecording(LLTrace::get_frame_recording()); + for(std::deque::iterator it = mTimerBarRows.begin(), end_it = mTimerBarRows.end(); + it != end_it; + ++it) { - mRecording.appendPeriodicRecording(LLTrace::get_frame_recording()); + it->mBars.clear(); } } @@ -1077,6 +1086,7 @@ void LLFastTimerView::drawLineGraph() glLineWidth(3); } + llassert(idp->getIndex() < sTimerColors.size()); const F32 * col = sTimerColors[idp->getIndex()].mV;// ft_display_table[idx].color->mV; F32 alpha = 1.f; @@ -1191,6 +1201,7 @@ void LLFastTimerView::drawLegend( S32 y ) scale_offset = llfloor(sinf(mHighlightTimer.getElapsedTimeF32() * 6.f) * 2.f); } bar_rect.stretch(scale_offset); + llassert(idp->getIndex() < sTimerColors.size()); gl_rect_2d(bar_rect, sTimerColors[idp->getIndex()]); LLUnit ms = 0; @@ -1262,7 +1273,7 @@ void LLFastTimerView::generateUniqueColors() { // generate unique colors { - sTimerColors.reserve(LLTrace::TimeBlock::getNumIndices()); + sTimerColors.resize(LLTrace::TimeBlock::getNumIndices()); sTimerColors[FTM_FRAME.getIndex()] = LLColor4::grey; F32 hue = 0.f; @@ -1283,6 +1294,7 @@ void LLFastTimerView::generateUniqueColors() LLColor4 child_color; child_color.setHSL(hue, saturation, lightness); + llassert(idp->getIndex() < sTimerColors.size()); sTimerColors[idp->getIndex()] = child_color; } } @@ -1377,7 +1389,7 @@ void LLFastTimerView::drawBorders( S32 y, const S32 x_start, S32 bar_height, S32 //history bars gl_rect_2d(x_start-5, by, getRect().getWidth()-5, LINE_GRAPH_HEIGHT-bar_height-dy-2, LLColor4::grey, FALSE); - by = LINE_GRAPH_HEIGHT-bar_height-dy-7; + by = LINE_GRAPH_HEIGHT-dy; //line graph mGraphRect = LLRect(x_start-5, by, getRect().getWidth()-5, 5); @@ -1391,21 +1403,21 @@ void LLFastTimerView::updateTotalTime() switch(mDisplayMode) { case 0: - mTotalTimeDisplay = mRecording.getPeriodMean(FTM_FRAME)*2; + mTotalTimeDisplay = mRecording.getPeriodMean(FTM_FRAME, 100)*2; break; case 1: - mTotalTimeDisplay = mAllTimeMax; + mTotalTimeDisplay = mRecording.getPeriodMax(FTM_FRAME); break; case 2: // Calculate the max total ticks for the current history - mTotalTimeDisplay = mRecording.getPeriodMax(FTM_FRAME); + mTotalTimeDisplay = mRecording.getPeriodMax(FTM_FRAME, 20); break; default: mTotalTimeDisplay = LLUnit(100); break; } - mTotalTimeDisplay = LLUnit(llceil(mTotalTimeDisplay.as().value() / 20.f) * 20.f); + mTotalTimeDisplay = LLUnit(llceil(mTotalTimeDisplay.getAs() / 20.f) * 20.f); } void LLFastTimerView::drawBars() @@ -1432,41 +1444,44 @@ void LLFastTimerView::drawBars() gGL.getTexUnit(0)->bind(bar_image->getImage()); { - const S32 histmax = llmin((S32)mRecording.getNumRecordedPeriods(), MAX_VISIBLE_HISTORY); - - llassert(mTimerBarRows.size() >= histmax); + const S32 histmax = (S32)mRecording.getNumRecordedPeriods(); // update widths updateTimerBarWidths(&FTM_FRAME, mAverageTimerRow, -1); - mAverageTimerRow.mBars[0].mVisibleRect = LLRect(mBarRect.mLeft, 0, mBarRect.mLeft + mAverageTimerRow.mBars[0].mWidth, -bar_height); - updateTimerBarFractions(&FTM_FRAME, mAverageTimerRow); + updateTimerBarOffsets(&FTM_FRAME, mAverageTimerRow); - for (S32 history_index = 0; history_index < histmax; history_index++) + for (S32 history_index = 1; history_index <= histmax; history_index++) { - TimerBarRow& row = mTimerBarRows[history_index]; + llassert(history_index <= mTimerBarRows.size()); + TimerBarRow& row = mTimerBarRows[history_index - 1]; if (row.mBars.empty()) { row.mBars.reserve(LLInstanceTracker::instanceCount()); updateTimerBarWidths(&FTM_FRAME, row, history_index); - row.mBars[0].mVisibleRect = LLRect(mBarRect.mLeft, 0, mBarRect.mLeft + row.mBars[0].mWidth, -1); - updateTimerBarFractions(&FTM_FRAME, row); + updateTimerBarOffsets(&FTM_FRAME, row); } } // draw bars - LLRect frame_bar_rect( mBarRect.mLeft, - bars_top, - mBarRect.mLeft + mAverageTimerRow.mBars[0].mWidth, - bars_top - bar_height); + LLRect frame_bar_rect; + frame_bar_rect.setLeftTopAndSize(mBarRect.mLeft, + bars_top, + llround((mAverageTimerRow.mBars[0].mTotalTime / mTotalTimeDisplay) * mBarRect.getWidth()), + bar_height); + mAverageTimerRow.mTop = frame_bar_rect.mTop; mAverageTimerRow.mBottom = frame_bar_rect.mBottom; - drawBar(&FTM_FRAME, frame_bar_rect, mAverageTimerRow, image_width, image_height, false); + drawBar(frame_bar_rect, mAverageTimerRow, image_width, image_height); frame_bar_rect.translate(0, -(bar_height + vpad + bar_height)); for(S32 bar_index = mScrollIndex; bar_index < llmin(histmax, mScrollIndex + MAX_VISIBLE_HISTORY); ++bar_index) { + llassert(bar_index < mTimerBarRows.size()); TimerBarRow& row = mTimerBarRows[bar_index]; + row.mTop = frame_bar_rect.mTop; row.mBottom = frame_bar_rect.mBottom; - drawBar(&FTM_FRAME, frame_bar_rect, row, image_width, image_height, false); + frame_bar_rect.mRight = frame_bar_rect.mLeft + + llround((row.mBars[0].mTotalTime / mTotalTimeDisplay) * mBarRect.getWidth()); + drawBar(frame_bar_rect, row, image_width, image_height); frame_bar_rect.translate(0, -(bar_height + vpad)); } @@ -1477,97 +1492,115 @@ void LLFastTimerView::drawBars() static LLFastTimer::DeclareTimer FTM_UPDATE_TIMER_BAR_WIDTHS("Update timer bar widths"); -S32 LLFastTimerView::updateTimerBarWidths(LLTrace::TimeBlock* time_block, TimerBarRow& row, S32 history_index, bool visible) +LLUnit LLFastTimerView::updateTimerBarWidths(LLTrace::TimeBlock* time_block, TimerBarRow& row, S32 history_index, bool visible) { - std::vector& bars = row.mBars; LLFastTimer _(FTM_UPDATE_TIMER_BAR_WIDTHS); - const F32 self_time_frame_fraction = history_index == -1 - ? (mRecording.getPeriodMean(time_block->selfTime()) / mTotalTimeDisplay) - : (mRecording.getPrevRecording(history_index).getSum(time_block->selfTime()) / mTotalTimeDisplay); + const LLUnit self_time = history_index == -1 + ? mRecording.getPeriodMean(time_block->selfTime()) + : mRecording.getPrevRecording(history_index).getSum(time_block->selfTime()); - const S32 self_time_width = llround(self_time_frame_fraction * (F32)mBarRect.getWidth()); - S32 full_width = self_time_width; + LLUnit full_time = self_time; // reserve a spot for this bar to be rendered before its children // even though we don't know its size yet + std::vector& bars = row.mBars; + S32 bar_index = bars.size(); bars.push_back(TimerBar()); - TimerBar& timer_bar = bars.back(); const bool children_visible = visible && !time_block->getCollapsed(); for (TimeBlock::child_iter it = time_block->beginChildren(), end_it = time_block->endChildren(); it != end_it; ++it) { - full_width += updateTimerBarWidths(*it, row, history_index, children_visible); + full_time += updateTimerBarWidths(*it, row, history_index, children_visible); } - timer_bar.mWidth = full_width; - timer_bar.mSelfWidth = self_time_width; - timer_bar.mTimeBlock = time_block; - timer_bar.mVisible = visible; + TimerBar& timer_bar = bars[bar_index]; + timer_bar.mTotalTime = full_time; + timer_bar.mSelfTime = self_time; + timer_bar.mTimeBlock = time_block; + timer_bar.mVisible = visible; - return full_width; + return full_time; } static LLFastTimer::DeclareTimer FTM_UPDATE_TIMER_BAR_FRACTIONS("Update timer bar fractions"); -S32 LLFastTimerView::updateTimerBarFractions(LLTrace::TimeBlock* time_block, TimerBarRow& row, S32 timer_bar_index) +S32 LLFastTimerView::updateTimerBarOffsets(LLTrace::TimeBlock* time_block, TimerBarRow& row, S32 timer_bar_index) { - std::vector& bars = row.mBars; LLFastTimer _(FTM_UPDATE_TIMER_BAR_FRACTIONS); + + std::vector& bars = row.mBars; + llassert(timer_bar_index < bars.size()); TimerBar& timer_bar = bars[timer_bar_index]; - S32 child_time_width = timer_bar.mWidth - timer_bar.mSelfWidth; - LLRect children_rect = timer_bar.mVisibleRect; + const LLUnit child_time_width = timer_bar.mTotalTime - timer_bar.mSelfTime; + timer_bar.mChildrenStart = timer_bar.mSelfStart; if (mDisplayCenter == ALIGN_CENTER) { - children_rect.mLeft += timer_bar.mSelfWidth / 2; + timer_bar.mChildrenStart += timer_bar.mSelfTime / 2; } else if (mDisplayCenter == ALIGN_RIGHT) { - children_rect.mLeft += timer_bar.mSelfWidth; + timer_bar.mChildrenStart += timer_bar.mSelfTime; } - children_rect.mRight = children_rect.mLeft + timer_bar.mWidth - timer_bar.mSelfWidth; - - timer_bar.mChildrenRect = children_rect; + timer_bar.mChildrenEnd = timer_bar.mChildrenStart + timer_bar.mTotalTime - timer_bar.mSelfTime; //now loop through children and figure out portion of bar image covered by each bar, now that we know the //sum of all children - if (!time_block->getCollapsed()) + F32 bar_fraction_start = 0.f; + TimerBar* last_child_timer_bar = NULL; + + bool first_child = true; + for (TimeBlock::child_iter it = time_block->beginChildren(), end_it = time_block->endChildren(); + it != end_it; + ++it) { - F32 bar_fraction_start = 0.f; - for (TimeBlock::child_iter it = time_block->beginChildren(), end_it = time_block->endChildren(); - it != end_it; - ++it) + timer_bar_index++; + + llassert(timer_bar_index < bars.size()); + TimerBar& child_timer_bar = bars[timer_bar_index]; + TimeBlock* child_time_block = *it; + + if (last_child_timer_bar) { - timer_bar_index++; + last_child_timer_bar->mLastChild = false; + } + child_timer_bar.mLastChild = true; + last_child_timer_bar = &child_timer_bar; - TimerBar& child_timer_bar = bars[timer_bar_index]; - TimeBlock* child_time_block = *it; + child_timer_bar.mFirstChild = first_child; + if (first_child) + { + first_child = false; + } - child_timer_bar.mStartFraction = bar_fraction_start; - child_timer_bar.mEndFraction = child_time_width > 0 - ? bar_fraction_start + (F32)child_timer_bar.mWidth / child_time_width - : 1.f; - child_timer_bar.mVisibleRect.set(children_rect.mLeft + llround(child_timer_bar.mStartFraction * children_rect.getWidth()), - children_rect.mTop, - children_rect.mLeft + llround(child_timer_bar.mEndFraction * children_rect.getWidth()), - children_rect.mBottom); + child_timer_bar.mStartFraction = bar_fraction_start; + child_timer_bar.mEndFraction = child_time_width > 0 + ? bar_fraction_start + child_timer_bar.mTotalTime / child_time_width + : 1.f; + child_timer_bar.mSelfStart = timer_bar.mChildrenStart + + child_timer_bar.mStartFraction + * (timer_bar.mChildrenEnd - timer_bar.mChildrenStart); + child_timer_bar.mSelfEnd = timer_bar.mChildrenStart + + child_timer_bar.mEndFraction + * (timer_bar.mChildrenEnd - timer_bar.mChildrenStart); - timer_bar_index = updateTimerBarFractions(child_time_block, row, timer_bar_index); + timer_bar_index = updateTimerBarOffsets(child_time_block, row, timer_bar_index); - bar_fraction_start = child_timer_bar.mEndFraction; - } + bar_fraction_start = child_timer_bar.mEndFraction; } return timer_bar_index; } -S32 LLFastTimerView::drawBar(LLTrace::TimeBlock* time_block, LLRect bar_rect, TimerBarRow& row, S32 image_width, S32 image_height, bool hovered, S32 bar_index) +S32 LLFastTimerView::drawBar(LLRect bar_rect, TimerBarRow& row, S32 image_width, S32 image_height, bool hovered, S32 bar_index) { + llassert(bar_index < row.mBars.size()); TimerBar& timer_bar = row.mBars[bar_index]; + LLTrace::TimeBlock* time_block = timer_bar.mTimeBlock; hovered |= mHoverID == time_block; // animate scale of bar when hovering over that particular timer - if (bar_rect.getWidth() > 0) + if ((F32)bar_rect.getWidth() * (timer_bar.mEndFraction - timer_bar.mStartFraction) > 2.f) { LLRect render_rect(bar_rect); S32 scale_offset = 0; @@ -1578,8 +1611,9 @@ S32 LLFastTimerView::drawBar(LLTrace::TimeBlock* time_block, LLRect bar_rect, Ti render_rect.mBottom -= scale_offset; } + llassert(time_block->getIndex() < sTimerColors.size()); LLColor4 color = sTimerColors[time_block->getIndex()]; - if (!hovered) color = lerp(color, LLColor4::grey, 0.8f); + if (!hovered) color = lerp(color, LLColor4::grey, 0.2f); gGL.color4fv(color.mV); gl_segmented_rect_2d_fragment_tex(render_rect, image_width, image_height, @@ -1587,26 +1621,33 @@ S32 LLFastTimerView::drawBar(LLTrace::TimeBlock* time_block, LLRect bar_rect, Ti timer_bar.mStartFraction, timer_bar.mEndFraction); } - if (!time_block->getCollapsed()) + LLRect children_rect; + children_rect.mLeft = llround(timer_bar.mChildrenStart / mTotalTimeDisplay * (F32)mBarRect.getWidth()) + mBarRect.mLeft; + children_rect.mRight = llround(timer_bar.mChildrenEnd / mTotalTimeDisplay * (F32)mBarRect.getWidth()) + mBarRect.mLeft; + + if (bar_rect.getHeight() > MIN_BAR_HEIGHT) { - for (TimeBlock::child_iter it = time_block->beginChildren(), end_it = time_block->endChildren(); it != end_it; ++it) + // shrink as we go down a level + children_rect.mTop = bar_rect.mTop - 1; + children_rect.mBottom = bar_rect.mBottom + 1; + } + else + { + children_rect.mTop = bar_rect.mTop; + children_rect.mBottom = bar_rect.mBottom; + } + + bar_index++; + const U32 num_bars = row.mBars.size(); + if (bar_index < num_bars && row.mBars[bar_index].mFirstChild) + { + bool is_last = false; + do { - ++bar_index; - LLRect children_rect = timer_bar.mChildrenRect; - children_rect.translate(0, row.mBottom); - if (bar_rect.getHeight() > MIN_BAR_HEIGHT) - { - // shrink as we go down a level - children_rect.mTop = bar_rect.mTop - 1; - children_rect.mBottom = bar_rect.mBottom + 1; - } - else - { - children_rect.mTop = bar_rect.mTop; - children_rect.mBottom = bar_rect.mBottom; - } - bar_index = drawBar(*it, children_rect, row, image_width, image_height, hovered, bar_index); + is_last = row.mBars[bar_index].mLastChild; + bar_index = drawBar(children_rect, row, image_width, image_height, hovered, bar_index); } + while(!is_last && bar_index < num_bars); } return bar_index; -- cgit v1.2.3 From d136c4c29686c565b5a46503aa67a9c958b4145d Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Tue, 18 Jun 2013 23:41:53 -0700 Subject: SH-4246 FIX interesting: fast timers significantly decreases framerate removed implicit flushes on reads from recorders for better performance made sure stack timers were updated on recorder deactivate faster rendering and better ui for fast timer view --- indra/newview/llfasttimerview.cpp | 316 ++++++++++++++++++++------------------ 1 file changed, 163 insertions(+), 153 deletions(-) (limited to 'indra/newview/llfasttimerview.cpp') diff --git a/indra/newview/llfasttimerview.cpp b/indra/newview/llfasttimerview.cpp index 231ece4bbd..1355b58f8b 100755 --- a/indra/newview/llfasttimerview.cpp +++ b/indra/newview/llfasttimerview.cpp @@ -30,12 +30,14 @@ #include "llviewerwindow.h" #include "llrect.h" +#include "llcombobox.h" #include "llerror.h" #include "llgl.h" #include "llimagepng.h" #include "llrender.h" #include "llrendertarget.h" #include "lllocalcliprect.h" +#include "lllayoutstack.h" #include "llmath.h" #include "llfontgl.h" #include "llsdserialize.h" @@ -59,6 +61,8 @@ using namespace LLTrace; static const S32 MAX_VISIBLE_HISTORY = 12; static const S32 LINE_GRAPH_HEIGHT = 240; static const S32 MIN_BAR_HEIGHT = 3; +static const S32 RUNNING_AVERAGE_WIDTH = 100; +static const S32 NUM_FRAMES_HISTORY = 256; std::vector ft_display_idx; // line of table entry for display purposes (for collapse) @@ -95,17 +99,15 @@ LLFastTimerView::LLFastTimerView(const LLSD& key) : LLFloater(key), mHoverTimer(NULL), mDisplayMode(0), - mDisplayCenter(ALIGN_CENTER), - mDisplayCalls(false), - mDisplayHz(false), + mDisplayType(TIME), mScrollIndex(0), mHoverID(NULL), mHoverBarIndex(-1), mStatsIndex(-1), mPauseHistory(false), - mRecording(512) + mRecording(NUM_FRAMES_HISTORY) { - mTimerBarRows.resize(512); + mTimerBarRows.resize(NUM_FRAMES_HISTORY); } LLFastTimerView::~LLFastTimerView() @@ -172,7 +174,7 @@ BOOL LLFastTimerView::handleRightMouseDown(S32 x, S32 y, MASK mask) TimeBlock* LLFastTimerView::getLegendID(S32 y) { - S32 idx = (mBarRect.mTop - y) / (LLFontGL::getFontMonospace()->getLineHeight()+2) - 1; + S32 idx = (mLegendRect.mTop - y) / (LLFontGL::getFontMonospace()->getLineHeight() + 2); if (idx >= 0 && idx < (S32)ft_display_idx.size()) { @@ -208,26 +210,6 @@ BOOL LLFastTimerView::handleMouseDown(S32 x, S32 y, MASK mask) //left click drills down by expanding timers mHoverTimer->setCollapsed(false); } - else if (mask & MASK_ALT) - { - if (mask & MASK_CONTROL) - { - mDisplayHz = !mDisplayHz; - } - else - { - mDisplayCalls = !mDisplayCalls; - } - } - else if (mask & MASK_SHIFT) - { - if (++mDisplayMode > 3) - mDisplayMode = 0; - } - else if (mask & MASK_CONTROL) - { - mDisplayCenter = (ChildAlignment)((mDisplayCenter + 1) % ALIGN_COUNT); - } else if (mGraphRect.pointInRect(x, y)) { gFocusMgr.setMouseCapture(this); @@ -260,7 +242,10 @@ BOOL LLFastTimerView::handleHover(S32 x, S32 y, MASK mask) if(mPauseHistory && mBarRect.pointInRect(x, y)) { - mHoverBarIndex = llmin((mBarRect.mTop - y) / (mBarRect.getHeight() / (MAX_VISIBLE_HISTORY + 2)) - 1, + //const S32 bars_top = mBarRect.mTop; + const S32 bars_top = mBarRect.mTop - ((S32)LLFontGL::getFontMonospace()->getLineHeight() + 4); + + mHoverBarIndex = llmin((bars_top - y) / (mBarRect.getHeight() / (MAX_VISIBLE_HISTORY + 2)) - 1, (S32)mRecording.getNumRecordedPeriods() - 1, MAX_VISIBLE_HISTORY); if (mHoverBarIndex == 0) @@ -272,25 +257,33 @@ BOOL LLFastTimerView::handleHover(S32 x, S32 y, MASK mask) mHoverBarIndex = 0; } - TimerBarRow& row = mHoverBarIndex == 0 ? mAverageTimerRow : mTimerBarRows[mHoverBarIndex - 1]; + TimerBarRow& row = mHoverBarIndex == 0 ? mAverageTimerRow : mTimerBarRows[mScrollIndex + mHoverBarIndex - 1]; TimerBar* hover_bar = NULL; LLUnit mouse_time_offset = ((F32)(x - mBarRect.mLeft) / (F32)mBarRect.getWidth()) * mTotalTimeDisplay; - for (std::vector::iterator it = row.mBars.begin(), end_it = row.mBars.end(); - it != end_it; - ++it) + for (int bar_index = 0, end_index = LLInstanceTracker::instanceCount(); + bar_index < end_index; + ++bar_index) { - if (it->mSelfStart > mouse_time_offset) + TimerBar& bar = row.mBars[bar_index]; + if (bar.mSelfStart > mouse_time_offset) { break; } - hover_bar = &(*it); + if (bar.mSelfEnd > mouse_time_offset) + { + hover_bar = &bar; + if (bar.mTimeBlock->getCollapsed()) + { + // stop on first collapsed timeblock, since we can't select any children + break; + } + } } if (hover_bar) { mHoverID = hover_bar->mTimeBlock; - mHoverTimer = mHoverID; if (mHoverTimer != mHoverID) { // could be that existing tooltip is for a parent and is thus @@ -300,7 +293,7 @@ BOOL LLFastTimerView::handleHover(S32 x, S32 y, MASK mask) mHoverTimer = mHoverID; mToolTipRect.set(mBarRect.mLeft + (hover_bar->mSelfStart / mTotalTimeDisplay) * mBarRect.getWidth(), row.mTop, - mBarRect.mLeft + (hover_bar->mSelfStart / mTotalTimeDisplay) * mBarRect.getWidth(), + mBarRect.mLeft + (hover_bar->mSelfEnd / mTotalTimeDisplay) * mBarRect.getWidth(), row.mBottom); } } @@ -324,7 +317,7 @@ static std::string get_tooltip(TimeBlock& timer, S32 history_index, PeriodicReco if (history_index == 0) { // by default, show average number of call - tooltip = llformat("%s (%d ms, %d calls)", timer.getName().c_str(), (S32)LLUnit(frame_recording.getPeriodMean(timer)).value(), (S32)frame_recording.getPeriodMean(timer.callCount())); + tooltip = llformat("%s (%d ms, %d calls)", timer.getName().c_str(), (S32)LLUnit(frame_recording.getPeriodMean (timer, RUNNING_AVERAGE_WIDTH)).value(), (S32)frame_recording.getPeriodMean(timer.callCount(), RUNNING_AVERAGE_WIDTH)); } else { @@ -397,22 +390,34 @@ void LLFastTimerView::draw() mTimerBarRows.push_front(TimerBarRow()); } + mDisplayMode = llclamp(getChild("time_scale_combo")->getCurrentIndex(), 0, 3); + mDisplayType = (EDisplayType)llclamp(getChild("metric_combo")->getCurrentIndex(), 0, 2); + generateUniqueColors(); + LLView::drawChildren(); + //getChild("timer_bars_stack")->updateLayout(); + //getChild("legend_stack")->updateLayout(); + LLView* bars_panel = getChildView("bars_panel"); + bars_panel->localRectToOtherView(bars_panel->getLocalRect(), &mBarRect, this); + + LLView* lines_panel = getChildView("lines_panel"); + lines_panel->localRectToOtherView(lines_panel->getLocalRect(), &mGraphRect, this); + + LLView* legend_panel = getChildView("legend"); + legend_panel->localRectToOtherView(legend_panel->getLocalRect(), &mLegendRect, this); + // Draw the window background gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); gl_rect_2d(getLocalRect(), LLColor4(0.f, 0.f, 0.f, 0.25f)); - S32 y = drawHelp(getRect().getHeight() - MARGIN); - drawLegend(y - ((S32)LLFontGL::getFontMonospace()->getLineHeight() + 2)); - - // update rectangle that includes timer bars - const S32 LEGEND_WIDTH = 220; + drawHelp(getRect().getHeight() - MARGIN); + drawLegend(); - mBarRect.mLeft = MARGIN + LEGEND_WIDTH + 8; - mBarRect.mTop = y; - mBarRect.mRight = getRect().getWidth() - MARGIN; - mBarRect.mBottom = MARGIN + LINE_GRAPH_HEIGHT; + //mBarRect.mLeft = MARGIN + LEGEND_WIDTH + 8; + //mBarRect.mTop = y; + //mBarRect.mRight = getRect().getWidth() - MARGIN; + //mBarRect.mBottom = MARGIN + LINE_GRAPH_HEIGHT; drawBars(); drawLineGraph(); @@ -433,7 +438,8 @@ void LLFastTimerView::onOpen(const LLSD& key) it != end_it; ++it) { - it->mBars.clear(); + delete []it->mBars; + it->mBars = NULL; } } @@ -993,7 +999,7 @@ void LLFastTimerView::printLineStats() LLUnit ticks; if (mStatsIndex == 0) { - ticks = mRecording.getPeriodMean(*idp); + ticks = mRecording.getPeriodMean(*idp, RUNNING_AVERAGE_WIDTH); } else { @@ -1019,8 +1025,6 @@ void LLFastTimerView::drawLineGraph() { LLFastTimer _(FTM_DRAW_LINE_GRAPH); //draw line graph history - S32 x = mBarRect.mLeft; - S32 y = LINE_GRAPH_HEIGHT; gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); LLLocalClipRect clip(mGraphRect); @@ -1029,21 +1033,6 @@ void LLFastTimerView::drawLineGraph() static U32 max_calls = 0; static F32 alpha_interp = 0.f; - //display y-axis range - std::string axis_label; - if (mDisplayCalls) - axis_label = llformat("%d calls", (int)max_calls); - else if (mDisplayHz) - axis_label = llformat("%d Hz", (int)(1.f / max_time.value())); - else - axis_label = llformat("%4.2f ms", LLUnit(max_time).value()); - - x = mGraphRect.mRight - LLFontGL::getFontMonospace()->getWidth(axis_label)-5; - y = mGraphRect.mTop - LLFontGL::getFontMonospace()->getLineHeight(); - - LLFontGL::getFontMonospace()->renderUTF8(axis_label, 0, x, y, LLColor4::white, - LLFontGL::LEFT, LLFontGL::TOP); - //highlight visible range { S32 first_frame = mRecording.getNumRecordedPeriods() - mScrollIndex; @@ -1059,7 +1048,7 @@ void LLFastTimerView::drawLineGraph() if (mHoverBarIndex > 0) { - S32 bar_frame = first_frame - mHoverBarIndex - 1; + S32 bar_frame = first_frame - (mScrollIndex + mHoverBarIndex) - 1; F32 bar = (F32) mGraphRect.mLeft + frame_delta*bar_frame; gGL.color4f(0.5f,0.5f,0.5f,1); @@ -1090,6 +1079,7 @@ void LLFastTimerView::drawLineGraph() const F32 * col = sTimerColors[idp->getIndex()].mV;// ft_display_table[idx].color->mV; F32 alpha = 1.f; + bool is_hover_timer = true; if (mHoverID != NULL && mHoverID != idp) @@ -1097,11 +1087,15 @@ void LLFastTimerView::drawLineGraph() if (idp->getParent() != mHoverID) { alpha = alpha_interp; + is_hover_timer = false; } } gGL.color4f(col[0], col[1], col[2], alpha); gGL.begin(LLRender::TRIANGLE_STRIP); + F32 call_scale_factor = (F32)mGraphRect.getHeight() / (F32)max_calls; + F32 time_scale_factor = (F32)mGraphRect.getHeight() / max_time.value(); + F32 hz_scale_factor = (F32) mGraphRect.getHeight() / (1.f / max_time.value()); for (U32 j = mRecording.getNumRecordedPeriods(); j > 0; j--) @@ -1110,16 +1104,26 @@ void LLFastTimerView::drawLineGraph() LLUnit time = llmax(recording.getSum(*idp), LLUnit(0.000001)); U32 calls = recording.getSum(idp->callCount()); - if (alpha == 1.f) + if (is_hover_timer) { //normalize to highlighted timer cur_max = llmax(cur_max, time); cur_max_calls = llmax(cur_max_calls, calls); } F32 x = mGraphRect.mRight - j * (F32)(mGraphRect.getWidth())/(mRecording.getNumRecordedPeriods()-1); - F32 y = mDisplayHz - ? mGraphRect.mBottom + (1.f / time.value()) * ((F32) mGraphRect.getHeight() / (1.f / max_time.value())) - : mGraphRect.mBottom + time / max_time * (F32)mGraphRect.getHeight(); + F32 y; + switch(mDisplayType) + { + case TIME: + y = mGraphRect.mBottom + time.value() * time_scale_factor; + break; + case CALLS: + y = mGraphRect.mBottom + (F32)calls * call_scale_factor; + break; + case HZ: + y = mGraphRect.mBottom + (1.f / time.value()) * hz_scale_factor; + break; + } gGL.vertex2f(x,y); gGL.vertex2f(x,mGraphRect.mBottom); } @@ -1140,7 +1144,7 @@ void LLFastTimerView::drawLineGraph() //interpolate towards new maximum max_time = lerp(max_time.value(), cur_max.value(), LLSmoothInterpolation::getInterpolant(0.1f)); - if (max_time - cur_max <= 1 || cur_max - max_time <= 1) + if (llabs((max_time - cur_max).value()) <= 1) { max_time = llmax(LLUnit(1), LLUnit(cur_max)); } @@ -1159,8 +1163,8 @@ void LLFastTimerView::drawLineGraph() if (mHoverID != NULL) { - x = (mGraphRect.mRight + mGraphRect.mLeft)/2; - y = mGraphRect.mBottom + 8; + S32 x = (mGraphRect.mRight + mGraphRect.mLeft)/2; + S32 y = mGraphRect.mBottom + 8; LLFontGL::getFontMonospace()->renderUTF8( mHoverID->getName(), @@ -1168,18 +1172,40 @@ void LLFastTimerView::drawLineGraph() x, y, LLColor4::white, LLFontGL::LEFT, LLFontGL::BOTTOM); - } + } + + //display y-axis range + std::string axis_label; + switch(mDisplayType) + { + case TIME: + axis_label = llformat("%4.2f ms", LLUnit(max_time).value()); + break; + case CALLS: + axis_label = llformat("%d calls", (int)max_calls); + break; + case HZ: + axis_label = llformat("%4.2f Hz", max_time.value() ? 1.f / max_time.value() : 0.f); + break; + } + + LLFontGL* font = LLFontGL::getFontMonospace(); + S32 x = mGraphRect.mRight - font->getWidth(axis_label)-5; + S32 y = mGraphRect.mTop - font->getLineHeight();; + + font->renderUTF8(axis_label, 0, x, y, LLColor4::white, LLFontGL::LEFT, LLFontGL::TOP); } -void LLFastTimerView::drawLegend( S32 y ) +void LLFastTimerView::drawLegend() { // draw legend S32 dx; - S32 x = MARGIN; + S32 x = mLegendRect.mLeft; + S32 y = mLegendRect.mTop; const S32 TEXT_HEIGHT = (S32)LLFontGL::getFontMonospace()->getLineHeight(); { - LLLocalClipRect clip(LLRect(MARGIN, y, LEGEND_WIDTH, MARGIN)); + LLLocalClipRect clip(mLegendRect); S32 cur_line = 0; ft_display_idx.clear(); std::map display_line; @@ -1214,18 +1240,22 @@ void LLFastTimerView::drawLegend( S32 y ) } else { - ms = LLUnit(mRecording.getPeriodMean(*idp)); - calls = (S32)mRecording.getPeriodMean(idp->callCount()); + ms = LLUnit(mRecording.getPeriodMean(*idp, RUNNING_AVERAGE_WIDTH)); + calls = (S32)mRecording.getPeriodMean(idp->callCount(), RUNNING_AVERAGE_WIDTH); } std::string timer_label; - if (mDisplayCalls) - { - timer_label = llformat("%s (%d)",idp->getName().c_str(),calls); - } - else + switch(mDisplayType) { + case TIME: timer_label = llformat("%s [%.1f]",idp->getName().c_str(),ms.value()); + break; + case CALLS: + timer_label = llformat("%s (%d)",idp->getName().c_str(),calls); + break; + case HZ: + timer_label = llformat("%.1f", ms.value() ? (1.f / ms.value()) : 0.f); + break; } dx = (TEXT_HEIGHT+4) + get_depth(idp)*8; @@ -1300,36 +1330,16 @@ void LLFastTimerView::generateUniqueColors() } } -S32 LLFastTimerView::drawHelp( S32 y ) +void LLFastTimerView::drawHelp( S32 y ) { // Draw some help const S32 texth = (S32)LLFontGL::getFontMonospace()->getLineHeight(); - char modedesc[][32] = { - "2 x Average ", - "Max ", - "Recent Max ", - "100 ms " - }; - char centerdesc[][32] = { - "Left ", - "Centered ", - "Ordered " - }; - - std::string text; - text = llformat("Full bar = %s [Click to pause/reset] [SHIFT-Click to toggle]",modedesc[mDisplayMode]); - LLFontGL::getFontMonospace()->renderUTF8(text, 0, MARGIN, y, LLColor4::white, LLFontGL::LEFT, LLFontGL::TOP); - y -= (texth + 2); - text = llformat("Justification = %s [CTRL-Click to toggle]",centerdesc[mDisplayCenter]); - LLFontGL::getFontMonospace()->renderUTF8(text, 0, MARGIN, y, LLColor4::white, LLFontGL::LEFT, LLFontGL::TOP); y -= (texth + 2); - LLFontGL::getFontMonospace()->renderUTF8(std::string("[Right-Click log selected] [ALT-Click toggle counts] [ALT-SHIFT-Click sub hidden]"), + LLFontGL::getFontMonospace()->renderUTF8(std::string("[Right-Click log selected] [ALT-Click toggle counts]"), 0, MARGIN, y, LLColor4::white, LLFontGL::LEFT, LLFontGL::TOP); - y -= (texth + 2); - return y; } void LLFastTimerView::drawTicks() @@ -1392,7 +1402,7 @@ void LLFastTimerView::drawBorders( S32 y, const S32 x_start, S32 bar_height, S32 by = LINE_GRAPH_HEIGHT-dy; //line graph - mGraphRect = LLRect(x_start-5, by, getRect().getWidth()-5, 5); + //mGraphRect = LLRect(x_start-5, by, getRect().getWidth()-5, 5); gl_rect_2d(mGraphRect, FALSE); } @@ -1403,7 +1413,7 @@ void LLFastTimerView::updateTotalTime() switch(mDisplayMode) { case 0: - mTotalTimeDisplay = mRecording.getPeriodMean(FTM_FRAME, 100)*2; + mTotalTimeDisplay = mRecording.getPeriodMean(FTM_FRAME, RUNNING_AVERAGE_WIDTH)*2; break; case 1: mTotalTimeDisplay = mRecording.getPeriodMax(FTM_FRAME); @@ -1447,18 +1457,27 @@ void LLFastTimerView::drawBars() const S32 histmax = (S32)mRecording.getNumRecordedPeriods(); // update widths - updateTimerBarWidths(&FTM_FRAME, mAverageTimerRow, -1); - updateTimerBarOffsets(&FTM_FRAME, mAverageTimerRow); - - for (S32 history_index = 1; history_index <= histmax; history_index++) + if (!mPauseHistory) { - llassert(history_index <= mTimerBarRows.size()); - TimerBarRow& row = mTimerBarRows[history_index - 1]; - if (row.mBars.empty()) + U32 bar_index = 0; + if (!mAverageTimerRow.mBars) { - row.mBars.reserve(LLInstanceTracker::instanceCount()); - updateTimerBarWidths(&FTM_FRAME, row, history_index); - updateTimerBarOffsets(&FTM_FRAME, row); + mAverageTimerRow.mBars = new TimerBar[LLInstanceTracker::instanceCount()]; + } + updateTimerBarWidths(&FTM_FRAME, mAverageTimerRow, -1, bar_index); + updateTimerBarOffsets(&FTM_FRAME, mAverageTimerRow); + + for (S32 history_index = 1; history_index <= histmax; history_index++) + { + llassert(history_index <= mTimerBarRows.size()); + TimerBarRow& row = mTimerBarRows[history_index - 1]; + bar_index = 0; + if (!row.mBars) + { + row.mBars = new TimerBar[LLInstanceTracker::instanceCount()]; + updateTimerBarWidths(&FTM_FRAME, row, history_index, bar_index); + updateTimerBarOffsets(&FTM_FRAME, row); + } } } @@ -1492,32 +1511,28 @@ void LLFastTimerView::drawBars() static LLFastTimer::DeclareTimer FTM_UPDATE_TIMER_BAR_WIDTHS("Update timer bar widths"); -LLUnit LLFastTimerView::updateTimerBarWidths(LLTrace::TimeBlock* time_block, TimerBarRow& row, S32 history_index, bool visible) +LLUnit LLFastTimerView::updateTimerBarWidths(LLTrace::TimeBlock* time_block, TimerBarRow& row, S32 history_index, U32& bar_index) { LLFastTimer _(FTM_UPDATE_TIMER_BAR_WIDTHS); const LLUnit self_time = history_index == -1 - ? mRecording.getPeriodMean(time_block->selfTime()) + ? mRecording.getPeriodMean(time_block->selfTime(), RUNNING_AVERAGE_WIDTH) : mRecording.getPrevRecording(history_index).getSum(time_block->selfTime()); LLUnit full_time = self_time; // reserve a spot for this bar to be rendered before its children // even though we don't know its size yet - std::vector& bars = row.mBars; - S32 bar_index = bars.size(); - bars.push_back(TimerBar()); + TimerBar& timer_bar = row.mBars[bar_index]; + bar_index++; - const bool children_visible = visible && !time_block->getCollapsed(); for (TimeBlock::child_iter it = time_block->beginChildren(), end_it = time_block->endChildren(); it != end_it; ++it) { - full_time += updateTimerBarWidths(*it, row, history_index, children_visible); + full_time += updateTimerBarWidths(*it, row, history_index, bar_index); } - TimerBar& timer_bar = bars[bar_index]; timer_bar.mTotalTime = full_time; timer_bar.mSelfTime = self_time; timer_bar.mTimeBlock = time_block; - timer_bar.mVisible = visible; return full_time; } @@ -1528,21 +1543,16 @@ S32 LLFastTimerView::updateTimerBarOffsets(LLTrace::TimeBlock* time_block, Timer { LLFastTimer _(FTM_UPDATE_TIMER_BAR_FRACTIONS); - std::vector& bars = row.mBars; - llassert(timer_bar_index < bars.size()); - TimerBar& timer_bar = bars[timer_bar_index]; - const LLUnit child_time_width = timer_bar.mTotalTime - timer_bar.mSelfTime; - timer_bar.mChildrenStart = timer_bar.mSelfStart; + TimerBar& timer_bar = row.mBars[timer_bar_index]; + const LLUnit bar_time = timer_bar.mTotalTime - timer_bar.mSelfTime; + timer_bar.mChildrenStart = timer_bar.mSelfStart + timer_bar.mSelfTime / 2; + timer_bar.mChildrenEnd = timer_bar.mChildrenStart + timer_bar.mTotalTime - timer_bar.mSelfTime; - if (mDisplayCenter == ALIGN_CENTER) + if (timer_bar_index == 0) { - timer_bar.mChildrenStart += timer_bar.mSelfTime / 2; + timer_bar.mSelfStart = 0.f; + timer_bar.mSelfEnd = bar_time; } - else if (mDisplayCenter == ALIGN_RIGHT) - { - timer_bar.mChildrenStart += timer_bar.mSelfTime; - } - timer_bar.mChildrenEnd = timer_bar.mChildrenStart + timer_bar.mTotalTime - timer_bar.mSelfTime; //now loop through children and figure out portion of bar image covered by each bar, now that we know the //sum of all children @@ -1556,8 +1566,7 @@ S32 LLFastTimerView::updateTimerBarOffsets(LLTrace::TimeBlock* time_block, Timer { timer_bar_index++; - llassert(timer_bar_index < bars.size()); - TimerBar& child_timer_bar = bars[timer_bar_index]; + TimerBar& child_timer_bar = row.mBars[timer_bar_index]; TimeBlock* child_time_block = *it; if (last_child_timer_bar) @@ -1574,15 +1583,15 @@ S32 LLFastTimerView::updateTimerBarOffsets(LLTrace::TimeBlock* time_block, Timer } child_timer_bar.mStartFraction = bar_fraction_start; - child_timer_bar.mEndFraction = child_time_width > 0 - ? bar_fraction_start + child_timer_bar.mTotalTime / child_time_width + child_timer_bar.mEndFraction = bar_time > 0 + ? bar_fraction_start + child_timer_bar.mTotalTime / bar_time : 1.f; - child_timer_bar.mSelfStart = timer_bar.mChildrenStart - + child_timer_bar.mStartFraction - * (timer_bar.mChildrenEnd - timer_bar.mChildrenStart); - child_timer_bar.mSelfEnd = timer_bar.mChildrenStart - + child_timer_bar.mEndFraction - * (timer_bar.mChildrenEnd - timer_bar.mChildrenStart); + child_timer_bar.mSelfStart = timer_bar.mChildrenStart + + child_timer_bar.mStartFraction + * (timer_bar.mChildrenEnd - timer_bar.mChildrenStart); + child_timer_bar.mSelfEnd = timer_bar.mChildrenStart + + child_timer_bar.mEndFraction + * (timer_bar.mChildrenEnd - timer_bar.mChildrenStart); timer_bar_index = updateTimerBarOffsets(child_time_block, row, timer_bar_index); @@ -1591,16 +1600,15 @@ S32 LLFastTimerView::updateTimerBarOffsets(LLTrace::TimeBlock* time_block, Timer return timer_bar_index; } -S32 LLFastTimerView::drawBar(LLRect bar_rect, TimerBarRow& row, S32 image_width, S32 image_height, bool hovered, S32 bar_index) +S32 LLFastTimerView::drawBar(LLRect bar_rect, TimerBarRow& row, S32 image_width, S32 image_height, bool hovered, bool visible, S32 bar_index) { - llassert(bar_index < row.mBars.size()); TimerBar& timer_bar = row.mBars[bar_index]; LLTrace::TimeBlock* time_block = timer_bar.mTimeBlock; hovered |= mHoverID == time_block; // animate scale of bar when hovering over that particular timer - if ((F32)bar_rect.getWidth() * (timer_bar.mEndFraction - timer_bar.mStartFraction) > 2.f) + if (visible && (F32)bar_rect.getWidth() * (timer_bar.mEndFraction - timer_bar.mStartFraction) > 2.f) { LLRect render_rect(bar_rect); S32 scale_offset = 0; @@ -1637,15 +1645,17 @@ S32 LLFastTimerView::drawBar(LLRect bar_rect, TimerBarRow& row, S32 image_width, children_rect.mBottom = bar_rect.mBottom; } + bool children_visible = visible && !time_block->getCollapsed(); + bar_index++; - const U32 num_bars = row.mBars.size(); + const U32 num_bars = LLInstanceTracker::instanceCount(); if (bar_index < num_bars && row.mBars[bar_index].mFirstChild) { bool is_last = false; do { is_last = row.mBars[bar_index].mLastChild; - bar_index = drawBar(children_rect, row, image_width, image_height, hovered, bar_index); + bar_index = drawBar(children_rect, row, image_width, image_height, hovered, children_visible, bar_index); } while(!is_last && bar_index < num_bars); } -- cgit v1.2.3 From c5fc8f90060aa7a6c8fbb72313172423b01eddc5 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Wed, 19 Jun 2013 08:23:53 -0700 Subject: SH-4246 FIX interesting: fast timers significantly decreases framerate moved collapsed flag to fast timer tree node --- indra/newview/llfasttimerview.cpp | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) (limited to 'indra/newview/llfasttimerview.cpp') diff --git a/indra/newview/llfasttimerview.cpp b/indra/newview/llfasttimerview.cpp index 1355b58f8b..ec307b841e 100755 --- a/indra/newview/llfasttimerview.cpp +++ b/indra/newview/llfasttimerview.cpp @@ -152,13 +152,13 @@ BOOL LLFastTimerView::handleRightMouseDown(S32 x, S32 y, MASK mask) if (mHoverTimer ) { // right click collapses timers - if (!mHoverTimer->getCollapsed()) + if (!mHoverTimer->getTreeNode().mCollapsed) { - mHoverTimer->setCollapsed(true); + mHoverTimer->getTreeNode().mCollapsed = true; } else if (mHoverTimer->getParent()) { - mHoverTimer->getParent()->setCollapsed(true); + mHoverTimer->getParent()->getTreeNode().mCollapsed = true; } return TRUE; } @@ -190,7 +190,7 @@ BOOL LLFastTimerView::handleDoubleClick(S32 x, S32 y, MASK mask) it != end_timer_tree(); ++it) { - (*it)->setCollapsed(false); + (*it)->getTreeNode().mCollapsed = false; } return TRUE; } @@ -202,13 +202,13 @@ BOOL LLFastTimerView::handleMouseDown(S32 x, S32 y, MASK mask) TimeBlock* idp = getLegendID(y); if (idp) { - idp->setCollapsed(!idp->getCollapsed()); + idp->getTreeNode().mCollapsed = !idp->getTreeNode().mCollapsed; } } else if (mHoverTimer) { //left click drills down by expanding timers - mHoverTimer->setCollapsed(false); + mHoverTimer->getTreeNode().mCollapsed = false; } else if (mGraphRect.pointInRect(x, y)) { @@ -273,7 +273,7 @@ BOOL LLFastTimerView::handleHover(S32 x, S32 y, MASK mask) if (bar.mSelfEnd > mouse_time_offset) { hover_bar = &bar; - if (bar.mTimeBlock->getCollapsed()) + if (bar.mTimeBlock->getTreeNode().mCollapsed) { // stop on first collapsed timeblock, since we can't select any children break; @@ -373,7 +373,7 @@ BOOL LLFastTimerView::handleScrollWheel(S32 x, S32 y, S32 clicks) return TRUE; } -static TimeBlock FTM_RENDER_TIMER("Timers", true); +static TimeBlock FTM_RENDER_TIMER("Timers"); static const S32 MARGIN = 10; static const S32 LEGEND_WIDTH = 220; @@ -975,7 +975,7 @@ void LLFastTimerView::printLineStats() first = false; legend_stat += idp->getName(); - if (idp->getCollapsed()) + if (idp->getTreeNode().mCollapsed) { it.skipDescendants(); } @@ -1009,7 +1009,7 @@ void LLFastTimerView::printLineStats() timer_stat += llformat("%.1f",ms.value()); - if (idp->getCollapsed()) + if (idp->getTreeNode().mCollapsed) { it.skipDescendants(); } @@ -1135,7 +1135,7 @@ void LLFastTimerView::drawLineGraph() glLineWidth(1); } - if (idp->getCollapsed()) + if (idp->getTreeNode().mCollapsed) { //skip hidden timers it.skipDescendants(); @@ -1267,7 +1267,7 @@ void LLFastTimerView::drawLegend() gl_line_2d(x + dx - 8, line_start_y, x + dx, line_start_y, color); S32 line_x = x + (TEXT_HEIGHT + 4) + ((get_depth(idp) - 1) * 8); gl_line_2d(line_x, line_start_y, line_x, line_end_y, color); - if (idp->getCollapsed() && !idp->getChildren().empty()) + if (idp->getTreeNode().mCollapsed && !idp->getChildren().empty()) { gl_line_2d(line_x+4, line_start_y-3, line_x+4, line_start_y+4, color); } @@ -1291,7 +1291,7 @@ void LLFastTimerView::drawLegend() y -= (TEXT_HEIGHT + 2); - if (idp->getCollapsed()) + if (idp->getTreeNode().mCollapsed) { it.skipDescendants(); } @@ -1645,7 +1645,7 @@ S32 LLFastTimerView::drawBar(LLRect bar_rect, TimerBarRow& row, S32 image_width, children_rect.mBottom = bar_rect.mBottom; } - bool children_visible = visible && !time_block->getCollapsed(); + bool children_visible = visible && !time_block->getTreeNode().mCollapsed; bar_index++; const U32 num_bars = LLInstanceTracker::instanceCount(); -- cgit v1.2.3 From ba9bffd0195e6606daa39760eec75ede954b4040 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Wed, 19 Jun 2013 20:39:59 -0700 Subject: BUILDFIX: forgot a file --- indra/newview/llfasttimerview.cpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'indra/newview/llfasttimerview.cpp') diff --git a/indra/newview/llfasttimerview.cpp b/indra/newview/llfasttimerview.cpp index ec307b841e..f956851129 100755 --- a/indra/newview/llfasttimerview.cpp +++ b/indra/newview/llfasttimerview.cpp @@ -99,7 +99,7 @@ LLFastTimerView::LLFastTimerView(const LLSD& key) : LLFloater(key), mHoverTimer(NULL), mDisplayMode(0), - mDisplayType(TIME), + mDisplayType(DISPLAY_TIME), mScrollIndex(0), mHoverID(NULL), mHoverBarIndex(-1), @@ -1114,13 +1114,13 @@ void LLFastTimerView::drawLineGraph() F32 y; switch(mDisplayType) { - case TIME: + case DISPLAY_TIME: y = mGraphRect.mBottom + time.value() * time_scale_factor; break; - case CALLS: + case DISPLAY_CALLS: y = mGraphRect.mBottom + (F32)calls * call_scale_factor; break; - case HZ: + case DISPLAY_HZ: y = mGraphRect.mBottom + (1.f / time.value()) * hz_scale_factor; break; } @@ -1178,13 +1178,13 @@ void LLFastTimerView::drawLineGraph() std::string axis_label; switch(mDisplayType) { - case TIME: + case DISPLAY_TIME: axis_label = llformat("%4.2f ms", LLUnit(max_time).value()); break; - case CALLS: + case DISPLAY_CALLS: axis_label = llformat("%d calls", (int)max_calls); break; - case HZ: + case DISPLAY_HZ: axis_label = llformat("%4.2f Hz", max_time.value() ? 1.f / max_time.value() : 0.f); break; } @@ -1247,13 +1247,13 @@ void LLFastTimerView::drawLegend() std::string timer_label; switch(mDisplayType) { - case TIME: + case DISPLAY_TIME: timer_label = llformat("%s [%.1f]",idp->getName().c_str(),ms.value()); break; - case CALLS: + case DISPLAY_CALLS: timer_label = llformat("%s (%d)",idp->getName().c_str(),calls); break; - case HZ: + case DISPLAY_HZ: timer_label = llformat("%.1f", ms.value() ? (1.f / ms.value()) : 0.f); break; } -- cgit v1.2.3 From ffa7123bb5187e1da491a8f475d696053d9c9ee4 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Fri, 28 Jun 2013 20:45:20 -0700 Subject: SH-4299 FIX Interesting: High fps shown temporarily off scale in statistics console added ability to force uniqueness of LLCopyOnWritePointer converted more variables to units added convenience function for unit constants --- indra/newview/llfasttimerview.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'indra/newview/llfasttimerview.cpp') diff --git a/indra/newview/llfasttimerview.cpp b/indra/newview/llfasttimerview.cpp index d3a97fde0e..7a5e1dcad0 100755 --- a/indra/newview/llfasttimerview.cpp +++ b/indra/newview/llfasttimerview.cpp @@ -1101,7 +1101,7 @@ void LLFastTimerView::drawLineGraph() j--) { LLTrace::Recording& recording = mRecording.getPrevRecording(j); - LLUnit time = llmax(recording.getSum(*idp), LLUnit(0.000001)); + LLUnit time = llmax(recording.getSum(*idp), LLUnits::Seconds::fromValue(0.000001)); U32 calls = recording.getSum(idp->callCount()); if (is_hover_timer) @@ -1126,7 +1126,7 @@ void LLFastTimerView::drawLineGraph() } gGL.vertex2f(x,y); gGL.vertex2f(x,mGraphRect.mBottom); -} + } gGL.end(); if (mHoverID == idp) @@ -1146,7 +1146,7 @@ void LLFastTimerView::drawLineGraph() max_time = lerp(max_time.value(), cur_max.value(), LLSmoothInterpolation::getInterpolant(0.1f)); if (llabs((max_time - cur_max).value()) <= 1) { - max_time = llmax(LLUnit(1), LLUnit(cur_max)); + max_time = llmax(LLUnits::Microseconds::fromValue(1.f), LLUnits::Microseconds::fromValue(cur_max)); } max_calls = llround(lerp((F32)max_calls, (F32) cur_max_calls, LLSmoothInterpolation::getInterpolant(0.1f))); @@ -1423,11 +1423,11 @@ void LLFastTimerView::updateTotalTime() mTotalTimeDisplay = mRecording.getPeriodMax(FTM_FRAME, 20); break; default: - mTotalTimeDisplay = LLUnit(100); + mTotalTimeDisplay = LLUnits::Milliseconds::fromValue(100); break; } - mTotalTimeDisplay = LLUnit(llceil(mTotalTimeDisplay.getAs() / 20.f) * 20.f); + mTotalTimeDisplay = LLUnits::Milliseconds::fromValue(llceil(mTotalTimeDisplay.valueAs() / 20.f) * 20.f); } void LLFastTimerView::drawBars() -- cgit v1.2.3 From 04bdc8ba83c297945dd60489c241b88adf892ff4 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Mon, 1 Jul 2013 17:04:01 -0700 Subject: SH-4294 FIX Interesting: Statistics Texture cache hit rate is always 0% also, removed LLTrace::init and cleanup removed derived class implementation of memory stat for LLMemTrackable is automatic now --- indra/newview/llfasttimerview.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'indra/newview/llfasttimerview.cpp') diff --git a/indra/newview/llfasttimerview.cpp b/indra/newview/llfasttimerview.cpp index 7a5e1dcad0..d922659435 100755 --- a/indra/newview/llfasttimerview.cpp +++ b/indra/newview/llfasttimerview.cpp @@ -430,18 +430,18 @@ void LLFastTimerView::draw() } void LLFastTimerView::onOpen(const LLSD& key) - { +{ setPauseState(false); mRecording.reset(); mRecording.appendPeriodicRecording(LLTrace::get_frame_recording()); for(std::deque::iterator it = mTimerBarRows.begin(), end_it = mTimerBarRows.end(); it != end_it; - ++it) - { + ++it) + { delete []it->mBars; it->mBars = NULL; - } - } + } +} void saveChart(const std::string& label, const char* suffix, LLImageRaw* scratch) -- cgit v1.2.3 From 50c472c24216ad0c3890cb8bb9cf638e75642f0c Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Tue, 23 Jul 2013 18:47:16 -0700 Subject: renamed mVarianceSum to mSumOfSquares to be more clear fixed normalization assertions to work with megaprims added is_zero() utility function fixed unit declarations to be more clear fixed texture cache hit rate always being 0 --- indra/newview/llfasttimerview.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/newview/llfasttimerview.cpp') diff --git a/indra/newview/llfasttimerview.cpp b/indra/newview/llfasttimerview.cpp index d922659435..b61889ccfa 100755 --- a/indra/newview/llfasttimerview.cpp +++ b/indra/newview/llfasttimerview.cpp @@ -1338,7 +1338,7 @@ void LLFastTimerView::drawHelp( S32 y ) y -= (texth + 2); y -= (texth + 2); - LLFontGL::getFontMonospace()->renderUTF8(std::string("[Right-Click log selected] [ALT-Click toggle counts]"), + LLFontGL::getFontMonospace()->renderUTF8(std::string("[Right-Click log selected]"), 0, MARGIN, y, LLColor4::white, LLFontGL::LEFT, LLFontGL::TOP); } -- cgit v1.2.3 From bd5808765f7a74226d312afbb863c471528b8d1a Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Wed, 31 Jul 2013 19:32:50 -0700 Subject: cleanup - renamed valueAs to valueInUnits and made it a symmetrical getter/setter --- indra/newview/llfasttimerview.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/newview/llfasttimerview.cpp') diff --git a/indra/newview/llfasttimerview.cpp b/indra/newview/llfasttimerview.cpp index b61889ccfa..4037b5ebdd 100755 --- a/indra/newview/llfasttimerview.cpp +++ b/indra/newview/llfasttimerview.cpp @@ -1427,7 +1427,7 @@ void LLFastTimerView::updateTotalTime() break; } - mTotalTimeDisplay = LLUnits::Milliseconds::fromValue(llceil(mTotalTimeDisplay.valueAs() / 20.f) * 20.f); + mTotalTimeDisplay = LLUnits::Milliseconds::fromValue(llceil(mTotalTimeDisplay.valueInUnits() / 20.f) * 20.f); } void LLFastTimerView::drawBars() -- cgit v1.2.3 From e340009fc59d59e59b2e8d903a884acb76b178eb Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Fri, 9 Aug 2013 17:11:19 -0700 Subject: second phase summer cleaning replace llinfos, lldebugs, etc with new LL_INFOS(), LL_DEBUGS(), etc. --- indra/newview/llfasttimerview.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'indra/newview/llfasttimerview.cpp') diff --git a/indra/newview/llfasttimerview.cpp b/indra/newview/llfasttimerview.cpp index 4037b5ebdd..bb9e474098 100755 --- a/indra/newview/llfasttimerview.cpp +++ b/indra/newview/llfasttimerview.cpp @@ -836,7 +836,7 @@ void LLFastTimerView::doAnalysisDefault(std::string baseline, std::string target std::ifstream target_is(target.c_str()); if (!base_is.is_open() || !target_is.is_open()) { - llwarns << "'-analyzeperformance' error : baseline or current target file inexistent" << llendl; + LL_WARNS() << "'-analyzeperformance' error : baseline or current target file inexistent" << LL_ENDL; base_is.close(); target_is.close(); return; @@ -980,7 +980,7 @@ void LLFastTimerView::printLineStats() it.skipDescendants(); } } - llinfos << legend_stat << llendl; + LL_INFOS() << legend_stat << LL_ENDL; std::string timer_stat; first = true; @@ -1014,7 +1014,7 @@ void LLFastTimerView::printLineStats() it.skipDescendants(); } } - llinfos << timer_stat << llendl; + LL_INFOS() << timer_stat << LL_ENDL; mStatsIndex = -1; } } -- cgit v1.2.3 From 26581404e426b00cd0a07c38b5cb858d5d5faa28 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Wed, 14 Aug 2013 11:51:49 -0700 Subject: BUILDFIX: added header for numeric_limits support on gcc added convenience types for units F32Seconds, etc. --- indra/newview/llfasttimerview.cpp | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) (limited to 'indra/newview/llfasttimerview.cpp') diff --git a/indra/newview/llfasttimerview.cpp b/indra/newview/llfasttimerview.cpp index bb9e474098..11a9a70b18 100755 --- a/indra/newview/llfasttimerview.cpp +++ b/indra/newview/llfasttimerview.cpp @@ -260,7 +260,7 @@ BOOL LLFastTimerView::handleHover(S32 x, S32 y, MASK mask) TimerBarRow& row = mHoverBarIndex == 0 ? mAverageTimerRow : mTimerBarRows[mScrollIndex + mHoverBarIndex - 1]; TimerBar* hover_bar = NULL; - LLUnit mouse_time_offset = ((F32)(x - mBarRect.mLeft) / (F32)mBarRect.getWidth()) * mTotalTimeDisplay; + LLUnits::F32Seconds mouse_time_offset = ((F32)(x - mBarRect.mLeft) / (F32)mBarRect.getWidth()) * mTotalTimeDisplay; for (int bar_index = 0, end_index = LLInstanceTracker::instanceCount(); bar_index < end_index; ++bar_index) @@ -996,7 +996,7 @@ void LLFastTimerView::printLineStats() } first = false; - LLUnit ticks; + LLUnits::F32Seconds ticks; if (mStatsIndex == 0) { ticks = mRecording.getPeriodMean(*idp, RUNNING_AVERAGE_WIDTH); @@ -1029,7 +1029,7 @@ void LLFastTimerView::drawLineGraph() LLLocalClipRect clip(mGraphRect); //normalize based on last frame's maximum - static LLUnit max_time = 0.000001; + static LLUnits::F32Seconds max_time(0.000001); static U32 max_calls = 0; static F32 alpha_interp = 0.f; @@ -1060,7 +1060,7 @@ void LLFastTimerView::drawLineGraph() } } - LLUnit cur_max = 0; + LLUnits::F32Seconds cur_max(0); U32 cur_max_calls = 0; for(timer_tree_iterator_t it = begin_timer_tree(FTM_FRAME); it != end_timer_tree(); @@ -1101,7 +1101,7 @@ void LLFastTimerView::drawLineGraph() j--) { LLTrace::Recording& recording = mRecording.getPrevRecording(j); - LLUnit time = llmax(recording.getSum(*idp), LLUnits::Seconds::fromValue(0.000001)); + LLUnits::F32Seconds time = llmax(recording.getSum(*idp), LLUnits::F64Seconds(0.000001)); U32 calls = recording.getSum(idp->callCount()); if (is_hover_timer) @@ -1146,7 +1146,7 @@ void LLFastTimerView::drawLineGraph() max_time = lerp(max_time.value(), cur_max.value(), LLSmoothInterpolation::getInterpolant(0.1f)); if (llabs((max_time - cur_max).value()) <= 1) { - max_time = llmax(LLUnits::Microseconds::fromValue(1.f), LLUnits::Microseconds::fromValue(cur_max)); + max_time = llmax(LLUnits::F32Microseconds(1.f), LLUnits::F32Microseconds(cur_max)); } max_calls = llround(lerp((F32)max_calls, (F32) cur_max_calls, LLSmoothInterpolation::getInterpolant(0.1f))); @@ -1230,7 +1230,7 @@ void LLFastTimerView::drawLegend() llassert(idp->getIndex() < sTimerColors.size()); gl_rect_2d(bar_rect, sTimerColors[idp->getIndex()]); - LLUnit ms = 0; + LLUnit ms(0); S32 calls = 0; if (mHoverBarIndex > 0 && mHoverID) { @@ -1240,7 +1240,7 @@ void LLFastTimerView::drawLegend() } else { - ms = LLUnit(mRecording.getPeriodMean(*idp, RUNNING_AVERAGE_WIDTH)); + ms = LLUnits::F64Seconds(mRecording.getPeriodMean(*idp, RUNNING_AVERAGE_WIDTH)); calls = (S32)mRecording.getPeriodMean(idp->callCount(), RUNNING_AVERAGE_WIDTH); } @@ -1423,7 +1423,7 @@ void LLFastTimerView::updateTotalTime() mTotalTimeDisplay = mRecording.getPeriodMax(FTM_FRAME, 20); break; default: - mTotalTimeDisplay = LLUnits::Milliseconds::fromValue(100); + mTotalTimeDisplay = LLUnits::F64Milliseconds(100); break; } @@ -1511,14 +1511,14 @@ void LLFastTimerView::drawBars() static LLFastTimer::DeclareTimer FTM_UPDATE_TIMER_BAR_WIDTHS("Update timer bar widths"); -LLUnit LLFastTimerView::updateTimerBarWidths(LLTrace::TimeBlock* time_block, TimerBarRow& row, S32 history_index, U32& bar_index) +LLUnits::F32Seconds LLFastTimerView::updateTimerBarWidths(LLTrace::TimeBlock* time_block, TimerBarRow& row, S32 history_index, U32& bar_index) { LLFastTimer _(FTM_UPDATE_TIMER_BAR_WIDTHS); - const LLUnit self_time = history_index == -1 + const LLUnits::F32Seconds self_time = history_index == -1 ? mRecording.getPeriodMean(time_block->selfTime(), RUNNING_AVERAGE_WIDTH) : mRecording.getPrevRecording(history_index).getSum(time_block->selfTime()); - LLUnit full_time = self_time; + LLUnits::F32Seconds full_time = self_time; // reserve a spot for this bar to be rendered before its children // even though we don't know its size yet @@ -1544,7 +1544,7 @@ S32 LLFastTimerView::updateTimerBarOffsets(LLTrace::TimeBlock* time_block, Timer LLFastTimer _(FTM_UPDATE_TIMER_BAR_FRACTIONS); TimerBar& timer_bar = row.mBars[timer_bar_index]; - const LLUnit bar_time = timer_bar.mTotalTime - timer_bar.mSelfTime; + const LLUnits::F32Seconds bar_time = timer_bar.mTotalTime - timer_bar.mSelfTime; timer_bar.mChildrenStart = timer_bar.mSelfStart + timer_bar.mSelfTime / 2; timer_bar.mChildrenEnd = timer_bar.mChildrenStart + timer_bar.mTotalTime - timer_bar.mSelfTime; -- cgit v1.2.3 From 9f7bfa1c3710856cd2b0a0a8a429d6c45b0fcd09 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Thu, 15 Aug 2013 00:02:23 -0700 Subject: moved unit types out of LLUnits namespace, since they are prefixed --- indra/newview/llfasttimerview.cpp | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) (limited to 'indra/newview/llfasttimerview.cpp') diff --git a/indra/newview/llfasttimerview.cpp b/indra/newview/llfasttimerview.cpp index 11a9a70b18..725a2f2daf 100755 --- a/indra/newview/llfasttimerview.cpp +++ b/indra/newview/llfasttimerview.cpp @@ -260,7 +260,7 @@ BOOL LLFastTimerView::handleHover(S32 x, S32 y, MASK mask) TimerBarRow& row = mHoverBarIndex == 0 ? mAverageTimerRow : mTimerBarRows[mScrollIndex + mHoverBarIndex - 1]; TimerBar* hover_bar = NULL; - LLUnits::F32Seconds mouse_time_offset = ((F32)(x - mBarRect.mLeft) / (F32)mBarRect.getWidth()) * mTotalTimeDisplay; + F32Seconds mouse_time_offset = ((F32)(x - mBarRect.mLeft) / (F32)mBarRect.getWidth()) * mTotalTimeDisplay; for (int bar_index = 0, end_index = LLInstanceTracker::instanceCount(); bar_index < end_index; ++bar_index) @@ -317,11 +317,11 @@ static std::string get_tooltip(TimeBlock& timer, S32 history_index, PeriodicReco if (history_index == 0) { // by default, show average number of call - tooltip = llformat("%s (%d ms, %d calls)", timer.getName().c_str(), (S32)LLUnit(frame_recording.getPeriodMean (timer, RUNNING_AVERAGE_WIDTH)).value(), (S32)frame_recording.getPeriodMean(timer.callCount(), RUNNING_AVERAGE_WIDTH)); + tooltip = llformat("%s (%d ms, %d calls)", timer.getName().c_str(), (S32)F64Milliseconds(frame_recording.getPeriodMean (timer, RUNNING_AVERAGE_WIDTH)).value(), (S32)frame_recording.getPeriodMean(timer.callCount(), RUNNING_AVERAGE_WIDTH)); } else { - tooltip = llformat("%s (%d ms, %d calls)", timer.getName().c_str(), (S32)LLUnit(frame_recording.getPrevRecording(history_index).getSum(timer)).value(), (S32)frame_recording.getPrevRecording(history_index).getSum(timer.callCount())); + tooltip = llformat("%s (%d ms, %d calls)", timer.getName().c_str(), (S32)F64Milliseconds(frame_recording.getPrevRecording(history_index).getSum(timer)).value(), (S32)frame_recording.getPrevRecording(history_index).getSum(timer.callCount())); } return tooltip; } @@ -996,7 +996,7 @@ void LLFastTimerView::printLineStats() } first = false; - LLUnits::F32Seconds ticks; + F32Seconds ticks; if (mStatsIndex == 0) { ticks = mRecording.getPeriodMean(*idp, RUNNING_AVERAGE_WIDTH); @@ -1005,7 +1005,7 @@ void LLFastTimerView::printLineStats() { ticks = mRecording.getPrevRecording(mStatsIndex).getSum(*idp); } - LLUnit ms = ticks; + F32Milliseconds ms = ticks; timer_stat += llformat("%.1f",ms.value()); @@ -1029,7 +1029,7 @@ void LLFastTimerView::drawLineGraph() LLLocalClipRect clip(mGraphRect); //normalize based on last frame's maximum - static LLUnits::F32Seconds max_time(0.000001); + static F32Seconds max_time(0.000001); static U32 max_calls = 0; static F32 alpha_interp = 0.f; @@ -1060,7 +1060,7 @@ void LLFastTimerView::drawLineGraph() } } - LLUnits::F32Seconds cur_max(0); + F32Seconds cur_max(0); U32 cur_max_calls = 0; for(timer_tree_iterator_t it = begin_timer_tree(FTM_FRAME); it != end_timer_tree(); @@ -1101,7 +1101,7 @@ void LLFastTimerView::drawLineGraph() j--) { LLTrace::Recording& recording = mRecording.getPrevRecording(j); - LLUnits::F32Seconds time = llmax(recording.getSum(*idp), LLUnits::F64Seconds(0.000001)); + F32Seconds time = llmax(recording.getSum(*idp), F64Seconds(0.000001)); U32 calls = recording.getSum(idp->callCount()); if (is_hover_timer) @@ -1146,7 +1146,7 @@ void LLFastTimerView::drawLineGraph() max_time = lerp(max_time.value(), cur_max.value(), LLSmoothInterpolation::getInterpolant(0.1f)); if (llabs((max_time - cur_max).value()) <= 1) { - max_time = llmax(LLUnits::F32Microseconds(1.f), LLUnits::F32Microseconds(cur_max)); + max_time = llmax(F32Microseconds(1.f), F32Microseconds(cur_max)); } max_calls = llround(lerp((F32)max_calls, (F32) cur_max_calls, LLSmoothInterpolation::getInterpolant(0.1f))); @@ -1179,7 +1179,7 @@ void LLFastTimerView::drawLineGraph() switch(mDisplayType) { case DISPLAY_TIME: - axis_label = llformat("%4.2f ms", LLUnit(max_time).value()); + axis_label = llformat("%4.2f ms", F32Milliseconds(max_time).value()); break; case DISPLAY_CALLS: axis_label = llformat("%d calls", (int)max_calls); @@ -1230,7 +1230,7 @@ void LLFastTimerView::drawLegend() llassert(idp->getIndex() < sTimerColors.size()); gl_rect_2d(bar_rect, sTimerColors[idp->getIndex()]); - LLUnit ms(0); + F32Milliseconds ms(0); S32 calls = 0; if (mHoverBarIndex > 0 && mHoverID) { @@ -1240,7 +1240,7 @@ void LLFastTimerView::drawLegend() } else { - ms = LLUnits::F64Seconds(mRecording.getPeriodMean(*idp, RUNNING_AVERAGE_WIDTH)); + ms = F64Seconds(mRecording.getPeriodMean(*idp, RUNNING_AVERAGE_WIDTH)); calls = (S32)mRecording.getPeriodMean(idp->callCount(), RUNNING_AVERAGE_WIDTH); } @@ -1346,7 +1346,7 @@ void LLFastTimerView::drawTicks() { // Draw MS ticks { - LLUnit ms = mTotalTimeDisplay; + U32Milliseconds ms = mTotalTimeDisplay; std::string tick_label; S32 x; S32 barw = mBarRect.getWidth(); @@ -1423,7 +1423,7 @@ void LLFastTimerView::updateTotalTime() mTotalTimeDisplay = mRecording.getPeriodMax(FTM_FRAME, 20); break; default: - mTotalTimeDisplay = LLUnits::F64Milliseconds(100); + mTotalTimeDisplay = F64Milliseconds(100); break; } @@ -1511,14 +1511,14 @@ void LLFastTimerView::drawBars() static LLFastTimer::DeclareTimer FTM_UPDATE_TIMER_BAR_WIDTHS("Update timer bar widths"); -LLUnits::F32Seconds LLFastTimerView::updateTimerBarWidths(LLTrace::TimeBlock* time_block, TimerBarRow& row, S32 history_index, U32& bar_index) +F32Seconds LLFastTimerView::updateTimerBarWidths(LLTrace::TimeBlock* time_block, TimerBarRow& row, S32 history_index, U32& bar_index) { LLFastTimer _(FTM_UPDATE_TIMER_BAR_WIDTHS); - const LLUnits::F32Seconds self_time = history_index == -1 + const F32Seconds self_time = history_index == -1 ? mRecording.getPeriodMean(time_block->selfTime(), RUNNING_AVERAGE_WIDTH) : mRecording.getPrevRecording(history_index).getSum(time_block->selfTime()); - LLUnits::F32Seconds full_time = self_time; + F32Seconds full_time = self_time; // reserve a spot for this bar to be rendered before its children // even though we don't know its size yet @@ -1544,7 +1544,7 @@ S32 LLFastTimerView::updateTimerBarOffsets(LLTrace::TimeBlock* time_block, Timer LLFastTimer _(FTM_UPDATE_TIMER_BAR_FRACTIONS); TimerBar& timer_bar = row.mBars[timer_bar_index]; - const LLUnits::F32Seconds bar_time = timer_bar.mTotalTime - timer_bar.mSelfTime; + const F32Seconds bar_time = timer_bar.mTotalTime - timer_bar.mSelfTime; timer_bar.mChildrenStart = timer_bar.mSelfStart + timer_bar.mSelfTime / 2; timer_bar.mChildrenEnd = timer_bar.mChildrenStart + timer_bar.mTotalTime - timer_bar.mSelfTime; -- cgit v1.2.3 From 612892b45a3413b16e40c49d3bfde77a4ca927fd Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Sun, 18 Aug 2013 22:30:27 -0700 Subject: SH-4433 WIP: Interesting: Statistics > Ping Sim is always 0 ms continued conversion to units system made units perform type promotion correctly and preserve type in arithmetic e.g. can now do LLVector3 in units added typedefs for remaining common unit types, including implicits --- indra/newview/llfasttimerview.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'indra/newview/llfasttimerview.cpp') diff --git a/indra/newview/llfasttimerview.cpp b/indra/newview/llfasttimerview.cpp index 725a2f2daf..36cbd67333 100755 --- a/indra/newview/llfasttimerview.cpp +++ b/indra/newview/llfasttimerview.cpp @@ -1143,7 +1143,7 @@ void LLFastTimerView::drawLineGraph() } //interpolate towards new maximum - max_time = lerp(max_time.value(), cur_max.value(), LLSmoothInterpolation::getInterpolant(0.1f)); + max_time = (F32Seconds)lerp(max_time.value(), cur_max.value(), LLSmoothInterpolation::getInterpolant(0.1f)); if (llabs((max_time - cur_max).value()) <= 1) { max_time = llmax(F32Microseconds(1.f), F32Microseconds(cur_max)); @@ -1439,7 +1439,7 @@ void LLFastTimerView::drawBars() bar_height -= vpad; updateTotalTime(); - if (mTotalTimeDisplay <= 0.0) return; + if (mTotalTimeDisplay <= (F32Seconds)0.0) return; drawTicks(); const S32 bars_top = mBarRect.mTop - ((S32)LLFontGL::getFontMonospace()->getLineHeight() + 4); @@ -1550,7 +1550,7 @@ S32 LLFastTimerView::updateTimerBarOffsets(LLTrace::TimeBlock* time_block, Timer if (timer_bar_index == 0) { - timer_bar.mSelfStart = 0.f; + timer_bar.mSelfStart = F32Seconds(0.f); timer_bar.mSelfEnd = bar_time; } @@ -1583,7 +1583,7 @@ S32 LLFastTimerView::updateTimerBarOffsets(LLTrace::TimeBlock* time_block, Timer } child_timer_bar.mStartFraction = bar_fraction_start; - child_timer_bar.mEndFraction = bar_time > 0 + child_timer_bar.mEndFraction = bar_time > (S32Seconds)0 ? bar_fraction_start + child_timer_bar.mTotalTime / bar_time : 1.f; child_timer_bar.mSelfStart = timer_bar.mChildrenStart -- cgit v1.2.3 From 9c256611f1814b843e1adc29f8a9185a3519eeaf Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Mon, 19 Aug 2013 16:05:03 -0700 Subject: BUILDFIX: removed consideration of some bad overloads in return type evaluation of unit operators --- indra/newview/llfasttimerview.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'indra/newview/llfasttimerview.cpp') diff --git a/indra/newview/llfasttimerview.cpp b/indra/newview/llfasttimerview.cpp index 36cbd67333..e8db263fae 100755 --- a/indra/newview/llfasttimerview.cpp +++ b/indra/newview/llfasttimerview.cpp @@ -282,14 +282,14 @@ BOOL LLFastTimerView::handleHover(S32 x, S32 y, MASK mask) } if (hover_bar) - { + { mHoverID = hover_bar->mTimeBlock; if (mHoverTimer != mHoverID) - { - // could be that existing tooltip is for a parent and is thus - // covering region for this new timer, go ahead and unblock - // so we can create a new tooltip - LLToolTipMgr::instance().unblockToolTips(); + { + // could be that existing tooltip is for a parent and is thus + // covering region for this new timer, go ahead and unblock + // so we can create a new tooltip + LLToolTipMgr::instance().unblockToolTips(); mHoverTimer = mHoverID; mToolTipRect.set(mBarRect.mLeft + (hover_bar->mSelfStart / mTotalTimeDisplay) * mBarRect.getWidth(), row.mTop, -- cgit v1.2.3 From cbe397ad13665c7bc993e10d8fe1e4a876253378 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Thu, 5 Sep 2013 14:04:13 -0700 Subject: changed fast timer over to using macro another attempt to move mem stat into base class --- indra/newview/llfasttimerview.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'indra/newview/llfasttimerview.cpp') diff --git a/indra/newview/llfasttimerview.cpp b/indra/newview/llfasttimerview.cpp index e8db263fae..bbd8f0792a 100755 --- a/indra/newview/llfasttimerview.cpp +++ b/indra/newview/llfasttimerview.cpp @@ -381,7 +381,7 @@ static std::vector sTimerColors; void LLFastTimerView::draw() { - LLFastTimer t(FTM_RENDER_TIMER); + LL_RECORD_BLOCK_TIME(FTM_RENDER_TIMER); if (!mPauseHistory) { @@ -1019,11 +1019,11 @@ void LLFastTimerView::printLineStats() } } -static LLFastTimer::DeclareTimer FTM_DRAW_LINE_GRAPH("Draw line graph"); +static LLTrace::TimeBlock FTM_DRAW_LINE_GRAPH("Draw line graph"); void LLFastTimerView::drawLineGraph() { - LLFastTimer _(FTM_DRAW_LINE_GRAPH); + LL_RECORD_BLOCK_TIME(FTM_DRAW_LINE_GRAPH); //draw line graph history gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); LLLocalClipRect clip(mGraphRect); @@ -1509,11 +1509,11 @@ void LLFastTimerView::drawBars() gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); } -static LLFastTimer::DeclareTimer FTM_UPDATE_TIMER_BAR_WIDTHS("Update timer bar widths"); +static LLTrace::TimeBlock FTM_UPDATE_TIMER_BAR_WIDTHS("Update timer bar widths"); F32Seconds LLFastTimerView::updateTimerBarWidths(LLTrace::TimeBlock* time_block, TimerBarRow& row, S32 history_index, U32& bar_index) { - LLFastTimer _(FTM_UPDATE_TIMER_BAR_WIDTHS); + LL_RECORD_BLOCK_TIME(FTM_UPDATE_TIMER_BAR_WIDTHS); const F32Seconds self_time = history_index == -1 ? mRecording.getPeriodMean(time_block->selfTime(), RUNNING_AVERAGE_WIDTH) : mRecording.getPrevRecording(history_index).getSum(time_block->selfTime()); @@ -1537,11 +1537,11 @@ F32Seconds LLFastTimerView::updateTimerBarWidths(LLTrace::TimeBlock* time_block, return full_time; } -static LLFastTimer::DeclareTimer FTM_UPDATE_TIMER_BAR_FRACTIONS("Update timer bar fractions"); +static LLTrace::TimeBlock FTM_UPDATE_TIMER_BAR_FRACTIONS("Update timer bar fractions"); S32 LLFastTimerView::updateTimerBarOffsets(LLTrace::TimeBlock* time_block, TimerBarRow& row, S32 timer_bar_index) { - LLFastTimer _(FTM_UPDATE_TIMER_BAR_FRACTIONS); + LL_RECORD_BLOCK_TIME(FTM_UPDATE_TIMER_BAR_FRACTIONS); TimerBar& timer_bar = row.mBars[timer_bar_index]; const F32Seconds bar_time = timer_bar.mTotalTime - timer_bar.mSelfTime; -- cgit v1.2.3 From f8a85003ddd4bee1ae00fc329c1c1d66d6100cbd Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Thu, 3 Oct 2013 19:04:51 -0700 Subject: more memory optimizations of lltrace --- indra/newview/llfasttimerview.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/newview/llfasttimerview.cpp') diff --git a/indra/newview/llfasttimerview.cpp b/indra/newview/llfasttimerview.cpp index bbd8f0792a..4809a6b7da 100755 --- a/indra/newview/llfasttimerview.cpp +++ b/indra/newview/llfasttimerview.cpp @@ -62,7 +62,7 @@ static const S32 MAX_VISIBLE_HISTORY = 12; static const S32 LINE_GRAPH_HEIGHT = 240; static const S32 MIN_BAR_HEIGHT = 3; static const S32 RUNNING_AVERAGE_WIDTH = 100; -static const S32 NUM_FRAMES_HISTORY = 256; +static const S32 NUM_FRAMES_HISTORY = 200; std::vector ft_display_idx; // line of table entry for display purposes (for collapse) -- cgit v1.2.3 From 697d2e720ba75e142a4d56ae8794bab8d7698dad Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Tue, 15 Oct 2013 20:24:42 -0700 Subject: renamed TimeBlock to BlockTimerStatHandle --- indra/newview/llfasttimerview.cpp | 74 +++++++++++++++++++-------------------- 1 file changed, 37 insertions(+), 37 deletions(-) (limited to 'indra/newview/llfasttimerview.cpp') diff --git a/indra/newview/llfasttimerview.cpp b/indra/newview/llfasttimerview.cpp index 4809a6b7da..6153c43690 100755 --- a/indra/newview/llfasttimerview.cpp +++ b/indra/newview/llfasttimerview.cpp @@ -64,17 +64,17 @@ static const S32 MIN_BAR_HEIGHT = 3; static const S32 RUNNING_AVERAGE_WIDTH = 100; static const S32 NUM_FRAMES_HISTORY = 200; -std::vector ft_display_idx; // line of table entry for display purposes (for collapse) +std::vector ft_display_idx; // line of table entry for display purposes (for collapse) -typedef LLTreeDFSIter timer_tree_iterator_t; +typedef LLTreeDFSIter timer_tree_iterator_t; BOOL LLFastTimerView::sAnalyzePerformance = FALSE; -static timer_tree_iterator_t begin_timer_tree(TimeBlock& id) +static timer_tree_iterator_t begin_timer_tree(BlockTimerStatHandle& id) { return timer_tree_iterator_t(&id, - boost::bind(boost::mem_fn(&TimeBlock::beginChildren), _1), - boost::bind(boost::mem_fn(&TimeBlock::endChildren), _1)); + boost::bind(boost::mem_fn(&BlockTimerStatHandle::beginChildren), _1), + boost::bind(boost::mem_fn(&BlockTimerStatHandle::endChildren), _1)); } static timer_tree_iterator_t end_timer_tree() @@ -82,10 +82,10 @@ static timer_tree_iterator_t end_timer_tree() return timer_tree_iterator_t(); } -S32 get_depth(const TimeBlock* blockp) +S32 get_depth(const BlockTimerStatHandle* blockp) { S32 depth = 0; - TimeBlock* timerp = blockp->getParent(); + BlockTimerStatHandle* timerp = blockp->getParent(); while(timerp) { depth++; @@ -172,7 +172,7 @@ BOOL LLFastTimerView::handleRightMouseDown(S32 x, S32 y, MASK mask) return LLFloater::handleRightMouseDown(x, y, mask); } -TimeBlock* LLFastTimerView::getLegendID(S32 y) +BlockTimerStatHandle* LLFastTimerView::getLegendID(S32 y) { S32 idx = (mLegendRect.mTop - y) / (LLFontGL::getFontMonospace()->getLineHeight() + 2); @@ -199,7 +199,7 @@ BOOL LLFastTimerView::handleMouseDown(S32 x, S32 y, MASK mask) { if (x < mBarRect.mLeft) { - TimeBlock* idp = getLegendID(y); + BlockTimerStatHandle* idp = getLegendID(y); if (idp) { idp->getTreeNode().mCollapsed = !idp->getTreeNode().mCollapsed; @@ -261,7 +261,7 @@ BOOL LLFastTimerView::handleHover(S32 x, S32 y, MASK mask) TimerBar* hover_bar = NULL; F32Seconds mouse_time_offset = ((F32)(x - mBarRect.mLeft) / (F32)mBarRect.getWidth()) * mTotalTimeDisplay; - for (int bar_index = 0, end_index = LLInstanceTracker::instanceCount(); + for (int bar_index = 0, end_index = LLTrace::BlockTimerStatHandle::instance_tracker_t::instanceCount(); bar_index < end_index; ++bar_index) { @@ -275,7 +275,7 @@ BOOL LLFastTimerView::handleHover(S32 x, S32 y, MASK mask) hover_bar = &bar; if (bar.mTimeBlock->getTreeNode().mCollapsed) { - // stop on first collapsed timeblock, since we can't select any children + // stop on first collapsed BlockTimerStatHandle, since we can't select any children break; } } @@ -300,7 +300,7 @@ BOOL LLFastTimerView::handleHover(S32 x, S32 y, MASK mask) } else if (x < mBarRect.mLeft) { - TimeBlock* timer_id = getLegendID(y); + BlockTimerStatHandle* timer_id = getLegendID(y); if (timer_id) { mHoverID = timer_id; @@ -311,7 +311,7 @@ BOOL LLFastTimerView::handleHover(S32 x, S32 y, MASK mask) } -static std::string get_tooltip(TimeBlock& timer, S32 history_index, PeriodicRecording& frame_recording) +static std::string get_tooltip(BlockTimerStatHandle& timer, S32 history_index, PeriodicRecording& frame_recording) { std::string tooltip; if (history_index == 0) @@ -351,7 +351,7 @@ BOOL LLFastTimerView::handleToolTip(S32 x, S32 y, MASK mask) // tooltips for timer legend if (x < mBarRect.mLeft) { - TimeBlock* idp = getLegendID(y); + BlockTimerStatHandle* idp = getLegendID(y); if (idp) { LLToolTipMgr::instance().show(get_tooltip(*idp, 0, mRecording)); @@ -373,7 +373,7 @@ BOOL LLFastTimerView::handleScrollWheel(S32 x, S32 y, S32 clicks) return TRUE; } -static TimeBlock FTM_RENDER_TIMER("Timers"); +static BlockTimerStatHandle FTM_RENDER_TIMER("Timers"); static const S32 MARGIN = 10; static const S32 LEGEND_WIDTH = 220; @@ -938,13 +938,13 @@ void LLFastTimerView::outputAllMetrics() //static void LLFastTimerView::doAnalysis(std::string baseline, std::string target, std::string output) { - if(TimeBlock::sLog) + if(BlockTimerStatHandle::sLog) { doAnalysisDefault(baseline, target, output) ; return ; } - if(TimeBlock::sMetricLog) + if(BlockTimerStatHandle::sMetricLog) { LLMetricPerformanceTesterBasic::doAnalysisMetrics(baseline, target, output) ; return ; @@ -966,7 +966,7 @@ void LLFastTimerView::printLineStats() it != end_timer_tree(); ++it) { - TimeBlock* idp = (*it); + BlockTimerStatHandle* idp = (*it); if (!first) { @@ -988,7 +988,7 @@ void LLFastTimerView::printLineStats() it != end_timer_tree(); ++it) { - TimeBlock* idp = (*it); + BlockTimerStatHandle* idp = (*it); if (!first) { @@ -1019,7 +1019,7 @@ void LLFastTimerView::printLineStats() } } -static LLTrace::TimeBlock FTM_DRAW_LINE_GRAPH("Draw line graph"); +static LLTrace::BlockTimerStatHandle FTM_DRAW_LINE_GRAPH("Draw line graph"); void LLFastTimerView::drawLineGraph() { @@ -1066,7 +1066,7 @@ void LLFastTimerView::drawLineGraph() it != end_timer_tree(); ++it) { - TimeBlock* idp = (*it); + BlockTimerStatHandle* idp = (*it); //fatten highlighted timer if (mHoverID == idp) @@ -1208,12 +1208,12 @@ void LLFastTimerView::drawLegend() LLLocalClipRect clip(mLegendRect); S32 cur_line = 0; ft_display_idx.clear(); - std::map display_line; + std::map display_line; for (timer_tree_iterator_t it = begin_timer_tree(FTM_FRAME); it != timer_tree_iterator_t(); ++it) { - TimeBlock* idp = (*it); + BlockTimerStatHandle* idp = (*it); display_line[idp] = cur_line; ft_display_idx.push_back(idp); cur_line++; @@ -1275,7 +1275,7 @@ void LLFastTimerView::drawLegend() x += dx; BOOL is_child_of_hover_item = (idp == mHoverID); - TimeBlock* next_parent = idp->getParent(); + BlockTimerStatHandle* next_parent = idp->getParent(); while(!is_child_of_hover_item && next_parent) { is_child_of_hover_item = (mHoverID == next_parent); @@ -1303,7 +1303,7 @@ void LLFastTimerView::generateUniqueColors() { // generate unique colors { - sTimerColors.resize(LLTrace::TimeBlock::getNumIndices()); + sTimerColors.resize(LLTrace::BlockTimerStatHandle::getNumIndices()); sTimerColors[FTM_FRAME.getIndex()] = LLColor4::grey; F32 hue = 0.f; @@ -1312,7 +1312,7 @@ void LLFastTimerView::generateUniqueColors() it != timer_tree_iterator_t(); ++it) { - TimeBlock* idp = (*it); + BlockTimerStatHandle* idp = (*it); const F32 HUE_INCREMENT = 0.23f; hue = fmodf(hue + HUE_INCREMENT, 1.f); @@ -1462,7 +1462,7 @@ void LLFastTimerView::drawBars() U32 bar_index = 0; if (!mAverageTimerRow.mBars) { - mAverageTimerRow.mBars = new TimerBar[LLInstanceTracker::instanceCount()]; + mAverageTimerRow.mBars = new TimerBar[LLTrace::BlockTimerStatHandle::instance_tracker_t::instanceCount()]; } updateTimerBarWidths(&FTM_FRAME, mAverageTimerRow, -1, bar_index); updateTimerBarOffsets(&FTM_FRAME, mAverageTimerRow); @@ -1474,7 +1474,7 @@ void LLFastTimerView::drawBars() bar_index = 0; if (!row.mBars) { - row.mBars = new TimerBar[LLInstanceTracker::instanceCount()]; + row.mBars = new TimerBar[LLTrace::BlockTimerStatHandle::instance_tracker_t::instanceCount()]; updateTimerBarWidths(&FTM_FRAME, row, history_index, bar_index); updateTimerBarOffsets(&FTM_FRAME, row); } @@ -1509,9 +1509,9 @@ void LLFastTimerView::drawBars() gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); } -static LLTrace::TimeBlock FTM_UPDATE_TIMER_BAR_WIDTHS("Update timer bar widths"); +static LLTrace::BlockTimerStatHandle FTM_UPDATE_TIMER_BAR_WIDTHS("Update timer bar widths"); -F32Seconds LLFastTimerView::updateTimerBarWidths(LLTrace::TimeBlock* time_block, TimerBarRow& row, S32 history_index, U32& bar_index) +F32Seconds LLFastTimerView::updateTimerBarWidths(LLTrace::BlockTimerStatHandle* time_block, TimerBarRow& row, S32 history_index, U32& bar_index) { LL_RECORD_BLOCK_TIME(FTM_UPDATE_TIMER_BAR_WIDTHS); const F32Seconds self_time = history_index == -1 @@ -1525,7 +1525,7 @@ F32Seconds LLFastTimerView::updateTimerBarWidths(LLTrace::TimeBlock* time_block, TimerBar& timer_bar = row.mBars[bar_index]; bar_index++; - for (TimeBlock::child_iter it = time_block->beginChildren(), end_it = time_block->endChildren(); it != end_it; ++it) + for (BlockTimerStatHandle::child_iter it = time_block->beginChildren(), end_it = time_block->endChildren(); it != end_it; ++it) { full_time += updateTimerBarWidths(*it, row, history_index, bar_index); } @@ -1537,9 +1537,9 @@ F32Seconds LLFastTimerView::updateTimerBarWidths(LLTrace::TimeBlock* time_block, return full_time; } -static LLTrace::TimeBlock FTM_UPDATE_TIMER_BAR_FRACTIONS("Update timer bar fractions"); +static LLTrace::BlockTimerStatHandle FTM_UPDATE_TIMER_BAR_FRACTIONS("Update timer bar fractions"); -S32 LLFastTimerView::updateTimerBarOffsets(LLTrace::TimeBlock* time_block, TimerBarRow& row, S32 timer_bar_index) +S32 LLFastTimerView::updateTimerBarOffsets(LLTrace::BlockTimerStatHandle* time_block, TimerBarRow& row, S32 timer_bar_index) { LL_RECORD_BLOCK_TIME(FTM_UPDATE_TIMER_BAR_FRACTIONS); @@ -1560,14 +1560,14 @@ S32 LLFastTimerView::updateTimerBarOffsets(LLTrace::TimeBlock* time_block, Timer TimerBar* last_child_timer_bar = NULL; bool first_child = true; - for (TimeBlock::child_iter it = time_block->beginChildren(), end_it = time_block->endChildren(); + for (BlockTimerStatHandle::child_iter it = time_block->beginChildren(), end_it = time_block->endChildren(); it != end_it; ++it) { timer_bar_index++; TimerBar& child_timer_bar = row.mBars[timer_bar_index]; - TimeBlock* child_time_block = *it; + BlockTimerStatHandle* child_time_block = *it; if (last_child_timer_bar) { @@ -1603,7 +1603,7 @@ S32 LLFastTimerView::updateTimerBarOffsets(LLTrace::TimeBlock* time_block, Timer S32 LLFastTimerView::drawBar(LLRect bar_rect, TimerBarRow& row, S32 image_width, S32 image_height, bool hovered, bool visible, S32 bar_index) { TimerBar& timer_bar = row.mBars[bar_index]; - LLTrace::TimeBlock* time_block = timer_bar.mTimeBlock; + LLTrace::BlockTimerStatHandle* time_block = timer_bar.mTimeBlock; hovered |= mHoverID == time_block; @@ -1648,7 +1648,7 @@ S32 LLFastTimerView::drawBar(LLRect bar_rect, TimerBarRow& row, S32 image_width, bool children_visible = visible && !time_block->getTreeNode().mCollapsed; bar_index++; - const U32 num_bars = LLInstanceTracker::instanceCount(); + const U32 num_bars = LLTrace::BlockTimerStatHandle::instance_tracker_t::instanceCount(); if (bar_index < num_bars && row.mBars[bar_index].mFirstChild) { bool is_last = false; -- cgit v1.2.3 From 1c26d4265666cd232d38724ad6f1e32fd2dc2d34 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Wed, 16 Oct 2013 16:42:27 -0700 Subject: moved tree iterators into llfasttimer.h --- indra/newview/llfasttimerview.cpp | 38 ++++++++++++-------------------------- 1 file changed, 12 insertions(+), 26 deletions(-) (limited to 'indra/newview/llfasttimerview.cpp') diff --git a/indra/newview/llfasttimerview.cpp b/indra/newview/llfasttimerview.cpp index 6153c43690..302cecb5b6 100755 --- a/indra/newview/llfasttimerview.cpp +++ b/indra/newview/llfasttimerview.cpp @@ -66,22 +66,8 @@ static const S32 NUM_FRAMES_HISTORY = 200; std::vector ft_display_idx; // line of table entry for display purposes (for collapse) -typedef LLTreeDFSIter timer_tree_iterator_t; - BOOL LLFastTimerView::sAnalyzePerformance = FALSE; -static timer_tree_iterator_t begin_timer_tree(BlockTimerStatHandle& id) -{ - return timer_tree_iterator_t(&id, - boost::bind(boost::mem_fn(&BlockTimerStatHandle::beginChildren), _1), - boost::bind(boost::mem_fn(&BlockTimerStatHandle::endChildren), _1)); -} - -static timer_tree_iterator_t end_timer_tree() -{ - return timer_tree_iterator_t(); -} - S32 get_depth(const BlockTimerStatHandle* blockp) { S32 depth = 0; @@ -186,8 +172,8 @@ BlockTimerStatHandle* LLFastTimerView::getLegendID(S32 y) BOOL LLFastTimerView::handleDoubleClick(S32 x, S32 y, MASK mask) { - for(timer_tree_iterator_t it = begin_timer_tree(FTM_FRAME); - it != end_timer_tree(); + for(LLTrace::block_timer_tree_df_iterator_t it = LLTrace::begin_block_timer_tree_df(FTM_FRAME); + it != LLTrace::end_block_timer_tree_df(); ++it) { (*it)->getTreeNode().mCollapsed = false; @@ -962,8 +948,8 @@ void LLFastTimerView::printLineStats() { std::string legend_stat; bool first = true; - for(timer_tree_iterator_t it = begin_timer_tree(FTM_FRAME); - it != end_timer_tree(); + for(block_timer_tree_df_iterator_t it = LLTrace::begin_block_timer_tree_df(FTM_FRAME); + it != LLTrace::end_block_timer_tree_df(); ++it) { BlockTimerStatHandle* idp = (*it); @@ -984,8 +970,8 @@ void LLFastTimerView::printLineStats() std::string timer_stat; first = true; - for(timer_tree_iterator_t it = begin_timer_tree(FTM_FRAME); - it != end_timer_tree(); + for(block_timer_tree_df_iterator_t it = LLTrace::begin_block_timer_tree_df(FTM_FRAME); + it != LLTrace::end_block_timer_tree_df(); ++it) { BlockTimerStatHandle* idp = (*it); @@ -1062,8 +1048,8 @@ void LLFastTimerView::drawLineGraph() F32Seconds cur_max(0); U32 cur_max_calls = 0; - for(timer_tree_iterator_t it = begin_timer_tree(FTM_FRAME); - it != end_timer_tree(); + for(block_timer_tree_df_iterator_t it = LLTrace::begin_block_timer_tree_df(FTM_FRAME); + it != LLTrace::end_block_timer_tree_df(); ++it) { BlockTimerStatHandle* idp = (*it); @@ -1209,8 +1195,8 @@ void LLFastTimerView::drawLegend() S32 cur_line = 0; ft_display_idx.clear(); std::map display_line; - for (timer_tree_iterator_t it = begin_timer_tree(FTM_FRAME); - it != timer_tree_iterator_t(); + for (block_timer_tree_df_iterator_t it = LLTrace::begin_block_timer_tree_df(FTM_FRAME); + it != block_timer_tree_df_iterator_t(); ++it) { BlockTimerStatHandle* idp = (*it); @@ -1308,8 +1294,8 @@ void LLFastTimerView::generateUniqueColors() F32 hue = 0.f; - for (timer_tree_iterator_t it = begin_timer_tree(FTM_FRAME); - it != timer_tree_iterator_t(); + for (block_timer_tree_df_iterator_t it = LLTrace::begin_block_timer_tree_df(FTM_FRAME); + it != block_timer_tree_df_iterator_t(); ++it) { BlockTimerStatHandle* idp = (*it); -- cgit v1.2.3 From ab43be5ddb50198304de1ae0e82b641c7d343449 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Wed, 23 Oct 2013 13:24:47 -0700 Subject: moved some common functionality from LLTrace::BlockTimerStatHandle to BlockTimer updates appearance utility dependency --- indra/newview/llfasttimerview.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'indra/newview/llfasttimerview.cpp') diff --git a/indra/newview/llfasttimerview.cpp b/indra/newview/llfasttimerview.cpp index 302cecb5b6..bd92b4b6ca 100755 --- a/indra/newview/llfasttimerview.cpp +++ b/indra/newview/llfasttimerview.cpp @@ -924,13 +924,13 @@ void LLFastTimerView::outputAllMetrics() //static void LLFastTimerView::doAnalysis(std::string baseline, std::string target, std::string output) { - if(BlockTimerStatHandle::sLog) + if(BlockTimer::sLog) { doAnalysisDefault(baseline, target, output) ; return ; } - if(BlockTimerStatHandle::sMetricLog) + if(BlockTimer::sMetricLog) { LLMetricPerformanceTesterBasic::doAnalysisMetrics(baseline, target, output) ; return ; -- cgit v1.2.3 From 237627181dbd9c7712ddaa8da6cdf1a8828d1279 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Tue, 29 Oct 2013 19:05:28 -0700 Subject: always dump entire fast timer log on right click...not just visible timers --- indra/newview/llfasttimerview.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'indra/newview/llfasttimerview.cpp') diff --git a/indra/newview/llfasttimerview.cpp b/indra/newview/llfasttimerview.cpp index bd92b4b6ca..768f7c1a03 100755 --- a/indra/newview/llfasttimerview.cpp +++ b/indra/newview/llfasttimerview.cpp @@ -961,10 +961,10 @@ void LLFastTimerView::printLineStats() first = false; legend_stat += idp->getName(); - if (idp->getTreeNode().mCollapsed) - { - it.skipDescendants(); - } + //if (idp->getTreeNode().mCollapsed) + //{ + // it.skipDescendants(); + //} } LL_INFOS() << legend_stat << LL_ENDL; @@ -995,10 +995,10 @@ void LLFastTimerView::printLineStats() timer_stat += llformat("%.1f",ms.value()); - if (idp->getTreeNode().mCollapsed) - { - it.skipDescendants(); - } + //if (idp->getTreeNode().mCollapsed) + //{ + // it.skipDescendants(); + //} } LL_INFOS() << timer_stat << LL_ENDL; mStatsIndex = -1; -- cgit v1.2.3 From 6ddfc8031c73f342cf8459445a20cd50ceb3efba Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Tue, 12 Nov 2013 11:42:06 -0800 Subject: BUILDFIX - miscellaneous stuff missed in the merge --- indra/newview/llfasttimerview.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'indra/newview/llfasttimerview.cpp') diff --git a/indra/newview/llfasttimerview.cpp b/indra/newview/llfasttimerview.cpp index bc07519506..76c37439ab 100755 --- a/indra/newview/llfasttimerview.cpp +++ b/indra/newview/llfasttimerview.cpp @@ -413,7 +413,7 @@ void LLFastTimerView::draw() mAllTimeMax = llmax(mAllTimeMax, mRecording.getLastRecording().getSum(FTM_FRAME)); mHoverID = NULL; mHoverBarIndex = -1; - } +} void LLFastTimerView::onOpen(const LLSD& key) { @@ -429,6 +429,10 @@ void LLFastTimerView::onOpen(const LLSD& key) } } +void LLFastTimerView::onClose(bool app_quitting) +{ + setVisible(FALSE); +} void saveChart(const std::string& label, const char* suffix, LLImageRaw* scratch) { @@ -936,10 +940,7 @@ void LLFastTimerView::doAnalysis(std::string baseline, std::string target, std:: return ; } } -void LLFastTimerView::onClickCloseBtn(bool) -{ - setVisible(false); -} + void LLFastTimerView::printLineStats() { -- cgit v1.2.3