From b3e9c46c94dad0c81a5adcb9152521b5368c66a7 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Wed, 29 Aug 2012 22:50:56 -0700 Subject: SH-3275 WIP Run viewer metrics for object update messages further cleanup of LLStat removed llfloaterlagmeter --- indra/llui/llstatbar.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/llui/llstatbar.cpp') diff --git a/indra/llui/llstatbar.cpp b/indra/llui/llstatbar.cpp index 04cce7878e..a21d7aa6a1 100644 --- a/indra/llui/llstatbar.cpp +++ b/indra/llui/llstatbar.cpp @@ -45,7 +45,7 @@ LLStatBar::LLStatBar(const Params& p) mUnitLabel(p.unit_label), mMinBar(p.bar_min), mMaxBar(p.bar_max), - mStatp(LLStat::getStat(p.stat)), + mStatp(LLStat::getInstance(p.stat)), mTickSpacing(p.tick_spacing), mLabelSpacing(p.label_spacing), mPrecision(p.precision), -- cgit v1.2.3 From b1baf982b1bd41a150233d0a28d3601226924c65 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Sun, 30 Sep 2012 10:41:29 -0700 Subject: SH-3275 WIP Run viewer metrics for object update messages factored out lltrace::sampler into separate file added rudimentary lltrace support to llstatgraph made llstatgraph use param blocks more effectively moves initial set of stats over to lltrace removed windows.h #defines for min and max --- indra/llui/llstatbar.cpp | 79 ++++++++++++++++++++++++++++++++++++------------ 1 file changed, 59 insertions(+), 20 deletions(-) (limited to 'indra/llui/llstatbar.cpp') diff --git a/indra/llui/llstatbar.cpp b/indra/llui/llstatbar.cpp index a21d7aa6a1..2d1b582598 100644 --- a/indra/llui/llstatbar.cpp +++ b/indra/llui/llstatbar.cpp @@ -36,6 +36,7 @@ #include "llstat.h" #include "lluictrlfactory.h" +#include "lltracesampler.h" /////////////////////////////////////////////////////////////////////////////////// @@ -46,6 +47,8 @@ LLStatBar::LLStatBar(const Params& p) mMinBar(p.bar_min), mMaxBar(p.bar_max), mStatp(LLStat::getInstance(p.stat)), + mFloatStatp(LLTrace::Stat::getInstance(p.stat)), + mIntStatp(LLTrace::Stat::getInstance(p.stat)), mTickSpacing(p.tick_spacing), mLabelSpacing(p.label_spacing), mPrecision(p.precision), @@ -84,30 +87,66 @@ BOOL LLStatBar::handleMouseDown(S32 x, S32 y, MASK mask) void LLStatBar::draw() { - if (!mStatp) + F32 current = 0.f, + min = 0.f, + max = 0.f, + mean = 0.f; + + if (mStatp) { -// llinfos << "No stats for statistics bar!" << llendl; - return; + // Get the values. + if (mPerSec) + { + current = mStatp->getCurrentPerSec(); + min = mStatp->getMinPerSec(); + max = mStatp->getMaxPerSec(); + mean = mStatp->getMeanPerSec(); + } + else + { + current = mStatp->getCurrent(); + min = mStatp->getMin(); + max = mStatp->getMax(); + mean = mStatp->getMean(); + } } - - // Get the values. - F32 current, min, max, mean; - if (mPerSec) + else if (mFloatStatp) { - current = mStatp->getCurrentPerSec(); - min = mStatp->getMinPerSec(); - max = mStatp->getMaxPerSec(); - mean = mStatp->getMeanPerSec(); + LLTrace::Sampler* sampler = LLThread::getTraceData()->getPrimarySampler(); + if (mPerSec) + { + current = sampler->getSum(*mFloatStatp) / sampler->getSampleTime(); + min = sampler->getMin(*mFloatStatp) / sampler->getSampleTime(); + max = sampler->getMax(*mFloatStatp) / sampler->getSampleTime(); + mean = sampler->getMean(*mFloatStatp) / sampler->getSampleTime(); + } + else + { + current = sampler->getSum(*mFloatStatp); + min = sampler->getMin(*mFloatStatp); + max = sampler->getMax(*mFloatStatp); + mean = sampler->getMean(*mFloatStatp); + } } - else + else if (mIntStatp) { - current = mStatp->getCurrent(); - min = mStatp->getMin(); - max = mStatp->getMax(); - mean = mStatp->getMean(); + LLTrace::Sampler* sampler = LLThread::getTraceData()->getPrimarySampler(); + if (mPerSec) + { + current = (F32)sampler->getSum(*mIntStatp) / sampler->getSampleTime(); + min = (F32)sampler->getMin(*mIntStatp) / sampler->getSampleTime(); + max = (F32)sampler->getMax(*mIntStatp) / sampler->getSampleTime(); + mean = (F32)sampler->getMean(*mIntStatp) / sampler->getSampleTime(); + } + else + { + current = (F32)sampler->getSum(*mIntStatp); + min = (F32)sampler->getMin(*mIntStatp); + max = (F32)sampler->getMax(*mIntStatp); + mean = (F32)sampler->getMean(*mIntStatp); + } } - if ((mUpdatesPerSec == 0.f) || (mUpdateTimer.getElapsedTimeF32() > 1.f/mUpdatesPerSec) || (mValue == 0.f)) { if (mDisplayMean) @@ -153,7 +192,7 @@ void LLStatBar::draw() LLFontGL::RIGHT, LLFontGL::TOP); value_format = llformat( "%%.%df", mPrecision); - if (mDisplayBar) + if (mDisplayBar && mStatp) { std::string tick_label; @@ -213,9 +252,9 @@ void LLStatBar::draw() right = (S32) ((max - mMinBar) * value_scale); gl_rect_2d(left, top, right, bottom, LLColor4(1.f, 0.f, 0.f, 0.25f)); - S32 num_values = mStatp->getNumValues() - 1; if (mDisplayHistory) { + S32 num_values = mStatp->getNumValues() - 1; S32 i; for (i = 0; i < num_values; i++) { @@ -270,7 +309,7 @@ LLRect LLStatBar::getRequiredRect() if (mDisplayBar) { - if (mDisplayHistory) + if (mDisplayHistory && mStatp) { rect.mTop = 35 + mStatp->getNumBins(); } -- cgit v1.2.3 From 14b1b0b2bb6bac5bc688cc4d14c33f1b680dd3b4 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Mon, 1 Oct 2012 19:39:04 -0700 Subject: SH-3275 WIP Run viewer metrics for object update messages cleaned up API samplers are now value types with copy-on-write buffers under the hood removed coupling with LLThread --- indra/llui/llstatbar.cpp | 36 +++++++++--------------------------- 1 file changed, 9 insertions(+), 27 deletions(-) (limited to 'indra/llui/llstatbar.cpp') diff --git a/indra/llui/llstatbar.cpp b/indra/llui/llstatbar.cpp index 2d1b582598..1f8be3da62 100644 --- a/indra/llui/llstatbar.cpp +++ b/indra/llui/llstatbar.cpp @@ -47,8 +47,7 @@ LLStatBar::LLStatBar(const Params& p) mMinBar(p.bar_min), mMaxBar(p.bar_max), mStatp(LLStat::getInstance(p.stat)), - mFloatStatp(LLTrace::Stat::getInstance(p.stat)), - mIntStatp(LLTrace::Stat::getInstance(p.stat)), + mFloatStatp(LLTrace::Rate::getInstance(p.stat)), mTickSpacing(p.tick_spacing), mLabelSpacing(p.label_spacing), mPrecision(p.precision), @@ -112,40 +111,23 @@ void LLStatBar::draw() } else if (mFloatStatp) { - LLTrace::Sampler* sampler = LLThread::getTraceData()->getPrimarySampler(); + LLTrace::Sampler* sampler = LLTrace::get_thread_trace()->getPrimarySampler(); if (mPerSec) { current = sampler->getSum(*mFloatStatp) / sampler->getSampleTime(); - min = sampler->getMin(*mFloatStatp) / sampler->getSampleTime(); - max = sampler->getMax(*mFloatStatp) / sampler->getSampleTime(); - mean = sampler->getMean(*mFloatStatp) / sampler->getSampleTime(); + //min = sampler->getMin(*mFloatStatp) / sampler->getSampleTime(); + //max = sampler->getMax(*mFloatStatp) / sampler->getSampleTime(); + //mean = sampler->getMean(*mFloatStatp) / sampler->getSampleTime(); } else { current = sampler->getSum(*mFloatStatp); - min = sampler->getMin(*mFloatStatp); - max = sampler->getMax(*mFloatStatp); - mean = sampler->getMean(*mFloatStatp); - } - } - else if (mIntStatp) - { - LLTrace::Sampler* sampler = LLThread::getTraceData()->getPrimarySampler(); - if (mPerSec) - { - current = (F32)sampler->getSum(*mIntStatp) / sampler->getSampleTime(); - min = (F32)sampler->getMin(*mIntStatp) / sampler->getSampleTime(); - max = (F32)sampler->getMax(*mIntStatp) / sampler->getSampleTime(); - mean = (F32)sampler->getMean(*mIntStatp) / sampler->getSampleTime(); - } - else - { - current = (F32)sampler->getSum(*mIntStatp); - min = (F32)sampler->getMin(*mIntStatp); - max = (F32)sampler->getMax(*mIntStatp); - mean = (F32)sampler->getMean(*mIntStatp); + //min = sampler->getMin(*mFloatStatp); + //max = sampler->getMax(*mFloatStatp); + //mean = sampler->getMean(*mFloatStatp); } } + if ((mUpdatesPerSec == 0.f) || (mUpdateTimer.getElapsedTimeF32() > 1.f/mUpdatesPerSec) || (mValue == 0.f)) { -- cgit v1.2.3 From dbe9742703cf14db85ec3d16c540efc68dce95a6 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Tue, 2 Oct 2012 15:37:16 -0700 Subject: SH-3404 create sampler class renamed LLTrace::ThreadTrace to LLTrace::ThreadRecorder renamed LLTrace::Sampler to LLTrace::Recording --- indra/llui/llstatbar.cpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'indra/llui/llstatbar.cpp') diff --git a/indra/llui/llstatbar.cpp b/indra/llui/llstatbar.cpp index 1f8be3da62..bc9603804b 100644 --- a/indra/llui/llstatbar.cpp +++ b/indra/llui/llstatbar.cpp @@ -36,7 +36,7 @@ #include "llstat.h" #include "lluictrlfactory.h" -#include "lltracesampler.h" +#include "lltracerecording.h" /////////////////////////////////////////////////////////////////////////////////// @@ -111,20 +111,20 @@ void LLStatBar::draw() } else if (mFloatStatp) { - LLTrace::Sampler* sampler = LLTrace::get_thread_trace()->getPrimarySampler(); + LLTrace::Recording* recording = LLTrace::get_thread_recorder()->getPrimaryRecording(); if (mPerSec) { - current = sampler->getSum(*mFloatStatp) / sampler->getSampleTime(); - //min = sampler->getMin(*mFloatStatp) / sampler->getSampleTime(); - //max = sampler->getMax(*mFloatStatp) / sampler->getSampleTime(); - //mean = sampler->getMean(*mFloatStatp) / sampler->getSampleTime(); + current = recording->getSum(*mFloatStatp) / recording->getSampleTime(); + //min = recording->getMin(*mFloatStatp) / recording->getSampleTime(); + //max = recording->getMax(*mFloatStatp) / recording->getSampleTime(); + //mean = recording->getMean(*mFloatStatp) / recording->getSampleTime(); } else { - current = sampler->getSum(*mFloatStatp); - //min = sampler->getMin(*mFloatStatp); - //max = sampler->getMax(*mFloatStatp); - //mean = sampler->getMean(*mFloatStatp); + current = recording->getSum(*mFloatStatp); + //min = recording->getMin(*mFloatStatp); + //max = recording->getMax(*mFloatStatp); + //mean = recording->getMean(*mFloatStatp); } } -- cgit v1.2.3 From 74ac0182ec8f7a0f6d0ea89f5814f0998ab90b62 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Wed, 10 Oct 2012 19:25:56 -0700 Subject: SH-3405 WIP convert existing stats to lltrace system fixed units conversion so that trace getters return convertable units removed circular dependencies from lltrace* converted more stats to lltrace --- indra/llui/llstatbar.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'indra/llui/llstatbar.cpp') diff --git a/indra/llui/llstatbar.cpp b/indra/llui/llstatbar.cpp index bc9603804b..4cbf695059 100644 --- a/indra/llui/llstatbar.cpp +++ b/indra/llui/llstatbar.cpp @@ -37,6 +37,7 @@ #include "llstat.h" #include "lluictrlfactory.h" #include "lltracerecording.h" +#include "lltracethreadrecorder.h" /////////////////////////////////////////////////////////////////////////////////// -- cgit v1.2.3 From 0f58ca02cdec62711eadb82ba28fcff08faef2ee Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Fri, 12 Oct 2012 00:20:19 -0700 Subject: SH-3275 WIP Update viewer metrics system to be more flexible cleaned up accumulator merging logic introduced frame recording to LLTrace directly instead of going through LLViewerStats moved consumer code over to frame recording instead of whatever the current active recording was --- indra/llui/llstatbar.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'indra/llui/llstatbar.cpp') diff --git a/indra/llui/llstatbar.cpp b/indra/llui/llstatbar.cpp index 4cbf695059..b73007e107 100644 --- a/indra/llui/llstatbar.cpp +++ b/indra/llui/llstatbar.cpp @@ -37,7 +37,6 @@ #include "llstat.h" #include "lluictrlfactory.h" #include "lltracerecording.h" -#include "lltracethreadrecorder.h" /////////////////////////////////////////////////////////////////////////////////// @@ -112,17 +111,17 @@ void LLStatBar::draw() } else if (mFloatStatp) { - LLTrace::Recording* recording = LLTrace::get_thread_recorder()->getPrimaryRecording(); + LLTrace::Recording& recording = LLTrace::get_frame_recording().getLastRecordingPeriod(); if (mPerSec) { - current = recording->getSum(*mFloatStatp) / recording->getSampleTime(); + current = recording.getPerSec(*mFloatStatp); //min = recording->getMin(*mFloatStatp) / recording->getSampleTime(); //max = recording->getMax(*mFloatStatp) / recording->getSampleTime(); //mean = recording->getMean(*mFloatStatp) / recording->getSampleTime(); } else { - current = recording->getSum(*mFloatStatp); + current = recording.getSum(*mFloatStatp); //min = recording->getMin(*mFloatStatp); //max = recording->getMax(*mFloatStatp); //mean = recording->getMean(*mFloatStatp); -- cgit v1.2.3 From 041dfccd1ea5b59c1b3c4e37e9a5495cad342c8f Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Fri, 12 Oct 2012 20:17:52 -0700 Subject: SH-3405 WIP convert existing stats to lltrace system default to double precision now fixed unit conversion logic for LLUnit renamed LLTrace::Rate to LLTrace::Count and got rid of the old count as it was confusing some const correctness changes --- indra/llui/llstatbar.cpp | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) (limited to 'indra/llui/llstatbar.cpp') diff --git a/indra/llui/llstatbar.cpp b/indra/llui/llstatbar.cpp index b73007e107..c60e5431ae 100644 --- a/indra/llui/llstatbar.cpp +++ b/indra/llui/llstatbar.cpp @@ -47,7 +47,7 @@ LLStatBar::LLStatBar(const Params& p) mMinBar(p.bar_min), mMaxBar(p.bar_max), mStatp(LLStat::getInstance(p.stat)), - mFloatStatp(LLTrace::Rate::getInstance(p.stat)), + mNewStatp(LLTrace::Count<>::getInstance(p.stat)), mTickSpacing(p.tick_spacing), mLabelSpacing(p.label_spacing), mPrecision(p.precision), @@ -109,22 +109,25 @@ void LLStatBar::draw() mean = mStatp->getMean(); } } - else if (mFloatStatp) + else if (mNewStatp) { - LLTrace::Recording& recording = LLTrace::get_frame_recording().getLastRecordingPeriod(); + LLTrace::PeriodicRecording& frame_recording = LLTrace::get_frame_recording(); + LLTrace::Recording& last_frame_recording = frame_recording.getLastRecordingPeriod(); + LLTrace::Recording& windowed_frame_recording = frame_recording.getTotalRecording(); + if (mPerSec) { - current = recording.getPerSec(*mFloatStatp); - //min = recording->getMin(*mFloatStatp) / recording->getSampleTime(); - //max = recording->getMax(*mFloatStatp) / recording->getSampleTime(); - //mean = recording->getMean(*mFloatStatp) / recording->getSampleTime(); + current = last_frame_recording.getPerSec(*mNewStatp); + //min = frame_window_recording.getMin(*mNewStatp) / frame_window_recording.getDuration(); + //max = frame_window_recording.getMax(*mNewStatp) / frame_window_recording.getDuration(); + mean = windowed_frame_recording.getPerSec(*mNewStatp);//frame_window_recording.getMean(*mNewStatp) / frame_window_recording.getDuration(); } else { - current = recording.getSum(*mFloatStatp); - //min = recording->getMin(*mFloatStatp); - //max = recording->getMax(*mFloatStatp); - //mean = recording->getMean(*mFloatStatp); + current = last_frame_recording.getSum(*mNewStatp); + //min = last_frame_recording.getMin(*mNewStatp); + //max = last_frame_recording.getMax(*mNewStatp); + mean = windowed_frame_recording.getSum(*mNewStatp); } } -- cgit v1.2.3 From a52d203a4f1d2988e8ffba16258f3f132f22f56d Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Wed, 17 Oct 2012 20:00:07 -0700 Subject: SH-3405 WIP convert existing stats to lltrace system started conversion of llviewerassetstats removed old, dead LLViewerStats code made units tracing require units declaration clean up of units handling --- indra/llui/llstatbar.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'indra/llui/llstatbar.cpp') diff --git a/indra/llui/llstatbar.cpp b/indra/llui/llstatbar.cpp index c60e5431ae..535c6f96e3 100644 --- a/indra/llui/llstatbar.cpp +++ b/indra/llui/llstatbar.cpp @@ -56,8 +56,7 @@ LLStatBar::LLStatBar(const Params& p) mDisplayBar(p.show_bar), mDisplayHistory(p.show_history), mDisplayMean(p.show_mean) -{ -} +{} BOOL LLStatBar::handleMouseDown(S32 x, S32 y, MASK mask) { -- cgit v1.2.3 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/llui/llstatbar.cpp | 138 +++++++++++++++++++++++++++++++++-------------- 1 file changed, 98 insertions(+), 40 deletions(-) (limited to 'indra/llui/llstatbar.cpp') diff --git a/indra/llui/llstatbar.cpp b/indra/llui/llstatbar.cpp index 535c6f96e3..6b40f8d475 100644 --- a/indra/llui/llstatbar.cpp +++ b/indra/llui/llstatbar.cpp @@ -34,7 +34,6 @@ #include "llgl.h" #include "llfontgl.h" -#include "llstat.h" #include "lluictrlfactory.h" #include "lltracerecording.h" @@ -46,8 +45,10 @@ LLStatBar::LLStatBar(const Params& p) mUnitLabel(p.unit_label), mMinBar(p.bar_min), mMaxBar(p.bar_max), - mStatp(LLStat::getInstance(p.stat)), - mNewStatp(LLTrace::Count<>::getInstance(p.stat)), + mCountFloatp(LLTrace::Count<>::getInstance(p.stat)), + mCountIntp(LLTrace::Count::getInstance(p.stat)), + mMeasurementFloatp(LLTrace::Measurement<>::getInstance(p.stat)), + mMeasurementIntp(LLTrace::Measurement::getInstance(p.stat)), mTickSpacing(p.tick_spacing), mLabelSpacing(p.label_spacing), mPrecision(p.precision), @@ -90,46 +91,62 @@ void LLStatBar::draw() max = 0.f, mean = 0.f; - if (mStatp) + LLTrace::PeriodicRecording& frame_recording = LLTrace::get_frame_recording(); + + if (mCountFloatp) { - // Get the values. + LLTrace::Recording& last_frame_recording = frame_recording.getLastRecordingPeriod(); + if (mPerSec) { - current = mStatp->getCurrentPerSec(); - min = mStatp->getMinPerSec(); - max = mStatp->getMaxPerSec(); - mean = mStatp->getMeanPerSec(); + current = last_frame_recording.getPerSec(*mCountFloatp); + min = frame_recording.getPeriodMinPerSec(*mCountFloatp); + max = frame_recording.getPeriodMaxPerSec(*mCountFloatp); + mean = frame_recording.getPeriodMeanPerSec(*mCountFloatp); } else { - current = mStatp->getCurrent(); - min = mStatp->getMin(); - max = mStatp->getMax(); - mean = mStatp->getMean(); + current = last_frame_recording.getSum(*mCountFloatp); + min = frame_recording.getPeriodMin(*mCountFloatp); + max = frame_recording.getPeriodMax(*mCountFloatp); + mean = frame_recording.getPeriodMean(*mCountFloatp); } } - else if (mNewStatp) + else if (mCountIntp) { - LLTrace::PeriodicRecording& frame_recording = LLTrace::get_frame_recording(); LLTrace::Recording& last_frame_recording = frame_recording.getLastRecordingPeriod(); - LLTrace::Recording& windowed_frame_recording = frame_recording.getTotalRecording(); if (mPerSec) { - current = last_frame_recording.getPerSec(*mNewStatp); - //min = frame_window_recording.getMin(*mNewStatp) / frame_window_recording.getDuration(); - //max = frame_window_recording.getMax(*mNewStatp) / frame_window_recording.getDuration(); - mean = windowed_frame_recording.getPerSec(*mNewStatp);//frame_window_recording.getMean(*mNewStatp) / frame_window_recording.getDuration(); + current = last_frame_recording.getPerSec(*mCountIntp); + min = frame_recording.getPeriodMinPerSec(*mCountIntp); + max = frame_recording.getPeriodMaxPerSec(*mCountIntp); + mean = frame_recording.getPeriodMeanPerSec(*mCountIntp); } else { - current = last_frame_recording.getSum(*mNewStatp); - //min = last_frame_recording.getMin(*mNewStatp); - //max = last_frame_recording.getMax(*mNewStatp); - mean = windowed_frame_recording.getSum(*mNewStatp); + current = last_frame_recording.getSum(*mCountIntp); + min = frame_recording.getPeriodMin(*mCountIntp); + max = frame_recording.getPeriodMax(*mCountIntp); + mean = frame_recording.getPeriodMean(*mCountIntp); } } - + else if (mMeasurementFloatp) + { + LLTrace::Recording& recording = frame_recording.getTotalRecording(); + current = recording.getLastValue(*mMeasurementFloatp); + min = recording.getMin(*mMeasurementFloatp); + max = recording.getMax(*mMeasurementFloatp); + mean = recording.getMean(*mMeasurementFloatp); + } + else if (mMeasurementIntp) + { + LLTrace::Recording& recording = frame_recording.getTotalRecording(); + current = recording.getLastValue(*mMeasurementIntp); + min = recording.getMin(*mMeasurementIntp); + max = recording.getMax(*mMeasurementIntp); + mean = recording.getMean(*mMeasurementIntp); + } if ((mUpdatesPerSec == 0.f) || (mUpdateTimer.getElapsedTimeF32() > 1.f/mUpdatesPerSec) || (mValue == 0.f)) { @@ -176,7 +193,7 @@ void LLStatBar::draw() LLFontGL::RIGHT, LLFontGL::TOP); value_format = llformat( "%%.%df", mPrecision); - if (mDisplayBar && mStatp) + if (mDisplayBar && (mCountFloatp || mCountIntp || mMeasurementFloatp || mMeasurementIntp)) { std::string tick_label; @@ -219,7 +236,7 @@ void LLStatBar::draw() right = width; gl_rect_2d(left, top, right, bottom, LLColor4(0.f, 0.f, 0.f, 0.25f)); - if (mStatp->getNumValues() == 0) + if (frame_recording.getNumPeriods() == 0) { // No data, don't draw anything... return; @@ -236,26 +253,58 @@ void LLStatBar::draw() right = (S32) ((max - mMinBar) * value_scale); gl_rect_2d(left, top, right, bottom, LLColor4(1.f, 0.f, 0.f, 0.25f)); - if (mDisplayHistory) + if (mDisplayHistory && (mCountFloatp || mCountIntp || mMeasurementFloatp || mMeasurementIntp)) { - S32 num_values = mStatp->getNumValues() - 1; + S32 num_values = frame_recording.getNumPeriods() - 1; S32 i; - for (i = 0; i < num_values; i++) + for (i = 1; i <= num_values; i++) { - if (i == mStatp->getNextBin()) - { - continue; - } if (mPerSec) { - left = (S32)((mStatp->getPrevPerSec(i) - mMinBar) * value_scale); - right = (S32)((mStatp->getPrevPerSec(i) - mMinBar) * value_scale) + 1; + if (mCountFloatp) + { + left = (S32)((frame_recording.getPrevRecordingPeriod(i).getPerSec(*mCountFloatp) - mMinBar) * value_scale); + right = (S32)((frame_recording.getPrevRecordingPeriod(i).getPerSec(*mCountFloatp) - mMinBar) * value_scale) + 1; + } + else if (mCountIntp) + { + left = (S32)((frame_recording.getPrevRecordingPeriod(i).getPerSec(*mCountIntp) - mMinBar) * value_scale); + right = (S32)((frame_recording.getPrevRecordingPeriod(i).getPerSec(*mCountIntp) - mMinBar) * value_scale) + 1; + } + else if (mMeasurementFloatp) + { + left = (S32)((frame_recording.getPrevRecordingPeriod(i).getPerSec(*mMeasurementFloatp) - mMinBar) * value_scale); + right = (S32)((frame_recording.getPrevRecordingPeriod(i).getPerSec(*mMeasurementFloatp) - mMinBar) * value_scale) + 1; + } + else if (mMeasurementIntp) + { + left = (S32)((frame_recording.getPrevRecordingPeriod(i).getPerSec(*mMeasurementIntp) - mMinBar) * value_scale); + right = (S32)((frame_recording.getPrevRecordingPeriod(i).getPerSec(*mMeasurementIntp) - mMinBar) * value_scale) + 1; + } gl_rect_2d(left, bottom+i+1, right, bottom+i, LLColor4(1.f, 0.f, 0.f, 1.f)); } else { - left = (S32)((mStatp->getPrev(i) - mMinBar) * value_scale); - right = (S32)((mStatp->getPrev(i) - mMinBar) * value_scale) + 1; + if (mCountFloatp) + { + left = (S32)((frame_recording.getPrevRecordingPeriod(i).getSum(*mCountFloatp) - mMinBar) * value_scale); + right = (S32)((frame_recording.getPrevRecordingPeriod(i).getSum(*mCountFloatp) - mMinBar) * value_scale) + 1; + } + else if (mCountIntp) + { + left = (S32)((frame_recording.getPrevRecordingPeriod(i).getSum(*mCountIntp) - mMinBar) * value_scale); + right = (S32)((frame_recording.getPrevRecordingPeriod(i).getSum(*mCountIntp) - mMinBar) * value_scale) + 1; + } + else if (mMeasurementFloatp) + { + left = (S32)((frame_recording.getPrevRecordingPeriod(i).getSum(*mMeasurementFloatp) - mMinBar) * value_scale); + right = (S32)((frame_recording.getPrevRecordingPeriod(i).getSum(*mMeasurementFloatp) - mMinBar) * value_scale) + 1; + } + else if (mMeasurementIntp) + { + left = (S32)((frame_recording.getPrevRecordingPeriod(i).getSum(*mMeasurementIntp) - mMinBar) * value_scale); + right = (S32)((frame_recording.getPrevRecordingPeriod(i).getSum(*mMeasurementIntp) - mMinBar) * value_scale) + 1; + } gl_rect_2d(left, bottom+i+1, right, bottom+i, LLColor4(1.f, 0.f, 0.f, 1.f)); } } @@ -279,6 +328,15 @@ void LLStatBar::draw() LLView::draw(); } +void LLStatBar::setStat(const std::string& stat_name) +{ + mCountFloatp = LLTrace::Count<>::getInstance(stat_name); + mCountIntp = LLTrace::Count::getInstance(stat_name); + mMeasurementFloatp = LLTrace::Measurement<>::getInstance(stat_name); + mMeasurementIntp = LLTrace::Measurement::getInstance(stat_name); +} + + void LLStatBar::setRange(F32 bar_min, F32 bar_max, F32 tick_spacing, F32 label_spacing) { mMinBar = bar_min; @@ -293,9 +351,9 @@ LLRect LLStatBar::getRequiredRect() if (mDisplayBar) { - if (mDisplayHistory && mStatp) + if (mDisplayHistory) { - rect.mTop = 35 + mStatp->getNumBins(); + rect.mTop = 35 + LLTrace::get_frame_recording().getNumPeriods(); } else { -- cgit v1.2.3 From 74fe126590fba03752d1d8d88dd3bb59c6900026 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Thu, 1 Nov 2012 17:52:11 -0700 Subject: SH-3405 FIX convert existing stats to lltrace system output of floater_stats is now identical to pre-lltrace system (with some tweaks) --- indra/llui/llstatbar.cpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'indra/llui/llstatbar.cpp') diff --git a/indra/llui/llstatbar.cpp b/indra/llui/llstatbar.cpp index 6b40f8d475..1bc9a9fc67 100644 --- a/indra/llui/llstatbar.cpp +++ b/indra/llui/llstatbar.cpp @@ -53,6 +53,7 @@ LLStatBar::LLStatBar(const Params& p) mLabelSpacing(p.label_spacing), mPrecision(p.precision), mUpdatesPerSec(p.update_rate), + mUnitScale(p.unit_scale), mPerSec(p.show_per_sec), mDisplayBar(p.show_bar), mDisplayHistory(p.show_history), @@ -148,6 +149,11 @@ void LLStatBar::draw() mean = recording.getMean(*mMeasurementIntp); } + current *= mUnitScale; + min *= mUnitScale; + max *= mUnitScale; + mean *= mUnitScale; + if ((mUpdatesPerSec == 0.f) || (mUpdateTimer.getElapsedTimeF32() > 1.f/mUpdatesPerSec) || (mValue == 0.f)) { if (mDisplayMean) -- cgit v1.2.3 From f07b9c2c69f1f6882dcf249aacf33cdfacf878ab Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Wed, 6 Mar 2013 11:08:25 -0800 Subject: renamed LLTrace stat gathering classes/methods to make the structure of LLTrace clearer Count becomes CountStatHandle Count.sum becomes sum(Count, value), etc. --- indra/llui/llstatbar.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'indra/llui/llstatbar.cpp') diff --git a/indra/llui/llstatbar.cpp b/indra/llui/llstatbar.cpp index 1bc9a9fc67..954f615210 100644 --- a/indra/llui/llstatbar.cpp +++ b/indra/llui/llstatbar.cpp @@ -45,10 +45,10 @@ LLStatBar::LLStatBar(const Params& p) mUnitLabel(p.unit_label), mMinBar(p.bar_min), mMaxBar(p.bar_max), - mCountFloatp(LLTrace::Count<>::getInstance(p.stat)), - mCountIntp(LLTrace::Count::getInstance(p.stat)), - mMeasurementFloatp(LLTrace::Measurement<>::getInstance(p.stat)), - mMeasurementIntp(LLTrace::Measurement::getInstance(p.stat)), + mCountFloatp(LLTrace::CountStatHandle<>::getInstance(p.stat)), + mCountIntp(LLTrace::CountStatHandle::getInstance(p.stat)), + mMeasurementFloatp(LLTrace::MeasurementStatHandle<>::getInstance(p.stat)), + mMeasurementIntp(LLTrace::MeasurementStatHandle::getInstance(p.stat)), mTickSpacing(p.tick_spacing), mLabelSpacing(p.label_spacing), mPrecision(p.precision), @@ -336,10 +336,10 @@ void LLStatBar::draw() void LLStatBar::setStat(const std::string& stat_name) { - mCountFloatp = LLTrace::Count<>::getInstance(stat_name); - mCountIntp = LLTrace::Count::getInstance(stat_name); - mMeasurementFloatp = LLTrace::Measurement<>::getInstance(stat_name); - mMeasurementIntp = LLTrace::Measurement::getInstance(stat_name); + mCountFloatp = LLTrace::CountStatHandle<>::getInstance(stat_name); + mCountIntp = LLTrace::CountStatHandle::getInstance(stat_name); + mMeasurementFloatp = LLTrace::MeasurementStatHandle<>::getInstance(stat_name); + mMeasurementIntp = LLTrace::MeasurementStatHandle::getInstance(stat_name); } -- cgit v1.2.3 From 7b4d27ecbcb5ac702459be97cbf6b81354850658 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Thu, 14 Mar 2013 19:36:50 -0700 Subject: SH-3931 WIP Interesting: Add graphs to visualize scene load metrics collapsed Orientation enums to all use LLView::EOrientation added ability to display stat bar horizontally --- indra/llui/llstatbar.cpp | 187 ++++++++++++++++++++++++++++++----------------- 1 file changed, 119 insertions(+), 68 deletions(-) (limited to 'indra/llui/llstatbar.cpp') diff --git a/indra/llui/llstatbar.cpp b/indra/llui/llstatbar.cpp index 954f615210..2bc385061a 100644 --- a/indra/llui/llstatbar.cpp +++ b/indra/llui/llstatbar.cpp @@ -57,7 +57,8 @@ LLStatBar::LLStatBar(const Params& p) mPerSec(p.show_per_sec), mDisplayBar(p.show_bar), mDisplayHistory(p.show_history), - mDisplayMean(p.show_mean) + mDisplayMean(p.show_mean), + mOrientation(p.orientation) {} BOOL LLStatBar::handleMouseDown(S32 x, S32 y, MASK mask) @@ -167,15 +168,27 @@ void LLStatBar::draw() mUpdateTimer.reset(); } - S32 width = getRect().getWidth() - 40; - S32 max_width = width; - S32 bar_top = getRect().getHeight() - 15; // 16 pixels from top. - S32 bar_height = bar_top - 20; - S32 tick_height = 4; - S32 tick_width = 1; - S32 left, top, right, bottom; + S32 bar_top, bar_left, bar_right, bar_bottom; + if (mOrientation == HORIZONTAL) + { + bar_top = getRect().getHeight() - 15; + bar_left = 0; + bar_right = getRect().getWidth() - 80; + bar_bottom = 0; + } + else // VERTICAL + { + bar_top = getRect().getHeight() - 15; // 16 pixels from top. + bar_left = 0; + bar_right = getRect().getWidth(); + bar_bottom = 20; + } + const S32 tick_length = 4; + const S32 tick_width = 1; - F32 value_scale = max_width/(mMaxBar - mMinBar); + F32 value_scale = (mOrientation == HORIZONTAL) + ? (bar_top - bar_bottom)/(mMaxBar - mMinBar) + : (bar_right - bar_left)/(mMaxBar - mMinBar); LLFontGL::getFontMonospace()->renderUTF8(mLabel, 0, 0, getRect().getHeight(), LLColor4(1.f, 1.f, 1.f, 1.f), LLFontGL::LEFT, LLFontGL::TOP); @@ -194,9 +207,16 @@ void LLStatBar::draw() } // Draw the value. - LLFontGL::getFontMonospace()->renderUTF8(value_str, 0, width, getRect().getHeight(), - LLColor4(1.f, 1.f, 1.f, 0.5f), - LLFontGL::RIGHT, LLFontGL::TOP); + if (mOrientation == HORIZONTAL) + { + + } + else + { + LLFontGL::getFontMonospace()->renderUTF8(value_str, 0, bar_right, getRect().getHeight(), + LLColor4(1.f, 1.f, 1.f, 0.5f), + LLFontGL::RIGHT, LLFontGL::TOP); + } value_format = llformat( "%%.%df", mPrecision); if (mDisplayBar && (mCountFloatp || mCountIntp || mMeasurementFloatp || mMeasurementIntp)) @@ -204,64 +224,75 @@ void LLStatBar::draw() std::string tick_label; // Draw the tick marks. - F32 tick_value; - top = bar_top; - bottom = bar_top - bar_height - tick_height/2; - LLGLSUIDefault gls_ui; gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); - for (tick_value = mMinBar; tick_value <= mMaxBar; tick_value += mTickSpacing) + for (F32 tick_value = mMinBar; tick_value <= mMaxBar; tick_value += mTickSpacing) { - left = llfloor((tick_value - mMinBar)*value_scale); - right = left + tick_width; - gl_rect_2d(left, top, right, bottom, LLColor4(1.f, 1.f, 1.f, 0.1f)); + const S32 begin = llfloor((tick_value - mMinBar)*value_scale); + const S32 end = begin + tick_width; + if (mOrientation == HORIZONTAL) + { + } + else + { + gl_rect_2d(begin, bar_top, end, bar_bottom - tick_length/2, LLColor4(1.f, 1.f, 1.f, 0.1f)); + } } // Draw the tick labels (and big ticks). - bottom = bar_top - bar_height - tick_height; - for (tick_value = mMinBar; tick_value <= mMaxBar; tick_value += mLabelSpacing) + for (F32 tick_value = mMinBar; tick_value <= mMaxBar; tick_value += mLabelSpacing) { - left = llfloor((tick_value - mMinBar)*value_scale); - right = left + tick_width; - gl_rect_2d(left, top, right, bottom, LLColor4(1.f, 1.f, 1.f, 0.25f)); - + const S32 begin = llfloor((tick_value - mMinBar)*value_scale); + const S32 end = begin + tick_width; tick_label = llformat( value_format.c_str(), tick_value); + // draw labels for the tick marks - LLFontGL::getFontMonospace()->renderUTF8(tick_label, 0, left - 1, bar_top - bar_height - tick_height, - LLColor4(1.f, 1.f, 1.f, 0.5f), - LLFontGL::LEFT, LLFontGL::TOP); + if (mOrientation == HORIZONTAL) + { + } + else + { + gl_rect_2d(begin, bar_top, end, bar_bottom - tick_length, LLColor4(1.f, 1.f, 1.f, 0.25f)); + LLFontGL::getFontMonospace()->renderUTF8(tick_label, 0, begin - 1, bar_bottom - tick_length, + LLColor4(1.f, 1.f, 1.f, 0.5f), + LLFontGL::LEFT, LLFontGL::TOP); + } } - // Now, draw the bars - top = bar_top; - bottom = bar_top - bar_height; - // draw background bar. - left = 0; - right = width; - gl_rect_2d(left, top, right, bottom, LLColor4(0.f, 0.f, 0.f, 0.25f)); + gl_rect_2d(bar_left, bar_top, bar_right, bar_bottom, LLColor4(0.f, 0.f, 0.f, 0.25f)); if (frame_recording.getNumPeriods() == 0) { // No data, don't draw anything... return; } + // draw min and max - left = (S32) ((min - mMinBar) * value_scale); + S32 begin = (S32) ((min - mMinBar) * value_scale); - if (left < 0) + if (begin < 0) { - left = 0; + begin = 0; llwarns << "Min:" << min << llendl; } - right = (S32) ((max - mMinBar) * value_scale); - gl_rect_2d(left, top, right, bottom, LLColor4(1.f, 0.f, 0.f, 0.25f)); + S32 end = (S32) ((max - mMinBar) * value_scale); + if (mOrientation == HORIZONTAL) + { + gl_rect_2d(bar_left, end, bar_right, begin, LLColor4(1.f, 0.f, 0.f, 0.25f)); + } + else // VERTICAL + { + gl_rect_2d(begin, bar_top, end, bar_bottom, LLColor4(1.f, 0.f, 0.f, 0.25f)); + } if (mDisplayHistory && (mCountFloatp || mCountIntp || mMeasurementFloatp || mMeasurementIntp)) { - S32 num_values = frame_recording.getNumPeriods() - 1; + const S32 num_values = frame_recording.getNumPeriods() - 1; + S32 begin = 0; + S32 end = 0; S32 i; for (i = 1; i <= num_values; i++) { @@ -269,66 +300,86 @@ void LLStatBar::draw() { if (mCountFloatp) { - left = (S32)((frame_recording.getPrevRecordingPeriod(i).getPerSec(*mCountFloatp) - mMinBar) * value_scale); - right = (S32)((frame_recording.getPrevRecordingPeriod(i).getPerSec(*mCountFloatp) - mMinBar) * value_scale) + 1; + begin = (S32)((frame_recording.getPrevRecordingPeriod(i).getPerSec(*mCountFloatp) - mMinBar) * value_scale); + end = (S32)((frame_recording.getPrevRecordingPeriod(i).getPerSec(*mCountFloatp) - mMinBar) * value_scale) + 1; } else if (mCountIntp) { - left = (S32)((frame_recording.getPrevRecordingPeriod(i).getPerSec(*mCountIntp) - mMinBar) * value_scale); - right = (S32)((frame_recording.getPrevRecordingPeriod(i).getPerSec(*mCountIntp) - mMinBar) * value_scale) + 1; + begin = (S32)((frame_recording.getPrevRecordingPeriod(i).getPerSec(*mCountIntp) - mMinBar) * value_scale); + end = (S32)((frame_recording.getPrevRecordingPeriod(i).getPerSec(*mCountIntp) - mMinBar) * value_scale) + 1; } else if (mMeasurementFloatp) { - left = (S32)((frame_recording.getPrevRecordingPeriod(i).getPerSec(*mMeasurementFloatp) - mMinBar) * value_scale); - right = (S32)((frame_recording.getPrevRecordingPeriod(i).getPerSec(*mMeasurementFloatp) - mMinBar) * value_scale) + 1; + begin = (S32)((frame_recording.getPrevRecordingPeriod(i).getPerSec(*mMeasurementFloatp) - mMinBar) * value_scale); + end = (S32)((frame_recording.getPrevRecordingPeriod(i).getPerSec(*mMeasurementFloatp) - mMinBar) * value_scale) + 1; } else if (mMeasurementIntp) { - left = (S32)((frame_recording.getPrevRecordingPeriod(i).getPerSec(*mMeasurementIntp) - mMinBar) * value_scale); - right = (S32)((frame_recording.getPrevRecordingPeriod(i).getPerSec(*mMeasurementIntp) - mMinBar) * value_scale) + 1; + begin = (S32)((frame_recording.getPrevRecordingPeriod(i).getPerSec(*mMeasurementIntp) - mMinBar) * value_scale); + end = (S32)((frame_recording.getPrevRecordingPeriod(i).getPerSec(*mMeasurementIntp) - mMinBar) * value_scale) + 1; } - gl_rect_2d(left, bottom+i+1, right, bottom+i, LLColor4(1.f, 0.f, 0.f, 1.f)); } else { if (mCountFloatp) { - left = (S32)((frame_recording.getPrevRecordingPeriod(i).getSum(*mCountFloatp) - mMinBar) * value_scale); - right = (S32)((frame_recording.getPrevRecordingPeriod(i).getSum(*mCountFloatp) - mMinBar) * value_scale) + 1; + begin = (S32)((frame_recording.getPrevRecordingPeriod(i).getSum(*mCountFloatp) - mMinBar) * value_scale); + end = (S32)((frame_recording.getPrevRecordingPeriod(i).getSum(*mCountFloatp) - mMinBar) * value_scale) + 1; } else if (mCountIntp) { - left = (S32)((frame_recording.getPrevRecordingPeriod(i).getSum(*mCountIntp) - mMinBar) * value_scale); - right = (S32)((frame_recording.getPrevRecordingPeriod(i).getSum(*mCountIntp) - mMinBar) * value_scale) + 1; + begin = (S32)((frame_recording.getPrevRecordingPeriod(i).getSum(*mCountIntp) - mMinBar) * value_scale); + end = (S32)((frame_recording.getPrevRecordingPeriod(i).getSum(*mCountIntp) - mMinBar) * value_scale) + 1; } else if (mMeasurementFloatp) { - left = (S32)((frame_recording.getPrevRecordingPeriod(i).getSum(*mMeasurementFloatp) - mMinBar) * value_scale); - right = (S32)((frame_recording.getPrevRecordingPeriod(i).getSum(*mMeasurementFloatp) - mMinBar) * value_scale) + 1; + begin = (S32)((frame_recording.getPrevRecordingPeriod(i).getSum(*mMeasurementFloatp) - mMinBar) * value_scale); + end = (S32)((frame_recording.getPrevRecordingPeriod(i).getSum(*mMeasurementFloatp) - mMinBar) * value_scale) + 1; } else if (mMeasurementIntp) { - left = (S32)((frame_recording.getPrevRecordingPeriod(i).getSum(*mMeasurementIntp) - mMinBar) * value_scale); - right = (S32)((frame_recording.getPrevRecordingPeriod(i).getSum(*mMeasurementIntp) - mMinBar) * value_scale) + 1; + begin = (S32)((frame_recording.getPrevRecordingPeriod(i).getSum(*mMeasurementIntp) - mMinBar) * value_scale); + end = (S32)((frame_recording.getPrevRecordingPeriod(i).getSum(*mMeasurementIntp) - mMinBar) * value_scale) + 1; } - gl_rect_2d(left, bottom+i+1, right, bottom+i, LLColor4(1.f, 0.f, 0.f, 1.f)); + } + if (mOrientation == HORIZONTAL) + { + gl_rect_2d(bar_right - i, end, bar_right - i - 1, begin, LLColor4(1.f, 0.f, 0.f, 1.f)); + } + else + { + gl_rect_2d(begin, bar_bottom+i+1, end, bar_bottom+i, LLColor4(1.f, 0.f, 0.f, 1.f)); } } } else { + S32 begin = (S32) ((current - mMinBar) * value_scale) - 1; + S32 end = (S32) ((current - mMinBar) * value_scale) + 1; // draw current - left = (S32) ((current - mMinBar) * value_scale) - 1; - right = (S32) ((current - mMinBar) * value_scale) + 1; - gl_rect_2d(left, top, right, bottom, LLColor4(1.f, 0.f, 0.f, 1.f)); + if (mOrientation == HORIZONTAL) + { + gl_rect_2d(bar_left, end, bar_right, begin, LLColor4(1.f, 0.f, 0.f, 1.f)); + } + else + { + gl_rect_2d(begin, bar_top, end, bar_bottom, LLColor4(1.f, 0.f, 0.f, 1.f)); + } } // draw mean bar - top = bar_top + 2; - bottom = bar_top - bar_height - 2; - left = (S32) ((mean - mMinBar) * value_scale) - 1; - right = (S32) ((mean - mMinBar) * value_scale) + 1; - gl_rect_2d(left, top, right, bottom, LLColor4(0.f, 1.f, 0.f, 1.f)); + { + const S32 begin = (S32) ((mean - mMinBar) * value_scale) - 1; + const S32 end = (S32) ((mean - mMinBar) * value_scale) + 1; + if (mOrientation == HORIZONTAL) + { + gl_rect_2d(bar_left - 2, begin, bar_right + 2, end, LLColor4(0.f, 1.f, 0.f, 1.f)); + } + else + { + gl_rect_2d(begin, bar_top + 2, end, bar_bottom - 2, LLColor4(0.f, 1.f, 0.f, 1.f)); + } + } } LLView::draw(); -- 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/llui/llstatbar.cpp | 131 +++++++++++++++++++++++++++++++++++------------ 1 file changed, 97 insertions(+), 34 deletions(-) (limited to 'indra/llui/llstatbar.cpp') diff --git a/indra/llui/llstatbar.cpp b/indra/llui/llstatbar.cpp index 2bc385061a..219ddad452 100644 --- a/indra/llui/llstatbar.cpp +++ b/indra/llui/llstatbar.cpp @@ -36,6 +36,7 @@ #include "lluictrlfactory.h" #include "lltracerecording.h" +#include "llcriticaldamp.h" /////////////////////////////////////////////////////////////////////////////////// @@ -45,6 +46,7 @@ LLStatBar::LLStatBar(const Params& p) mUnitLabel(p.unit_label), mMinBar(p.bar_min), mMaxBar(p.bar_max), + mCurMaxBar(p.bar_max), mCountFloatp(LLTrace::CountStatHandle<>::getInstance(p.stat)), mCountIntp(LLTrace::CountStatHandle::getInstance(p.stat)), mMeasurementFloatp(LLTrace::MeasurementStatHandle<>::getInstance(p.stat)), @@ -54,11 +56,14 @@ LLStatBar::LLStatBar(const Params& p) mPrecision(p.precision), mUpdatesPerSec(p.update_rate), mUnitScale(p.unit_scale), + mNumFrames(p.num_frames), + mMaxHeight(p.max_height), mPerSec(p.show_per_sec), mDisplayBar(p.show_bar), mDisplayHistory(p.show_history), mDisplayMean(p.show_mean), - mOrientation(p.orientation) + mOrientation(p.orientation), + mScaleRange(p.scale_range) {} BOOL LLStatBar::handleMouseDown(S32 x, S32 y, MASK mask) @@ -171,24 +176,38 @@ void LLStatBar::draw() S32 bar_top, bar_left, bar_right, bar_bottom; if (mOrientation == HORIZONTAL) { - bar_top = getRect().getHeight() - 15; + bar_top = llmax(5, getRect().getHeight() - 15); bar_left = 0; - bar_right = getRect().getWidth() - 80; - bar_bottom = 0; + bar_right = getRect().getWidth() - 40; + bar_bottom = llmin(bar_top - 5, 0); } else // VERTICAL { - bar_top = getRect().getHeight() - 15; // 16 pixels from top. + bar_top = llmax(5, getRect().getHeight() - 15); bar_left = 0; bar_right = getRect().getWidth(); - bar_bottom = 20; + bar_bottom = llmin(bar_top - 5, 20); } const S32 tick_length = 4; const S32 tick_width = 1; + if (mScaleRange) + { + F32 cur_max = mLabelSpacing; + while(max > cur_max) + { + cur_max += mLabelSpacing; + } + mCurMaxBar = LLSmoothInterpolation::lerp(mCurMaxBar, cur_max, 0.05f); + } + else + { + mCurMaxBar = mMaxBar; + } + F32 value_scale = (mOrientation == HORIZONTAL) - ? (bar_top - bar_bottom)/(mMaxBar - mMinBar) - : (bar_right - bar_left)/(mMaxBar - mMinBar); + ? (bar_top - bar_bottom)/(mCurMaxBar - mMinBar) + : (bar_right - bar_left)/(mCurMaxBar - mMinBar); LLFontGL::getFontMonospace()->renderUTF8(mLabel, 0, 0, getRect().getHeight(), LLColor4(1.f, 1.f, 1.f, 1.f), LLFontGL::LEFT, LLFontGL::TOP); @@ -209,7 +228,9 @@ void LLStatBar::draw() // Draw the value. if (mOrientation == HORIZONTAL) { - + LLFontGL::getFontMonospace()->renderUTF8(value_str, 0, bar_right, getRect().getHeight(), + LLColor4(1.f, 1.f, 1.f, 0.5f), + LLFontGL::RIGHT, LLFontGL::TOP); } else { @@ -227,12 +248,13 @@ void LLStatBar::draw() LLGLSUIDefault gls_ui; gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); - for (F32 tick_value = mMinBar; tick_value <= mMaxBar; tick_value += mTickSpacing) + for (F32 tick_value = mMinBar + mLabelSpacing; tick_value <= mCurMaxBar; tick_value += mTickSpacing) { const S32 begin = llfloor((tick_value - mMinBar)*value_scale); const S32 end = begin + tick_width; if (mOrientation == HORIZONTAL) { + gl_rect_2d(bar_left, end, bar_right - tick_length/2, begin, LLColor4(1.f, 1.f, 1.f, 0.1f)); } else { @@ -241,7 +263,7 @@ void LLStatBar::draw() } // Draw the tick labels (and big ticks). - for (F32 tick_value = mMinBar; tick_value <= mMaxBar; tick_value += mLabelSpacing) + for (F32 tick_value = mMinBar + mLabelSpacing; tick_value <= mCurMaxBar; tick_value += mLabelSpacing) { const S32 begin = llfloor((tick_value - mMinBar)*value_scale); const S32 end = begin + tick_width; @@ -250,13 +272,17 @@ void LLStatBar::draw() // draw labels for the tick marks if (mOrientation == HORIZONTAL) { + gl_rect_2d(bar_left, end, bar_right - tick_length, begin, LLColor4(1.f, 1.f, 1.f, 0.25f)); + LLFontGL::getFontMonospace()->renderUTF8(tick_label, 0, bar_right, begin, + LLColor4(1.f, 1.f, 1.f, 0.5f), + LLFontGL::LEFT, LLFontGL::VCENTER); } else { gl_rect_2d(begin, bar_top, end, bar_bottom - tick_length, LLColor4(1.f, 1.f, 1.f, 0.25f)); LLFontGL::getFontMonospace()->renderUTF8(tick_label, 0, begin - 1, bar_bottom - tick_length, LLColor4(1.f, 1.f, 1.f, 0.5f), - LLFontGL::LEFT, LLFontGL::TOP); + LLFontGL::RIGHT, LLFontGL::TOP); } } @@ -288,69 +314,99 @@ void LLStatBar::draw() gl_rect_2d(begin, bar_top, end, bar_bottom, LLColor4(1.f, 0.f, 0.f, 0.25f)); } + F32 span = (mOrientation == HORIZONTAL) + ? (bar_right - bar_left) + : (bar_top - bar_bottom); + if (mDisplayHistory && (mCountFloatp || mCountIntp || mMeasurementFloatp || mMeasurementIntp)) { const S32 num_values = frame_recording.getNumPeriods() - 1; - S32 begin = 0; - S32 end = 0; + F32 begin = 0; + F32 end = 0; S32 i; - for (i = 1; i <= num_values; i++) + gGL.color4f( 1.f, 0.f, 0.f, 1.f ); + gGL.begin( LLRender::QUADS ); + const S32 max_frame = llmin(mNumFrames, num_values); + U32 num_samples = 0; + for (i = 1; i <= max_frame; i++) { + F32 offset = ((F32)i / (F32)mNumFrames) * span; + LLTrace::Recording& recording = frame_recording.getPrevRecordingPeriod(i); if (mPerSec) { if (mCountFloatp) { - begin = (S32)((frame_recording.getPrevRecordingPeriod(i).getPerSec(*mCountFloatp) - mMinBar) * value_scale); - end = (S32)((frame_recording.getPrevRecordingPeriod(i).getPerSec(*mCountFloatp) - mMinBar) * value_scale) + 1; + begin = ((recording.getPerSec(*mCountFloatp) - mMinBar) * value_scale); + end = ((recording.getPerSec(*mCountFloatp) - mMinBar) * value_scale) + 1; + num_samples = recording.getSampleCount(*mCountFloatp); } else if (mCountIntp) { - begin = (S32)((frame_recording.getPrevRecordingPeriod(i).getPerSec(*mCountIntp) - mMinBar) * value_scale); - end = (S32)((frame_recording.getPrevRecordingPeriod(i).getPerSec(*mCountIntp) - mMinBar) * value_scale) + 1; + begin = ((recording.getPerSec(*mCountIntp) - mMinBar) * value_scale); + end = ((recording.getPerSec(*mCountIntp) - mMinBar) * value_scale) + 1; + num_samples = recording.getSampleCount(*mCountIntp); } else if (mMeasurementFloatp) { - begin = (S32)((frame_recording.getPrevRecordingPeriod(i).getPerSec(*mMeasurementFloatp) - mMinBar) * value_scale); - end = (S32)((frame_recording.getPrevRecordingPeriod(i).getPerSec(*mMeasurementFloatp) - mMinBar) * value_scale) + 1; + //rate isn't defined for measurement stats, so use mean + begin = ((recording.getMean(*mMeasurementFloatp) - mMinBar) * value_scale); + end = ((recording.getMean(*mMeasurementFloatp) - mMinBar) * value_scale) + 1; + num_samples = recording.getSampleCount(*mMeasurementFloatp); } else if (mMeasurementIntp) { - begin = (S32)((frame_recording.getPrevRecordingPeriod(i).getPerSec(*mMeasurementIntp) - mMinBar) * value_scale); - end = (S32)((frame_recording.getPrevRecordingPeriod(i).getPerSec(*mMeasurementIntp) - mMinBar) * value_scale) + 1; + //rate isn't defined for measurement stats, so use mean + begin = ((recording.getMean(*mMeasurementIntp) - mMinBar) * value_scale); + end = ((recording.getMean(*mMeasurementIntp) - mMinBar) * value_scale) + 1; + num_samples = recording.getSampleCount(*mMeasurementIntp); } } else { if (mCountFloatp) { - begin = (S32)((frame_recording.getPrevRecordingPeriod(i).getSum(*mCountFloatp) - mMinBar) * value_scale); - end = (S32)((frame_recording.getPrevRecordingPeriod(i).getSum(*mCountFloatp) - mMinBar) * value_scale) + 1; + begin = ((recording.getSum(*mCountFloatp) - mMinBar) * value_scale); + end = ((recording.getSum(*mCountFloatp) - mMinBar) * value_scale) + 1; + num_samples = recording.getSampleCount(*mCountFloatp); } else if (mCountIntp) { - begin = (S32)((frame_recording.getPrevRecordingPeriod(i).getSum(*mCountIntp) - mMinBar) * value_scale); - end = (S32)((frame_recording.getPrevRecordingPeriod(i).getSum(*mCountIntp) - mMinBar) * value_scale) + 1; + begin = ((recording.getSum(*mCountIntp) - mMinBar) * value_scale); + end = ((recording.getSum(*mCountIntp) - mMinBar) * value_scale) + 1; + num_samples = recording.getSampleCount(*mCountIntp); } else if (mMeasurementFloatp) { - begin = (S32)((frame_recording.getPrevRecordingPeriod(i).getSum(*mMeasurementFloatp) - mMinBar) * value_scale); - end = (S32)((frame_recording.getPrevRecordingPeriod(i).getSum(*mMeasurementFloatp) - mMinBar) * value_scale) + 1; + begin = ((recording.getMean(*mMeasurementFloatp) - mMinBar) * value_scale); + end = ((recording.getMean(*mMeasurementFloatp) - mMinBar) * value_scale) + 1; + num_samples = recording.getSampleCount(*mMeasurementFloatp); } else if (mMeasurementIntp) { - begin = (S32)((frame_recording.getPrevRecordingPeriod(i).getSum(*mMeasurementIntp) - mMinBar) * value_scale); - end = (S32)((frame_recording.getPrevRecordingPeriod(i).getSum(*mMeasurementIntp) - mMinBar) * value_scale) + 1; + begin = ((recording.getMean(*mMeasurementIntp) - mMinBar) * value_scale); + end = ((recording.getMean(*mMeasurementIntp) - mMinBar) * value_scale) + 1; + num_samples = recording.getSampleCount(*mMeasurementIntp); } } + + if (!num_samples) continue; + if (mOrientation == HORIZONTAL) { - gl_rect_2d(bar_right - i, end, bar_right - i - 1, begin, LLColor4(1.f, 0.f, 0.f, 1.f)); + gGL.vertex2f((F32)bar_right - offset, end); + gGL.vertex2f((F32)bar_right - offset, begin); + gGL.vertex2f((F32)bar_right - offset - 1.f, begin); + gGL.vertex2f((F32)bar_right - offset - 1.f, end); } else { - gl_rect_2d(begin, bar_bottom+i+1, end, bar_bottom+i, LLColor4(1.f, 0.f, 0.f, 1.f)); + gGL.vertex2i(begin, (F32)bar_bottom+offset+1.f); + gGL.vertex2i(begin, (F32)bar_bottom+offset); + gGL.vertex2i(end, (F32)bar_bottom+offset); + gGL.vertex2i(end, (F32)bar_bottom+offset+1.f); } } + gGL.end(); } else { @@ -410,7 +466,14 @@ LLRect LLStatBar::getRequiredRect() { if (mDisplayHistory) { - rect.mTop = 35 + LLTrace::get_frame_recording().getNumPeriods(); + if (mOrientation == HORIZONTAL) + { + rect.mTop = mMaxHeight; + } + else + { + rect.mTop = 35 + llmin(mMaxHeight, llmin(mNumFrames, LLTrace::get_frame_recording().getNumPeriods())); + } } else { -- 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/llui/llstatbar.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'indra/llui/llstatbar.cpp') diff --git a/indra/llui/llstatbar.cpp b/indra/llui/llstatbar.cpp index 219ddad452..cda40aac72 100644 --- a/indra/llui/llstatbar.cpp +++ b/indra/llui/llstatbar.cpp @@ -88,7 +88,7 @@ BOOL LLStatBar::handleMouseDown(S32 x, S32 y, MASK mask) LLView* parent = getParent(); parent->reshape(parent->getRect().getWidth(), parent->getRect().getHeight(), FALSE); - return FALSE; + return TRUE; } void LLStatBar::draw() @@ -98,6 +98,7 @@ void LLStatBar::draw() max = 0.f, mean = 0.f; + S32 num_samples = 0; LLTrace::PeriodicRecording& frame_recording = LLTrace::get_frame_recording(); if (mCountFloatp) @@ -110,6 +111,7 @@ void LLStatBar::draw() min = frame_recording.getPeriodMinPerSec(*mCountFloatp); max = frame_recording.getPeriodMaxPerSec(*mCountFloatp); mean = frame_recording.getPeriodMeanPerSec(*mCountFloatp); + num_samples = frame_recording.getTotalRecording().getSampleCount(*mCountFloatp); } else { @@ -117,6 +119,7 @@ void LLStatBar::draw() min = frame_recording.getPeriodMin(*mCountFloatp); max = frame_recording.getPeriodMax(*mCountFloatp); mean = frame_recording.getPeriodMean(*mCountFloatp); + num_samples = frame_recording.getTotalRecording().getSampleCount(*mCountFloatp); } } else if (mCountIntp) @@ -129,6 +132,7 @@ void LLStatBar::draw() min = frame_recording.getPeriodMinPerSec(*mCountIntp); max = frame_recording.getPeriodMaxPerSec(*mCountIntp); mean = frame_recording.getPeriodMeanPerSec(*mCountIntp); + num_samples = frame_recording.getTotalRecording().getSampleCount(*mCountIntp); } else { @@ -136,6 +140,7 @@ void LLStatBar::draw() min = frame_recording.getPeriodMin(*mCountIntp); max = frame_recording.getPeriodMax(*mCountIntp); mean = frame_recording.getPeriodMean(*mCountIntp); + num_samples = frame_recording.getTotalRecording().getSampleCount(*mCountIntp); } } else if (mMeasurementFloatp) @@ -145,6 +150,7 @@ void LLStatBar::draw() min = recording.getMin(*mMeasurementFloatp); max = recording.getMax(*mMeasurementFloatp); mean = recording.getMean(*mMeasurementFloatp); + num_samples = frame_recording.getTotalRecording().getSampleCount(*mMeasurementFloatp); } else if (mMeasurementIntp) { @@ -153,6 +159,7 @@ void LLStatBar::draw() min = recording.getMin(*mMeasurementIntp); max = recording.getMax(*mMeasurementIntp); mean = recording.getMean(*mMeasurementIntp); + num_samples = frame_recording.getTotalRecording().getSampleCount(*mMeasurementIntp); } current *= mUnitScale; @@ -191,7 +198,7 @@ void LLStatBar::draw() const S32 tick_length = 4; const S32 tick_width = 1; - if (mScaleRange) + if (mScaleRange && num_samples) { F32 cur_max = mLabelSpacing; while(max > cur_max) @@ -472,7 +479,7 @@ LLRect LLStatBar::getRequiredRect() } else { - rect.mTop = 35 + llmin(mMaxHeight, llmin(mNumFrames, LLTrace::get_frame_recording().getNumPeriods())); + rect.mTop = 35 + llmin(mMaxHeight, llmin(mNumFrames, (S32)LLTrace::get_frame_recording().getNumPeriods())); } } else -- cgit v1.2.3 From 935dce7d6b0a343cef5b13f53d6da5d0c2dc6a73 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Mon, 25 Mar 2013 00:18:06 -0700 Subject: SH-3931 WIP Interesting: Add graphs to visualize scene load metrics fixed some compile errors made label spacing automatic on stat bars fixed infinite values coming from stats --- indra/llui/llstatbar.cpp | 107 +++++++++++++++++++++++++---------------------- 1 file changed, 57 insertions(+), 50 deletions(-) (limited to 'indra/llui/llstatbar.cpp') diff --git a/indra/llui/llstatbar.cpp b/indra/llui/llstatbar.cpp index cda40aac72..d9f3d14ef0 100644 --- a/indra/llui/llstatbar.cpp +++ b/indra/llui/llstatbar.cpp @@ -52,7 +52,6 @@ LLStatBar::LLStatBar(const Params& p) mMeasurementFloatp(LLTrace::MeasurementStatHandle<>::getInstance(p.stat)), mMeasurementIntp(LLTrace::MeasurementStatHandle::getInstance(p.stat)), mTickSpacing(p.tick_spacing), - mLabelSpacing(p.label_spacing), mPrecision(p.precision), mUpdatesPerSec(p.update_rate), mUnitScale(p.unit_scale), @@ -68,26 +67,32 @@ LLStatBar::LLStatBar(const Params& p) BOOL LLStatBar::handleMouseDown(S32 x, S32 y, MASK mask) { - if (mDisplayBar) + BOOL handled = LLView::handleMouseDown(x, y, mask); + if (!handled) { - if (mDisplayHistory) + if (mDisplayBar) { - mDisplayBar = FALSE; - mDisplayHistory = FALSE; + if (mDisplayHistory || mOrientation == HORIZONTAL) + { + mDisplayBar = FALSE; + mDisplayHistory = FALSE; + } + else + { + mDisplayHistory = TRUE; + } } else { - mDisplayHistory = TRUE; + mDisplayBar = TRUE; + if (mOrientation == HORIZONTAL) + { + mDisplayHistory = TRUE; + } } + LLView* parent = getParent(); + parent->reshape(parent->getRect().getWidth(), parent->getRect().getHeight(), FALSE); } - else - { - mDisplayBar = TRUE; - } - - LLView* parent = getParent(); - parent->reshape(parent->getRect().getWidth(), parent->getRect().getHeight(), FALSE); - return TRUE; } @@ -200,10 +205,10 @@ void LLStatBar::draw() if (mScaleRange && num_samples) { - F32 cur_max = mLabelSpacing; - while(max > cur_max) + F32 cur_max = mTickSpacing; + while(max > cur_max && mMaxBar > cur_max) { - cur_max += mLabelSpacing; + cur_max += mTickSpacing; } mCurMaxBar = LLSmoothInterpolation::lerp(mCurMaxBar, cur_max, 0.05f); } @@ -254,42 +259,51 @@ void LLStatBar::draw() // Draw the tick marks. LLGLSUIDefault gls_ui; gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); - - for (F32 tick_value = mMinBar + mLabelSpacing; tick_value <= mCurMaxBar; tick_value += mTickSpacing) + S32 last_tick = 0; + S32 last_label = 0; + const S32 MIN_TICK_SPACING = mOrientation == HORIZONTAL ? 20 : 30; + const S32 MIN_LABEL_SPACING = mOrientation == HORIZONTAL ? 40 : 60; + for (F32 tick_value = mMinBar + mTickSpacing; tick_value <= mCurMaxBar; tick_value += mTickSpacing) { const S32 begin = llfloor((tick_value - mMinBar)*value_scale); const S32 end = begin + tick_width; - if (mOrientation == HORIZONTAL) + if (begin - last_tick < MIN_TICK_SPACING) { - gl_rect_2d(bar_left, end, bar_right - tick_length/2, begin, LLColor4(1.f, 1.f, 1.f, 0.1f)); + continue; } - else - { - gl_rect_2d(begin, bar_top, end, bar_bottom - tick_length/2, LLColor4(1.f, 1.f, 1.f, 0.1f)); - } - } + last_tick = begin; - // Draw the tick labels (and big ticks). - for (F32 tick_value = mMinBar + mLabelSpacing; tick_value <= mCurMaxBar; tick_value += mLabelSpacing) - { - const S32 begin = llfloor((tick_value - mMinBar)*value_scale); - const S32 end = begin + tick_width; tick_label = llformat( value_format.c_str(), tick_value); - // draw labels for the tick marks if (mOrientation == HORIZONTAL) { - gl_rect_2d(bar_left, end, bar_right - tick_length, begin, LLColor4(1.f, 1.f, 1.f, 0.25f)); - LLFontGL::getFontMonospace()->renderUTF8(tick_label, 0, bar_right, begin, - LLColor4(1.f, 1.f, 1.f, 0.5f), - LLFontGL::LEFT, LLFontGL::VCENTER); + if (begin - last_label > MIN_LABEL_SPACING) + { + gl_rect_2d(bar_left, end, bar_right - tick_length, begin, LLColor4(1.f, 1.f, 1.f, 0.25f)); + LLFontGL::getFontMonospace()->renderUTF8(tick_label, 0, bar_right, begin, + LLColor4(1.f, 1.f, 1.f, 0.5f), + LLFontGL::LEFT, LLFontGL::VCENTER); + last_label = begin; + } + else + { + gl_rect_2d(bar_left, end, bar_right - tick_length/2, begin, LLColor4(1.f, 1.f, 1.f, 0.1f)); + } } else { - gl_rect_2d(begin, bar_top, end, bar_bottom - tick_length, LLColor4(1.f, 1.f, 1.f, 0.25f)); - LLFontGL::getFontMonospace()->renderUTF8(tick_label, 0, begin - 1, bar_bottom - tick_length, - LLColor4(1.f, 1.f, 1.f, 0.5f), - LLFontGL::RIGHT, LLFontGL::TOP); + if (begin - last_label > MIN_LABEL_SPACING) + { + gl_rect_2d(begin, bar_top, end, bar_bottom - tick_length, LLColor4(1.f, 1.f, 1.f, 0.25f)); + LLFontGL::getFontMonospace()->renderUTF8(tick_label, 0, begin - 1, bar_bottom - tick_length, + LLColor4(1.f, 1.f, 1.f, 0.5f), + LLFontGL::RIGHT, LLFontGL::TOP); + last_label = begin; + } + else + { + gl_rect_2d(begin, bar_top, end, bar_bottom - tick_length/2, LLColor4(1.f, 1.f, 1.f, 0.1f)); + } } } @@ -457,12 +471,11 @@ void LLStatBar::setStat(const std::string& stat_name) } -void LLStatBar::setRange(F32 bar_min, F32 bar_max, F32 tick_spacing, F32 label_spacing) +void LLStatBar::setRange(F32 bar_min, F32 bar_max, F32 tick_spacing) { mMinBar = bar_min; mMaxBar = bar_max; mTickSpacing = tick_spacing; - mLabelSpacing = label_spacing; } LLRect LLStatBar::getRequiredRect() @@ -473,14 +486,7 @@ LLRect LLStatBar::getRequiredRect() { if (mDisplayHistory) { - if (mOrientation == HORIZONTAL) - { - rect.mTop = mMaxHeight; - } - else - { - rect.mTop = 35 + llmin(mMaxHeight, llmin(mNumFrames, (S32)LLTrace::get_frame_recording().getNumPeriods())); - } + rect.mTop = mMaxHeight; } else { @@ -493,3 +499,4 @@ LLRect LLStatBar::getRequiredRect() } return rect; } + -- cgit v1.2.3 From faebbb23f87a855463aba611ca8944ec7f4e0a9c Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Wed, 10 Apr 2013 15:31:44 -0700 Subject: BUILDFIX: gcc error about type conversion --- indra/llui/llstatbar.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'indra/llui/llstatbar.cpp') diff --git a/indra/llui/llstatbar.cpp b/indra/llui/llstatbar.cpp index d9f3d14ef0..d73cd74651 100644 --- a/indra/llui/llstatbar.cpp +++ b/indra/llui/llstatbar.cpp @@ -421,10 +421,10 @@ void LLStatBar::draw() } else { - gGL.vertex2i(begin, (F32)bar_bottom+offset+1.f); - gGL.vertex2i(begin, (F32)bar_bottom+offset); - gGL.vertex2i(end, (F32)bar_bottom+offset); - gGL.vertex2i(end, (F32)bar_bottom+offset+1.f); + gGL.vertex2f(begin, (F32)bar_bottom+offset+1.f); + gGL.vertex2f(begin, (F32)bar_bottom+offset); + gGL.vertex2f(end, (F32)bar_bottom+offset); + gGL.vertex2f(end, (F32)bar_bottom+offset+1.f); } } gGL.end(); -- 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/llui/llstatbar.cpp | 37 ++++++++++++++++--------------------- 1 file changed, 16 insertions(+), 21 deletions(-) (limited to 'indra/llui/llstatbar.cpp') diff --git a/indra/llui/llstatbar.cpp b/indra/llui/llstatbar.cpp index d9f3d14ef0..46eea368e5 100644 --- a/indra/llui/llstatbar.cpp +++ b/indra/llui/llstatbar.cpp @@ -103,12 +103,11 @@ void LLStatBar::draw() max = 0.f, mean = 0.f; - S32 num_samples = 0; LLTrace::PeriodicRecording& frame_recording = LLTrace::get_frame_recording(); if (mCountFloatp) { - LLTrace::Recording& last_frame_recording = frame_recording.getLastRecordingPeriod(); + LLTrace::Recording& last_frame_recording = frame_recording.getLastRecording(); if (mPerSec) { @@ -116,7 +115,6 @@ void LLStatBar::draw() min = frame_recording.getPeriodMinPerSec(*mCountFloatp); max = frame_recording.getPeriodMaxPerSec(*mCountFloatp); mean = frame_recording.getPeriodMeanPerSec(*mCountFloatp); - num_samples = frame_recording.getTotalRecording().getSampleCount(*mCountFloatp); } else { @@ -124,12 +122,11 @@ void LLStatBar::draw() min = frame_recording.getPeriodMin(*mCountFloatp); max = frame_recording.getPeriodMax(*mCountFloatp); mean = frame_recording.getPeriodMean(*mCountFloatp); - num_samples = frame_recording.getTotalRecording().getSampleCount(*mCountFloatp); } } else if (mCountIntp) { - LLTrace::Recording& last_frame_recording = frame_recording.getLastRecordingPeriod(); + LLTrace::Recording& last_frame_recording = frame_recording.getLastRecording(); if (mPerSec) { @@ -137,7 +134,6 @@ void LLStatBar::draw() min = frame_recording.getPeriodMinPerSec(*mCountIntp); max = frame_recording.getPeriodMaxPerSec(*mCountIntp); mean = frame_recording.getPeriodMeanPerSec(*mCountIntp); - num_samples = frame_recording.getTotalRecording().getSampleCount(*mCountIntp); } else { @@ -145,26 +141,25 @@ void LLStatBar::draw() min = frame_recording.getPeriodMin(*mCountIntp); max = frame_recording.getPeriodMax(*mCountIntp); mean = frame_recording.getPeriodMean(*mCountIntp); - num_samples = frame_recording.getTotalRecording().getSampleCount(*mCountIntp); } } else if (mMeasurementFloatp) { - LLTrace::Recording& recording = frame_recording.getTotalRecording(); - current = recording.getLastValue(*mMeasurementFloatp); - min = recording.getMin(*mMeasurementFloatp); - max = recording.getMax(*mMeasurementFloatp); - mean = recording.getMean(*mMeasurementFloatp); - num_samples = frame_recording.getTotalRecording().getSampleCount(*mMeasurementFloatp); + LLTrace::Recording& last_frame_recording = frame_recording.getLastRecording(); + + current = last_frame_recording.getLastValue(*mMeasurementFloatp); + min = frame_recording.getPeriodMin(*mMeasurementFloatp); + max = frame_recording.getPeriodMax(*mMeasurementFloatp); + mean = frame_recording.getPeriodMean(*mMeasurementFloatp); } else if (mMeasurementIntp) { - LLTrace::Recording& recording = frame_recording.getTotalRecording(); - current = recording.getLastValue(*mMeasurementIntp); - min = recording.getMin(*mMeasurementIntp); - max = recording.getMax(*mMeasurementIntp); - mean = recording.getMean(*mMeasurementIntp); - num_samples = frame_recording.getTotalRecording().getSampleCount(*mMeasurementIntp); + LLTrace::Recording& last_frame_recording = frame_recording.getLastRecording(); + + current = last_frame_recording.getLastValue(*mMeasurementIntp); + min = frame_recording.getPeriodMin(*mMeasurementIntp); + max = frame_recording.getPeriodMax(*mMeasurementIntp); + mean = frame_recording.getPeriodMean(*mMeasurementIntp); } current *= mUnitScale; @@ -203,7 +198,7 @@ void LLStatBar::draw() const S32 tick_length = 4; const S32 tick_width = 1; - if (mScaleRange && num_samples) + if (mScaleRange && min < max) { F32 cur_max = mTickSpacing; while(max > cur_max && mMaxBar > cur_max) @@ -352,7 +347,7 @@ void LLStatBar::draw() for (i = 1; i <= max_frame; i++) { F32 offset = ((F32)i / (F32)mNumFrames) * span; - LLTrace::Recording& recording = frame_recording.getPrevRecordingPeriod(i); + LLTrace::Recording& recording = frame_recording.getPrevRecording(i); if (mPerSec) { if (mCountFloatp) -- cgit v1.2.3 From bdc6d58b7e84bc81977148995b0028f7420eee65 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Thu, 11 Apr 2013 19:12:27 -0700 Subject: SH-3931 WIP Interesting: Add graphs to visualize scene load metrics added ability to query periodic timer for specific number of periods used that to do smaller time averaged window for camera speed --- indra/llui/llstatbar.cpp | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) (limited to 'indra/llui/llstatbar.cpp') diff --git a/indra/llui/llstatbar.cpp b/indra/llui/llstatbar.cpp index 46eea368e5..70ba59b130 100644 --- a/indra/llui/llstatbar.cpp +++ b/indra/llui/llstatbar.cpp @@ -112,16 +112,16 @@ void LLStatBar::draw() if (mPerSec) { current = last_frame_recording.getPerSec(*mCountFloatp); - min = frame_recording.getPeriodMinPerSec(*mCountFloatp); - max = frame_recording.getPeriodMaxPerSec(*mCountFloatp); - mean = frame_recording.getPeriodMeanPerSec(*mCountFloatp); + min = frame_recording.getPeriodMinPerSec(*mCountFloatp, mNumFrames); + max = frame_recording.getPeriodMaxPerSec(*mCountFloatp, mNumFrames); + mean = frame_recording.getPeriodMeanPerSec(*mCountFloatp, mNumFrames); } else { current = last_frame_recording.getSum(*mCountFloatp); - min = frame_recording.getPeriodMin(*mCountFloatp); - max = frame_recording.getPeriodMax(*mCountFloatp); - mean = frame_recording.getPeriodMean(*mCountFloatp); + min = frame_recording.getPeriodMin(*mCountFloatp, mNumFrames); + max = frame_recording.getPeriodMax(*mCountFloatp, mNumFrames); + mean = frame_recording.getPeriodMean(*mCountFloatp, mNumFrames); } } else if (mCountIntp) @@ -131,16 +131,16 @@ void LLStatBar::draw() if (mPerSec) { current = last_frame_recording.getPerSec(*mCountIntp); - min = frame_recording.getPeriodMinPerSec(*mCountIntp); - max = frame_recording.getPeriodMaxPerSec(*mCountIntp); - mean = frame_recording.getPeriodMeanPerSec(*mCountIntp); + min = frame_recording.getPeriodMinPerSec(*mCountIntp, mNumFrames); + max = frame_recording.getPeriodMaxPerSec(*mCountIntp, mNumFrames); + mean = frame_recording.getPeriodMeanPerSec(*mCountIntp, mNumFrames); } else { current = last_frame_recording.getSum(*mCountIntp); - min = frame_recording.getPeriodMin(*mCountIntp); - max = frame_recording.getPeriodMax(*mCountIntp); - mean = frame_recording.getPeriodMean(*mCountIntp); + min = frame_recording.getPeriodMin(*mCountIntp, mNumFrames); + max = frame_recording.getPeriodMax(*mCountIntp, mNumFrames); + mean = frame_recording.getPeriodMean(*mCountIntp, mNumFrames); } } else if (mMeasurementFloatp) @@ -148,18 +148,18 @@ void LLStatBar::draw() LLTrace::Recording& last_frame_recording = frame_recording.getLastRecording(); current = last_frame_recording.getLastValue(*mMeasurementFloatp); - min = frame_recording.getPeriodMin(*mMeasurementFloatp); - max = frame_recording.getPeriodMax(*mMeasurementFloatp); - mean = frame_recording.getPeriodMean(*mMeasurementFloatp); + min = frame_recording.getPeriodMin(*mMeasurementFloatp, mNumFrames); + max = frame_recording.getPeriodMax(*mMeasurementFloatp, mNumFrames); + mean = frame_recording.getPeriodMean(*mMeasurementFloatp, mNumFrames); } else if (mMeasurementIntp) { LLTrace::Recording& last_frame_recording = frame_recording.getLastRecording(); current = last_frame_recording.getLastValue(*mMeasurementIntp); - min = frame_recording.getPeriodMin(*mMeasurementIntp); - max = frame_recording.getPeriodMax(*mMeasurementIntp); - mean = frame_recording.getPeriodMean(*mMeasurementIntp); + min = frame_recording.getPeriodMin(*mMeasurementIntp, mNumFrames); + max = frame_recording.getPeriodMax(*mMeasurementIntp, mNumFrames); + mean = frame_recording.getPeriodMean(*mMeasurementIntp, mNumFrames); } current *= mUnitScale; -- cgit v1.2.3 From 9ae76d12157641033431381959ef4f798a119b8d Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Wed, 29 May 2013 17:00:50 -0700 Subject: SH-3931 WIP Interesting: Add graphs to visualize scene load metrics fixed copy construction behavior of Recordings to not zero out data split measurement into event and sample, with sample representing a continuous function --- indra/llui/llstatbar.cpp | 118 ++++++++++++++++++++++++++++++++--------------- 1 file changed, 81 insertions(+), 37 deletions(-) (limited to 'indra/llui/llstatbar.cpp') diff --git a/indra/llui/llstatbar.cpp b/indra/llui/llstatbar.cpp index 972b436bdc..22ca90df7a 100644 --- a/indra/llui/llstatbar.cpp +++ b/indra/llui/llstatbar.cpp @@ -47,10 +47,6 @@ LLStatBar::LLStatBar(const Params& p) mMinBar(p.bar_min), mMaxBar(p.bar_max), mCurMaxBar(p.bar_max), - mCountFloatp(LLTrace::CountStatHandle<>::getInstance(p.stat)), - mCountIntp(LLTrace::CountStatHandle::getInstance(p.stat)), - mMeasurementFloatp(LLTrace::MeasurementStatHandle<>::getInstance(p.stat)), - mMeasurementIntp(LLTrace::MeasurementStatHandle::getInstance(p.stat)), mTickSpacing(p.tick_spacing), mPrecision(p.precision), mUpdatesPerSec(p.update_rate), @@ -63,7 +59,9 @@ LLStatBar::LLStatBar(const Params& p) mDisplayMean(p.show_mean), mOrientation(p.orientation), mScaleRange(p.scale_range) -{} +{ + setStat(p.stat); +} BOOL LLStatBar::handleMouseDown(S32 x, S32 y, MASK mask) { @@ -143,23 +141,41 @@ void LLStatBar::draw() mean = frame_recording.getPeriodMean(*mCountIntp, mNumFrames); } } - else if (mMeasurementFloatp) + else if (mEventFloatp) { - LLTrace::Recording& last_frame_recording = frame_recording.getLastRecording(); + LLTrace::Recording& last_frame_recording = frame_recording.getLastRecording(); - current = last_frame_recording.getLastValue(*mMeasurementFloatp); - min = frame_recording.getPeriodMin(*mMeasurementFloatp, mNumFrames); - max = frame_recording.getPeriodMax(*mMeasurementFloatp, mNumFrames); - mean = frame_recording.getPeriodMean(*mMeasurementFloatp, mNumFrames); + current = last_frame_recording.getMean(*mEventFloatp); + min = frame_recording.getPeriodMin(*mEventFloatp, mNumFrames); + max = frame_recording.getPeriodMax(*mEventFloatp, mNumFrames); + mean = frame_recording.getPeriodMean(*mEventFloatp, mNumFrames); } - else if (mMeasurementIntp) + else if (mEventIntp) { - LLTrace::Recording& last_frame_recording = frame_recording.getLastRecording(); + LLTrace::Recording& last_frame_recording = frame_recording.getLastRecording(); + + current = last_frame_recording.getLastValue(*mEventIntp); + min = frame_recording.getPeriodMin(*mEventIntp, mNumFrames); + max = frame_recording.getPeriodMax(*mEventIntp, mNumFrames); + mean = frame_recording.getPeriodMean(*mEventIntp, mNumFrames); + } + else if (mSampleFloatp) + { + LLTrace::Recording& last_frame_recording = frame_recording.getLastRecording(); + + current = last_frame_recording.getLastValue(*mSampleFloatp); + min = frame_recording.getPeriodMin(*mSampleFloatp, mNumFrames); + max = frame_recording.getPeriodMax(*mSampleFloatp, mNumFrames); + mean = frame_recording.getPeriodMean(*mSampleFloatp, mNumFrames); + } + else if (mSampleIntp) + { + LLTrace::Recording& last_frame_recording = frame_recording.getLastRecording(); - current = last_frame_recording.getLastValue(*mMeasurementIntp); - min = frame_recording.getPeriodMin(*mMeasurementIntp, mNumFrames); - max = frame_recording.getPeriodMax(*mMeasurementIntp, mNumFrames); - mean = frame_recording.getPeriodMean(*mMeasurementIntp, mNumFrames); + current = last_frame_recording.getLastValue(*mSampleIntp); + min = frame_recording.getPeriodMin(*mSampleIntp, mNumFrames); + max = frame_recording.getPeriodMax(*mSampleIntp, mNumFrames); + mean = frame_recording.getPeriodMean(*mSampleIntp, mNumFrames); } current *= mUnitScale; @@ -247,7 +263,7 @@ void LLStatBar::draw() } value_format = llformat( "%%.%df", mPrecision); - if (mDisplayBar && (mCountFloatp || mCountIntp || mMeasurementFloatp || mMeasurementIntp)) + if (mDisplayBar && (mCountFloatp || mCountIntp || mEventFloatp || mEventIntp || mSampleFloatp || mSampleIntp)) { std::string tick_label; @@ -334,7 +350,7 @@ void LLStatBar::draw() ? (bar_right - bar_left) : (bar_top - bar_bottom); - if (mDisplayHistory && (mCountFloatp || mCountIntp || mMeasurementFloatp || mMeasurementIntp)) + if (mDisplayHistory && (mCountFloatp || mCountIntp || mEventFloatp || mEventIntp || mSampleFloatp || mSampleIntp)) { const S32 num_values = frame_recording.getNumPeriods() - 1; F32 begin = 0; @@ -362,19 +378,33 @@ void LLStatBar::draw() end = ((recording.getPerSec(*mCountIntp) - mMinBar) * value_scale) + 1; num_samples = recording.getSampleCount(*mCountIntp); } - else if (mMeasurementFloatp) + else if (mEventFloatp) { //rate isn't defined for measurement stats, so use mean - begin = ((recording.getMean(*mMeasurementFloatp) - mMinBar) * value_scale); - end = ((recording.getMean(*mMeasurementFloatp) - mMinBar) * value_scale) + 1; - num_samples = recording.getSampleCount(*mMeasurementFloatp); + begin = ((recording.getMean(*mEventFloatp) - mMinBar) * value_scale); + end = ((recording.getMean(*mEventFloatp) - mMinBar) * value_scale) + 1; + num_samples = recording.getSampleCount(*mEventFloatp); } - else if (mMeasurementIntp) + else if (mEventIntp) { //rate isn't defined for measurement stats, so use mean - begin = ((recording.getMean(*mMeasurementIntp) - mMinBar) * value_scale); - end = ((recording.getMean(*mMeasurementIntp) - mMinBar) * value_scale) + 1; - num_samples = recording.getSampleCount(*mMeasurementIntp); + begin = ((recording.getMean(*mEventIntp) - mMinBar) * value_scale); + end = ((recording.getMean(*mEventIntp) - mMinBar) * value_scale) + 1; + num_samples = recording.getSampleCount(*mEventIntp); + } + else if (mSampleFloatp) + { + //rate isn't defined for sample stats, so use mean + begin = ((recording.getMean(*mEventFloatp) - mMinBar) * value_scale); + end = ((recording.getMean(*mEventFloatp) - mMinBar) * value_scale) + 1; + num_samples = recording.getSampleCount(*mEventFloatp); + } + else if (mSampleIntp) + { + //rate isn't defined for sample stats, so use mean + begin = ((recording.getMean(*mEventFloatp) - mMinBar) * value_scale); + end = ((recording.getMean(*mEventFloatp) - mMinBar) * value_scale) + 1; + num_samples = recording.getSampleCount(*mEventFloatp); } } else @@ -391,17 +421,29 @@ void LLStatBar::draw() end = ((recording.getSum(*mCountIntp) - mMinBar) * value_scale) + 1; num_samples = recording.getSampleCount(*mCountIntp); } - else if (mMeasurementFloatp) + else if (mEventFloatp) + { + begin = ((recording.getMean(*mEventFloatp) - mMinBar) * value_scale); + end = ((recording.getMean(*mEventFloatp) - mMinBar) * value_scale) + 1; + num_samples = recording.getSampleCount(*mEventFloatp); + } + else if (mEventIntp) + { + begin = ((recording.getMean(*mEventIntp) - mMinBar) * value_scale); + end = ((recording.getMean(*mEventIntp) - mMinBar) * value_scale) + 1; + num_samples = recording.getSampleCount(*mEventIntp); + } + else if (mSampleFloatp) { - begin = ((recording.getMean(*mMeasurementFloatp) - mMinBar) * value_scale); - end = ((recording.getMean(*mMeasurementFloatp) - mMinBar) * value_scale) + 1; - num_samples = recording.getSampleCount(*mMeasurementFloatp); + begin = ((recording.getMean(*mEventFloatp) - mMinBar) * value_scale); + end = ((recording.getMean(*mEventFloatp) - mMinBar) * value_scale) + 1; + num_samples = recording.getSampleCount(*mEventFloatp); } - else if (mMeasurementIntp) + else if (mSampleIntp) { - begin = ((recording.getMean(*mMeasurementIntp) - mMinBar) * value_scale); - end = ((recording.getMean(*mMeasurementIntp) - mMinBar) * value_scale) + 1; - num_samples = recording.getSampleCount(*mMeasurementIntp); + begin = ((recording.getMean(*mEventFloatp) - mMinBar) * value_scale); + end = ((recording.getMean(*mEventFloatp) - mMinBar) * value_scale) + 1; + num_samples = recording.getSampleCount(*mEventFloatp); } } @@ -461,8 +503,10 @@ void LLStatBar::setStat(const std::string& stat_name) { mCountFloatp = LLTrace::CountStatHandle<>::getInstance(stat_name); mCountIntp = LLTrace::CountStatHandle::getInstance(stat_name); - mMeasurementFloatp = LLTrace::MeasurementStatHandle<>::getInstance(stat_name); - mMeasurementIntp = LLTrace::MeasurementStatHandle::getInstance(stat_name); + mEventFloatp = LLTrace::EventStatHandle<>::getInstance(stat_name); + mEventIntp = LLTrace::EventStatHandle::getInstance(stat_name); + mSampleFloatp = LLTrace::SampleStatHandle<>::getInstance(stat_name); + mSampleIntp = LLTrace::SampleStatHandle::getInstance(stat_name); } -- cgit v1.2.3 From 233201f8227f92e93061d3e2393a17b42dfa3dd1 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Sun, 2 Jun 2013 22:49:17 -0700 Subject: SH-3931 WIP Interesting: Add graphs to visualize scene load metrics removed unnecessary templates from accumulator types...now always track data in double precision floating point, using templated accessors to convert to and from arbitrary types --- indra/llui/llstatbar.cpp | 170 +++++++++++++---------------------------------- 1 file changed, 46 insertions(+), 124 deletions(-) (limited to 'indra/llui/llstatbar.cpp') diff --git a/indra/llui/llstatbar.cpp b/indra/llui/llstatbar.cpp index 22ca90df7a..6966df8213 100644 --- a/indra/llui/llstatbar.cpp +++ b/indra/llui/llstatbar.cpp @@ -97,9 +97,9 @@ BOOL LLStatBar::handleMouseDown(S32 x, S32 y, MASK mask) void LLStatBar::draw() { F32 current = 0.f, - min = 0.f, - max = 0.f, - mean = 0.f; + min = 0.f, + max = 0.f, + mean = 0.f; LLTrace::PeriodicRecording& frame_recording = LLTrace::get_frame_recording(); @@ -110,35 +110,16 @@ void LLStatBar::draw() if (mPerSec) { current = last_frame_recording.getPerSec(*mCountFloatp); - min = frame_recording.getPeriodMinPerSec(*mCountFloatp, mNumFrames); - max = frame_recording.getPeriodMaxPerSec(*mCountFloatp, mNumFrames); - mean = frame_recording.getPeriodMeanPerSec(*mCountFloatp, mNumFrames); + min = frame_recording.getPeriodMinPerSec(*mCountFloatp, mNumFrames); + max = frame_recording.getPeriodMaxPerSec(*mCountFloatp, mNumFrames); + mean = frame_recording.getPeriodMeanPerSec(*mCountFloatp, mNumFrames); } else { current = last_frame_recording.getSum(*mCountFloatp); - min = frame_recording.getPeriodMin(*mCountFloatp, mNumFrames); - max = frame_recording.getPeriodMax(*mCountFloatp, mNumFrames); - mean = frame_recording.getPeriodMean(*mCountFloatp, mNumFrames); - } - } - else if (mCountIntp) - { - LLTrace::Recording& last_frame_recording = frame_recording.getLastRecording(); - - if (mPerSec) - { - current = last_frame_recording.getPerSec(*mCountIntp); - min = frame_recording.getPeriodMinPerSec(*mCountIntp, mNumFrames); - max = frame_recording.getPeriodMaxPerSec(*mCountIntp, mNumFrames); - mean = frame_recording.getPeriodMeanPerSec(*mCountIntp, mNumFrames); - } - else - { - current = last_frame_recording.getSum(*mCountIntp); - min = frame_recording.getPeriodMin(*mCountIntp, mNumFrames); - max = frame_recording.getPeriodMax(*mCountIntp, mNumFrames); - mean = frame_recording.getPeriodMean(*mCountIntp, mNumFrames); + min = frame_recording.getPeriodMin(*mCountFloatp, mNumFrames); + max = frame_recording.getPeriodMax(*mCountFloatp, mNumFrames); + mean = frame_recording.getPeriodMean(*mCountFloatp, mNumFrames); } } else if (mEventFloatp) @@ -146,42 +127,24 @@ void LLStatBar::draw() LLTrace::Recording& last_frame_recording = frame_recording.getLastRecording(); current = last_frame_recording.getMean(*mEventFloatp); - min = frame_recording.getPeriodMin(*mEventFloatp, mNumFrames); - max = frame_recording.getPeriodMax(*mEventFloatp, mNumFrames); - mean = frame_recording.getPeriodMean(*mEventFloatp, mNumFrames); - } - else if (mEventIntp) - { - LLTrace::Recording& last_frame_recording = frame_recording.getLastRecording(); - - current = last_frame_recording.getLastValue(*mEventIntp); - min = frame_recording.getPeriodMin(*mEventIntp, mNumFrames); - max = frame_recording.getPeriodMax(*mEventIntp, mNumFrames); - mean = frame_recording.getPeriodMean(*mEventIntp, mNumFrames); + min = frame_recording.getPeriodMin(*mEventFloatp, mNumFrames); + max = frame_recording.getPeriodMax(*mEventFloatp, mNumFrames); + mean = frame_recording.getPeriodMean(*mEventFloatp, mNumFrames); } else if (mSampleFloatp) { LLTrace::Recording& last_frame_recording = frame_recording.getLastRecording(); current = last_frame_recording.getLastValue(*mSampleFloatp); - min = frame_recording.getPeriodMin(*mSampleFloatp, mNumFrames); - max = frame_recording.getPeriodMax(*mSampleFloatp, mNumFrames); - mean = frame_recording.getPeriodMean(*mSampleFloatp, mNumFrames); - } - else if (mSampleIntp) - { - LLTrace::Recording& last_frame_recording = frame_recording.getLastRecording(); - - current = last_frame_recording.getLastValue(*mSampleIntp); - min = frame_recording.getPeriodMin(*mSampleIntp, mNumFrames); - max = frame_recording.getPeriodMax(*mSampleIntp, mNumFrames); - mean = frame_recording.getPeriodMean(*mSampleIntp, mNumFrames); + min = frame_recording.getPeriodMin(*mSampleFloatp, mNumFrames); + max = frame_recording.getPeriodMax(*mSampleFloatp, mNumFrames); + mean = frame_recording.getPeriodMean(*mSampleFloatp, mNumFrames); } current *= mUnitScale; - min *= mUnitScale; - max *= mUnitScale; - mean *= mUnitScale; + min *= mUnitScale; + max *= mUnitScale; + mean *= mUnitScale; if ((mUpdatesPerSec == 0.f) || (mUpdateTimer.getElapsedTimeF32() > 1.f/mUpdatesPerSec) || (mValue == 0.f)) { @@ -199,16 +162,16 @@ void LLStatBar::draw() S32 bar_top, bar_left, bar_right, bar_bottom; if (mOrientation == HORIZONTAL) { - bar_top = llmax(5, getRect().getHeight() - 15); - bar_left = 0; - bar_right = getRect().getWidth() - 40; + bar_top = llmax(5, getRect().getHeight() - 15); + bar_left = 0; + bar_right = getRect().getWidth() - 40; bar_bottom = llmin(bar_top - 5, 0); } else // VERTICAL { - bar_top = llmax(5, getRect().getHeight() - 15); - bar_left = 0; - bar_right = getRect().getWidth(); + bar_top = llmax(5, getRect().getHeight() - 15); + bar_left = 0; + bar_right = getRect().getWidth(); bar_bottom = llmin(bar_top - 5, 20); } const S32 tick_length = 4; @@ -263,7 +226,7 @@ void LLStatBar::draw() } value_format = llformat( "%%.%df", mPrecision); - if (mDisplayBar && (mCountFloatp || mCountIntp || mEventFloatp || mEventIntp || mSampleFloatp || mSampleIntp)) + if (mDisplayBar && (mCountFloatp || mEventFloatp || mSampleFloatp)) { std::string tick_label; @@ -272,7 +235,7 @@ void LLStatBar::draw() gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); S32 last_tick = 0; S32 last_label = 0; - const S32 MIN_TICK_SPACING = mOrientation == HORIZONTAL ? 20 : 30; + const S32 MIN_TICK_SPACING = mOrientation == HORIZONTAL ? 20 : 30; const S32 MIN_LABEL_SPACING = mOrientation == HORIZONTAL ? 40 : 60; for (F32 tick_value = mMinBar + mTickSpacing; tick_value <= mCurMaxBar; tick_value += mTickSpacing) { @@ -350,7 +313,7 @@ void LLStatBar::draw() ? (bar_right - bar_left) : (bar_top - bar_bottom); - if (mDisplayHistory && (mCountFloatp || mCountIntp || mEventFloatp || mEventIntp || mSampleFloatp || mSampleIntp)) + if (mDisplayHistory && (mCountFloatp || mEventFloatp || mSampleFloatp)) { const S32 num_values = frame_recording.getNumPeriods() - 1; F32 begin = 0; @@ -368,42 +331,22 @@ void LLStatBar::draw() { if (mCountFloatp) { - begin = ((recording.getPerSec(*mCountFloatp) - mMinBar) * value_scale); - end = ((recording.getPerSec(*mCountFloatp) - mMinBar) * value_scale) + 1; + begin = ((recording.getPerSec(*mCountFloatp) - mMinBar) * value_scale); + end = ((recording.getPerSec(*mCountFloatp) - mMinBar) * value_scale) + 1; num_samples = recording.getSampleCount(*mCountFloatp); } - else if (mCountIntp) - { - begin = ((recording.getPerSec(*mCountIntp) - mMinBar) * value_scale); - end = ((recording.getPerSec(*mCountIntp) - mMinBar) * value_scale) + 1; - num_samples = recording.getSampleCount(*mCountIntp); - } else if (mEventFloatp) { //rate isn't defined for measurement stats, so use mean - begin = ((recording.getMean(*mEventFloatp) - mMinBar) * value_scale); - end = ((recording.getMean(*mEventFloatp) - mMinBar) * value_scale) + 1; + begin = ((recording.getMean(*mEventFloatp) - mMinBar) * value_scale); + end = ((recording.getMean(*mEventFloatp) - mMinBar) * value_scale) + 1; num_samples = recording.getSampleCount(*mEventFloatp); } - else if (mEventIntp) - { - //rate isn't defined for measurement stats, so use mean - begin = ((recording.getMean(*mEventIntp) - mMinBar) * value_scale); - end = ((recording.getMean(*mEventIntp) - mMinBar) * value_scale) + 1; - num_samples = recording.getSampleCount(*mEventIntp); - } else if (mSampleFloatp) { //rate isn't defined for sample stats, so use mean - begin = ((recording.getMean(*mEventFloatp) - mMinBar) * value_scale); - end = ((recording.getMean(*mEventFloatp) - mMinBar) * value_scale) + 1; - num_samples = recording.getSampleCount(*mEventFloatp); - } - else if (mSampleIntp) - { - //rate isn't defined for sample stats, so use mean - begin = ((recording.getMean(*mEventFloatp) - mMinBar) * value_scale); - end = ((recording.getMean(*mEventFloatp) - mMinBar) * value_scale) + 1; + begin = ((recording.getMean(*mEventFloatp) - mMinBar) * value_scale); + end = ((recording.getMean(*mEventFloatp) - mMinBar) * value_scale) + 1; num_samples = recording.getSampleCount(*mEventFloatp); } } @@ -411,41 +354,23 @@ void LLStatBar::draw() { if (mCountFloatp) { - begin = ((recording.getSum(*mCountFloatp) - mMinBar) * value_scale); - end = ((recording.getSum(*mCountFloatp) - mMinBar) * value_scale) + 1; + begin = ((recording.getSum(*mCountFloatp) - mMinBar) * value_scale); + end = ((recording.getSum(*mCountFloatp) - mMinBar) * value_scale) + 1; num_samples = recording.getSampleCount(*mCountFloatp); } - else if (mCountIntp) - { - begin = ((recording.getSum(*mCountIntp) - mMinBar) * value_scale); - end = ((recording.getSum(*mCountIntp) - mMinBar) * value_scale) + 1; - num_samples = recording.getSampleCount(*mCountIntp); - } else if (mEventFloatp) { - begin = ((recording.getMean(*mEventFloatp) - mMinBar) * value_scale); - end = ((recording.getMean(*mEventFloatp) - mMinBar) * value_scale) + 1; + begin = ((recording.getMean(*mEventFloatp) - mMinBar) * value_scale); + end = ((recording.getMean(*mEventFloatp) - mMinBar) * value_scale) + 1; num_samples = recording.getSampleCount(*mEventFloatp); } - else if (mEventIntp) - { - begin = ((recording.getMean(*mEventIntp) - mMinBar) * value_scale); - end = ((recording.getMean(*mEventIntp) - mMinBar) * value_scale) + 1; - num_samples = recording.getSampleCount(*mEventIntp); - } else if (mSampleFloatp) { - begin = ((recording.getMean(*mEventFloatp) - mMinBar) * value_scale); - end = ((recording.getMean(*mEventFloatp) - mMinBar) * value_scale) + 1; + begin = ((recording.getMean(*mEventFloatp) - mMinBar) * value_scale); + end = ((recording.getMean(*mEventFloatp) - mMinBar) * value_scale) + 1; num_samples = recording.getSampleCount(*mEventFloatp); } - else if (mSampleIntp) - { - begin = ((recording.getMean(*mEventFloatp) - mMinBar) * value_scale); - end = ((recording.getMean(*mEventFloatp) - mMinBar) * value_scale) + 1; - num_samples = recording.getSampleCount(*mEventFloatp); - } - } + } if (!num_samples) continue; @@ -501,20 +426,17 @@ void LLStatBar::draw() void LLStatBar::setStat(const std::string& stat_name) { - mCountFloatp = LLTrace::CountStatHandle<>::getInstance(stat_name); - mCountIntp = LLTrace::CountStatHandle::getInstance(stat_name); - mEventFloatp = LLTrace::EventStatHandle<>::getInstance(stat_name); - mEventIntp = LLTrace::EventStatHandle::getInstance(stat_name); - mSampleFloatp = LLTrace::SampleStatHandle<>::getInstance(stat_name); - mSampleIntp = LLTrace::SampleStatHandle::getInstance(stat_name); + mCountFloatp = LLTrace::TraceType::getInstance(stat_name); + mEventFloatp = LLTrace::TraceType::getInstance(stat_name); + mSampleFloatp = LLTrace::TraceType::getInstance(stat_name); } void LLStatBar::setRange(F32 bar_min, F32 bar_max, F32 tick_spacing) { - mMinBar = bar_min; - mMaxBar = bar_max; - mTickSpacing = tick_spacing; + mMinBar = bar_min; + mMaxBar = bar_max; + mTickSpacing = tick_spacing; } LLRect LLStatBar::getRequiredRect() -- 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/llui/llstatbar.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'indra/llui/llstatbar.cpp') diff --git a/indra/llui/llstatbar.cpp b/indra/llui/llstatbar.cpp index 6966df8213..d3cc2733e6 100755 --- a/indra/llui/llstatbar.cpp +++ b/indra/llui/llstatbar.cpp @@ -284,7 +284,7 @@ void LLStatBar::draw() // draw background bar. gl_rect_2d(bar_left, bar_top, bar_right, bar_bottom, LLColor4(0.f, 0.f, 0.f, 0.25f)); - if (frame_recording.getNumPeriods() == 0) + if (frame_recording.getNumRecordedPeriods() == 0) { // No data, don't draw anything... return; @@ -315,7 +315,7 @@ void LLStatBar::draw() if (mDisplayHistory && (mCountFloatp || mEventFloatp || mSampleFloatp)) { - const S32 num_values = frame_recording.getNumPeriods() - 1; + const S32 num_values = frame_recording.getNumRecordedPeriods() - 1; F32 begin = 0; F32 end = 0; S32 i; -- 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/llui/llstatbar.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'indra/llui/llstatbar.cpp') diff --git a/indra/llui/llstatbar.cpp b/indra/llui/llstatbar.cpp index d3cc2733e6..fd88565de4 100755 --- a/indra/llui/llstatbar.cpp +++ b/indra/llui/llstatbar.cpp @@ -345,9 +345,9 @@ void LLStatBar::draw() else if (mSampleFloatp) { //rate isn't defined for sample stats, so use mean - begin = ((recording.getMean(*mEventFloatp) - mMinBar) * value_scale); - end = ((recording.getMean(*mEventFloatp) - mMinBar) * value_scale) + 1; - num_samples = recording.getSampleCount(*mEventFloatp); + begin = ((recording.getMean(*mSampleFloatp) - mMinBar) * value_scale); + end = ((recording.getMean(*mSampleFloatp) - mMinBar) * value_scale) + 1; + num_samples = recording.getSampleCount(*mSampleFloatp); } } else @@ -366,9 +366,9 @@ void LLStatBar::draw() } else if (mSampleFloatp) { - begin = ((recording.getMean(*mEventFloatp) - mMinBar) * value_scale); - end = ((recording.getMean(*mEventFloatp) - mMinBar) * value_scale) + 1; - num_samples = recording.getSampleCount(*mEventFloatp); + begin = ((recording.getMean(*mSampleFloatp) - mMinBar) * value_scale); + end = ((recording.getMean(*mSampleFloatp) - mMinBar) * value_scale) + 1; + num_samples = recording.getSampleCount(*mSampleFloatp); } } -- cgit v1.2.3 From d122318bef2ff0eced7641dc24f411f792bd2935 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Mon, 8 Jul 2013 00:55:17 -0700 Subject: SH-4299 WIP: Interesting: High fps shown temporarily off scale in statistics console added percentage/ratio units added auto-range and auto tick calculation to stat bar to automate display stats --- indra/llui/llstatbar.cpp | 301 ++++++++++++++++++++++++++++++----------------- 1 file changed, 192 insertions(+), 109 deletions(-) (limited to 'indra/llui/llstatbar.cpp') diff --git a/indra/llui/llstatbar.cpp b/indra/llui/llstatbar.cpp index fd88565de4..46e15af66e 100755 --- a/indra/llui/llstatbar.cpp +++ b/indra/llui/llstatbar.cpp @@ -37,32 +37,137 @@ #include "lluictrlfactory.h" #include "lltracerecording.h" #include "llcriticaldamp.h" +#include "lltooltip.h" +#include + +F32 calc_reasonable_tick_value(F32 min, F32 max) +{ + F32 range = max - min; + const S32 DIVISORS[] = {6, 8, 10, 4, 5}; + // try storing + S32 best_decimal_digit_count = S32_MAX; + S32 best_divisor = 10; + for (U32 divisor_idx = 0; divisor_idx < LL_ARRAY_SIZE(DIVISORS); divisor_idx++) + { + S32 divisor = DIVISORS[divisor_idx]; + F32 possible_tick_value = range / divisor; + S32 num_whole_digits = llceil(logf(min + possible_tick_value) * OO_LN10); + for (S32 digit_count = -(num_whole_digits - 1); digit_count < 6; digit_count++) + { + F32 test_tick_value = min + (possible_tick_value * pow(10.0, digit_count)); + + if (is_approx_equal((F32)(S32)test_tick_value, (F32)test_tick_value)) + { + if (digit_count < best_decimal_digit_count) + { + best_decimal_digit_count = digit_count; + best_divisor = divisor; + } + break; + } + } + } + + return is_approx_equal(range, 0.f) ? 1.f : range / best_divisor; +} + +void calc_display_range(F32& min, F32& max) +{ + const F32 RANGES[] = {1.f, 1.5f, 2.f, 3.f, 5.f, 10.f}; + + const S32 num_digits_max = is_approx_equal(fabs(max), 0.f) + ? S32_MIN + 1 + : llceil(logf(fabs(max)) * OO_LN10); + const S32 num_digits_min = is_approx_equal(fabs(min), 0.f) + ? S32_MIN + 1 + : llceil(logf(fabs(min)) * OO_LN10); + + const S32 num_digits = llmax(num_digits_max, num_digits_min); + const F32 starting_max = pow(10.0, num_digits - 1) * ((max < 0.f) ? -1 : 1); + const F32 starting_min = pow(10.0, num_digits - 1) * ((min < 0.f) ? -1 : 1); + + F32 new_max = starting_max; + F32 new_min = starting_min; + F32 out_max = max; + F32 out_min = min; + + for (S32 range_idx = 0; range_idx < LL_ARRAY_SIZE(RANGES); range_idx++) + { + new_max = starting_max * RANGES[range_idx]; + new_min = starting_min * RANGES[range_idx]; + + if (min > 0.f && new_min < min) + { + out_min = new_min; + } + if (max < 0.f && new_max > max) + { + out_max = new_max; + } + } + + new_max = starting_max; + new_min = starting_min; + for (S32 range_idx = LL_ARRAY_SIZE(RANGES) - 1; range_idx >= 0; range_idx--) + { + new_max = starting_max * RANGES[range_idx]; + new_min = starting_min * RANGES[range_idx]; + + if (min < 0.f && new_min < min) + { + out_min = new_min; + } + if (max > 0.f && new_max > max) + { + out_max = new_max; + } + } + + min = out_min; + max = out_max; +} /////////////////////////////////////////////////////////////////////////////////// LLStatBar::LLStatBar(const Params& p) - : LLView(p), - mLabel(p.label), - mUnitLabel(p.unit_label), - mMinBar(p.bar_min), - mMaxBar(p.bar_max), - mCurMaxBar(p.bar_max), - mTickSpacing(p.tick_spacing), - mPrecision(p.precision), - mUpdatesPerSec(p.update_rate), - mUnitScale(p.unit_scale), - mNumFrames(p.num_frames), - mMaxHeight(p.max_height), - mPerSec(p.show_per_sec), - mDisplayBar(p.show_bar), - mDisplayHistory(p.show_history), - mDisplayMean(p.show_mean), - mOrientation(p.orientation), - mScaleRange(p.scale_range) +: LLView(p), + mLabel(p.label), + mUnitLabel(p.unit_label), + mMinBar(p.bar_min), + mMaxBar(p.bar_max), + mCurMaxBar(p.bar_max), + mTickValue(p.tick_spacing.isProvided() ? p.tick_spacing : calc_reasonable_tick_value(p.bar_min, p.bar_max)), + mDecimalDigits(p.decimal_digits), + mNumFrames(p.num_frames), + mMaxHeight(p.max_height), + mPerSec(p.show_per_sec), + mDisplayBar(p.show_bar), + mDisplayHistory(p.show_history), + mDisplayMean(p.show_mean), + mOrientation(p.orientation), + mScaleMax(!p.bar_max.isProvided()), + mScaleMin(!p.bar_min.isProvided()) { setStat(p.stat); } +BOOL LLStatBar::handleHover(S32 x, S32 y, MASK mask) +{ + if (mCountFloatp) + { + LLToolTipMgr::instance().show(LLToolTip::Params().message(mCountFloatp->getDescription()).sticky_rect(calcScreenRect())); + } + else if ( mEventFloatp) + { + LLToolTipMgr::instance().show(LLToolTip::Params().message(mEventFloatp->getDescription()).sticky_rect(calcScreenRect())); + } + else if (mSampleFloatp) + { + LLToolTipMgr::instance().show(LLToolTip::Params().message(mSampleFloatp->getDescription()).sticky_rect(calcScreenRect())); + } + return TRUE; +} + BOOL LLStatBar::handleMouseDown(S32 x, S32 y, MASK mask) { BOOL handled = LLView::handleMouseDown(x, y, mask); @@ -96,23 +201,27 @@ BOOL LLStatBar::handleMouseDown(S32 x, S32 y, MASK mask) void LLStatBar::draw() { - F32 current = 0.f, - min = 0.f, - max = 0.f, - mean = 0.f; + F32 current = 0, + min = 0, + max = 0, + mean = 0, + value = 0; LLTrace::PeriodicRecording& frame_recording = LLTrace::get_frame_recording(); + std::string unit_label; if (mCountFloatp) { LLTrace::Recording& last_frame_recording = frame_recording.getLastRecording(); - + unit_label = mUnitLabel.empty() ? mCountFloatp->getUnitLabel() : mUnitLabel; if (mPerSec) { + unit_label += "/s"; current = last_frame_recording.getPerSec(*mCountFloatp); min = frame_recording.getPeriodMinPerSec(*mCountFloatp, mNumFrames); max = frame_recording.getPeriodMaxPerSec(*mCountFloatp, mNumFrames); mean = frame_recording.getPeriodMeanPerSec(*mCountFloatp, mNumFrames); + value = mDisplayMean ? mean : current; } else { @@ -120,43 +229,30 @@ void LLStatBar::draw() min = frame_recording.getPeriodMin(*mCountFloatp, mNumFrames); max = frame_recording.getPeriodMax(*mCountFloatp, mNumFrames); mean = frame_recording.getPeriodMean(*mCountFloatp, mNumFrames); + value = mDisplayMean ? mean : current; } } else if (mEventFloatp) { LLTrace::Recording& last_frame_recording = frame_recording.getLastRecording(); + unit_label = mUnitLabel.empty() ? mEventFloatp->getUnitLabel() : mUnitLabel; current = last_frame_recording.getMean(*mEventFloatp); min = frame_recording.getPeriodMin(*mEventFloatp, mNumFrames); max = frame_recording.getPeriodMax(*mEventFloatp, mNumFrames); mean = frame_recording.getPeriodMean(*mEventFloatp, mNumFrames); + value = mDisplayMean ? mean : current; } else if (mSampleFloatp) { LLTrace::Recording& last_frame_recording = frame_recording.getLastRecording(); + unit_label = mUnitLabel.empty() ? mSampleFloatp->getUnitLabel() : mUnitLabel; current = last_frame_recording.getLastValue(*mSampleFloatp); min = frame_recording.getPeriodMin(*mSampleFloatp, mNumFrames); max = frame_recording.getPeriodMax(*mSampleFloatp, mNumFrames); mean = frame_recording.getPeriodMean(*mSampleFloatp, mNumFrames); - } - - current *= mUnitScale; - min *= mUnitScale; - max *= mUnitScale; - mean *= mUnitScale; - - if ((mUpdatesPerSec == 0.f) || (mUpdateTimer.getElapsedTimeF32() > 1.f/mUpdatesPerSec) || (mValue == 0.f)) - { - if (mDisplayMean) - { - mValue = mean; - } - else - { - mValue = current; - } - mUpdateTimer.reset(); + value = mDisplayMean ? mean : current; } S32 bar_top, bar_left, bar_right, bar_bottom; @@ -177,39 +273,40 @@ void LLStatBar::draw() const S32 tick_length = 4; const S32 tick_width = 1; - if (mScaleRange && min < max) + if ((mScaleMax && max >= mCurMaxBar)|| (mScaleMin && min <= mCurMinBar)) { - F32 cur_max = mTickSpacing; - while(max > cur_max && mMaxBar > cur_max) - { - cur_max += mTickSpacing; - } - mCurMaxBar = LLSmoothInterpolation::lerp(mCurMaxBar, cur_max, 0.05f); + F32 range_min = min; + F32 range_max = max; + calc_display_range(range_min, range_max); + if (mScaleMax) { mMaxBar = llmax(mMaxBar, range_max); } + if (mScaleMin) { mMinBar = llmin(mMinBar, range_min); } + mTickValue = calc_reasonable_tick_value(mMinBar, mMaxBar); + + } + mCurMaxBar = LLSmoothInterpolation::lerp(mCurMaxBar, mMaxBar, 0.05f); + mCurMinBar = LLSmoothInterpolation::lerp(mCurMinBar, mMinBar, 0.05f); + + F32 value_scale; + if (mCurMaxBar == mCurMinBar) + { + value_scale = 0.f; } else { - mCurMaxBar = mMaxBar; + value_scale = (mOrientation == HORIZONTAL) + ? (bar_top - bar_bottom)/(mCurMaxBar - mCurMinBar) + : (bar_right - bar_left)/(mCurMaxBar - mCurMinBar); } - F32 value_scale = (mOrientation == HORIZONTAL) - ? (bar_top - bar_bottom)/(mCurMaxBar - mMinBar) - : (bar_right - bar_left)/(mCurMaxBar - mMinBar); - LLFontGL::getFontMonospace()->renderUTF8(mLabel, 0, 0, getRect().getHeight(), LLColor4(1.f, 1.f, 1.f, 1.f), LLFontGL::LEFT, LLFontGL::TOP); - - std::string value_format; - std::string value_str; - if (!mUnitLabel.empty()) - { - value_format = llformat( "%%.%df%%s", mPrecision); - value_str = llformat( value_format.c_str(), mValue, mUnitLabel.c_str()); - } - else + + S32 decimal_digits = mDecimalDigits; + if (is_approx_equal((F32)(S32)value, value)) { - value_format = llformat( "%%.%df", mPrecision); - value_str = llformat( value_format.c_str(), mValue); + decimal_digits = 0; } + std::string value_str = llformat("%10.*f %s", decimal_digits, value, unit_label.c_str()); // Draw the value. if (mOrientation == HORIZONTAL) @@ -225,11 +322,8 @@ void LLStatBar::draw() LLFontGL::RIGHT, LLFontGL::TOP); } - value_format = llformat( "%%.%df", mPrecision); if (mDisplayBar && (mCountFloatp || mEventFloatp || mSampleFloatp)) { - std::string tick_label; - // Draw the tick marks. LLGLSUIDefault gls_ui; gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); @@ -237,9 +331,10 @@ void LLStatBar::draw() S32 last_label = 0; const S32 MIN_TICK_SPACING = mOrientation == HORIZONTAL ? 20 : 30; const S32 MIN_LABEL_SPACING = mOrientation == HORIZONTAL ? 40 : 60; - for (F32 tick_value = mMinBar + mTickSpacing; tick_value <= mCurMaxBar; tick_value += mTickSpacing) + // start counting from actual min, not current, animating min, so that ticks don't float between numbers + for (F32 tick_value = mMinBar; tick_value <= mCurMaxBar; tick_value += mTickValue) { - const S32 begin = llfloor((tick_value - mMinBar)*value_scale); + const S32 begin = llfloor((tick_value - mCurMinBar)*value_scale); const S32 end = begin + tick_width; if (begin - last_tick < MIN_TICK_SPACING) { @@ -247,14 +342,19 @@ void LLStatBar::draw() } last_tick = begin; - tick_label = llformat( value_format.c_str(), tick_value); + S32 decimal_digits = mDecimalDigits; + if (is_approx_equal((F32)(S32)tick_value, tick_value)) + { + decimal_digits = 0; + } + std::string tick_string = llformat("%10.*f", decimal_digits, tick_value); if (mOrientation == HORIZONTAL) { if (begin - last_label > MIN_LABEL_SPACING) { gl_rect_2d(bar_left, end, bar_right - tick_length, begin, LLColor4(1.f, 1.f, 1.f, 0.25f)); - LLFontGL::getFontMonospace()->renderUTF8(tick_label, 0, bar_right, begin, + LLFontGL::getFontMonospace()->renderUTF8(tick_string, 0, bar_right, begin, LLColor4(1.f, 1.f, 1.f, 0.5f), LLFontGL::LEFT, LLFontGL::VCENTER); last_label = begin; @@ -269,7 +369,7 @@ void LLStatBar::draw() if (begin - last_label > MIN_LABEL_SPACING) { gl_rect_2d(begin, bar_top, end, bar_bottom - tick_length, LLColor4(1.f, 1.f, 1.f, 0.25f)); - LLFontGL::getFontMonospace()->renderUTF8(tick_label, 0, begin - 1, bar_bottom - tick_length, + LLFontGL::getFontMonospace()->renderUTF8(tick_string, 0, begin - 1, bar_bottom - tick_length, LLColor4(1.f, 1.f, 1.f, 0.5f), LLFontGL::RIGHT, LLFontGL::TOP); last_label = begin; @@ -291,7 +391,7 @@ void LLStatBar::draw() } // draw min and max - S32 begin = (S32) ((min - mMinBar) * value_scale); + S32 begin = (S32) ((min - mCurMinBar) * value_scale); if (begin < 0) { @@ -299,7 +399,7 @@ void LLStatBar::draw() llwarns << "Min:" << min << llendl; } - S32 end = (S32) ((max - mMinBar) * value_scale); + S32 end = (S32) ((max - mCurMinBar) * value_scale); if (mOrientation == HORIZONTAL) { gl_rect_2d(bar_left, end, bar_right, begin, LLColor4(1.f, 0.f, 0.f, 0.25f)); @@ -327,47 +427,30 @@ void LLStatBar::draw() { F32 offset = ((F32)i / (F32)mNumFrames) * span; LLTrace::Recording& recording = frame_recording.getPrevRecording(i); - if (mPerSec) + if (mPerSec && mCountFloatp) { - if (mCountFloatp) - { - begin = ((recording.getPerSec(*mCountFloatp) - mMinBar) * value_scale); - end = ((recording.getPerSec(*mCountFloatp) - mMinBar) * value_scale) + 1; - num_samples = recording.getSampleCount(*mCountFloatp); - } - else if (mEventFloatp) - { - //rate isn't defined for measurement stats, so use mean - begin = ((recording.getMean(*mEventFloatp) - mMinBar) * value_scale); - end = ((recording.getMean(*mEventFloatp) - mMinBar) * value_scale) + 1; - num_samples = recording.getSampleCount(*mEventFloatp); - } - else if (mSampleFloatp) - { - //rate isn't defined for sample stats, so use mean - begin = ((recording.getMean(*mSampleFloatp) - mMinBar) * value_scale); - end = ((recording.getMean(*mSampleFloatp) - mMinBar) * value_scale) + 1; - num_samples = recording.getSampleCount(*mSampleFloatp); - } + begin = ((recording.getPerSec(*mCountFloatp) - mCurMinBar) * value_scale); + end = ((recording.getPerSec(*mCountFloatp) - mCurMinBar) * value_scale) + 1; + num_samples = recording.getSampleCount(*mCountFloatp); } else { if (mCountFloatp) { - begin = ((recording.getSum(*mCountFloatp) - mMinBar) * value_scale); - end = ((recording.getSum(*mCountFloatp) - mMinBar) * value_scale) + 1; + begin = ((recording.getSum(*mCountFloatp) - mCurMinBar) * value_scale); + end = ((recording.getSum(*mCountFloatp) - mCurMinBar) * value_scale) + 1; num_samples = recording.getSampleCount(*mCountFloatp); } else if (mEventFloatp) { - begin = ((recording.getMean(*mEventFloatp) - mMinBar) * value_scale); - end = ((recording.getMean(*mEventFloatp) - mMinBar) * value_scale) + 1; + begin = ((recording.getMean(*mEventFloatp) - mCurMinBar) * value_scale); + end = ((recording.getMean(*mEventFloatp) - mCurMinBar) * value_scale) + 1; num_samples = recording.getSampleCount(*mEventFloatp); } else if (mSampleFloatp) { - begin = ((recording.getMean(*mSampleFloatp) - mMinBar) * value_scale); - end = ((recording.getMean(*mSampleFloatp) - mMinBar) * value_scale) + 1; + begin = ((recording.getMean(*mSampleFloatp) - mCurMinBar) * value_scale); + end = ((recording.getMean(*mSampleFloatp) - mCurMinBar) * value_scale) + 1; num_samples = recording.getSampleCount(*mSampleFloatp); } } @@ -393,8 +476,8 @@ void LLStatBar::draw() } else { - S32 begin = (S32) ((current - mMinBar) * value_scale) - 1; - S32 end = (S32) ((current - mMinBar) * value_scale) + 1; + S32 begin = (S32) ((current - mCurMinBar) * value_scale) - 1; + S32 end = (S32) ((current - mCurMinBar) * value_scale) + 1; // draw current if (mOrientation == HORIZONTAL) { @@ -408,8 +491,8 @@ void LLStatBar::draw() // draw mean bar { - const S32 begin = (S32) ((mean - mMinBar) * value_scale) - 1; - const S32 end = (S32) ((mean - mMinBar) * value_scale) + 1; + const S32 begin = (S32) ((mean - mCurMinBar) * value_scale) - 1; + const S32 end = (S32) ((mean - mCurMinBar) * value_scale) + 1; if (mOrientation == HORIZONTAL) { gl_rect_2d(bar_left - 2, begin, bar_right + 2, end, LLColor4(0.f, 1.f, 0.f, 1.f)); @@ -432,11 +515,11 @@ void LLStatBar::setStat(const std::string& stat_name) } -void LLStatBar::setRange(F32 bar_min, F32 bar_max, F32 tick_spacing) +void LLStatBar::setRange(F32 bar_min, F32 bar_max) { - mMinBar = bar_min; - mMaxBar = bar_max; - mTickSpacing = tick_spacing; + mMinBar = bar_min; + mMaxBar = bar_max; + mTickValue = calc_reasonable_tick_value(mMinBar, mMaxBar); } LLRect LLStatBar::getRequiredRect() -- cgit v1.2.3 From c95042db3e8d2f1a938e7d6e9ca625700d634639 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Fri, 12 Jul 2013 00:52:31 -0700 Subject: SH-4299 WIP: Interesting: High fps shown temporarily off scale in statistics console improved calculation of display range for stat bars --- indra/llui/llstatbar.cpp | 262 ++++++++++++++++++++++++++--------------------- 1 file changed, 144 insertions(+), 118 deletions(-) (limited to 'indra/llui/llstatbar.cpp') diff --git a/indra/llui/llstatbar.cpp b/indra/llui/llstatbar.cpp index 46e15af66e..a0a14f4610 100755 --- a/indra/llui/llstatbar.cpp +++ b/indra/llui/llstatbar.cpp @@ -38,9 +38,10 @@ #include "lltracerecording.h" #include "llcriticaldamp.h" #include "lltooltip.h" +#include "lllocalcliprect.h" #include -F32 calc_reasonable_tick_value(F32 min, F32 max) +F32 calc_tick_value(F32 min, F32 max) { F32 range = max - min; const S32 DIVISORS[] = {6, 8, 10, 4, 5}; @@ -56,7 +57,7 @@ F32 calc_reasonable_tick_value(F32 min, F32 max) { F32 test_tick_value = min + (possible_tick_value * pow(10.0, digit_count)); - if (is_approx_equal((F32)(S32)test_tick_value, (F32)test_tick_value)) + if (is_approx_equal((F32)(S32)test_tick_value, test_tick_value)) { if (digit_count < best_decimal_digit_count) { @@ -68,12 +69,16 @@ F32 calc_reasonable_tick_value(F32 min, F32 max) } } - return is_approx_equal(range, 0.f) ? 1.f : range / best_divisor; + return is_approx_equal(range, 0.f) ? 0.f : range / best_divisor; } -void calc_display_range(F32& min, F32& max) +void calc_auto_scale_range(F32& min, F32& max, F32& tick) { - const F32 RANGES[] = {1.f, 1.5f, 2.f, 3.f, 5.f, 10.f}; + min = llmin(0.f, min, max); + max = llmax(0.f, min, max); + + const F32 RANGES[] = {0.f, 1.f, 1.5f, 2.f, 3.f, 5.f, 10.f}; + const F32 TICKS[] = {0.f, 0.25f, 0.5f, 1.f, 1.f, 1.f, 2.f }; const S32 num_digits_max = is_approx_equal(fabs(max), 0.f) ? S32_MIN + 1 @@ -83,46 +88,55 @@ void calc_display_range(F32& min, F32& max) : llceil(logf(fabs(min)) * OO_LN10); const S32 num_digits = llmax(num_digits_max, num_digits_min); - const F32 starting_max = pow(10.0, num_digits - 1) * ((max < 0.f) ? -1 : 1); - const F32 starting_min = pow(10.0, num_digits - 1) * ((min < 0.f) ? -1 : 1); + const F32 power_of_10 = pow(10.0, num_digits - 1); + const F32 starting_max = power_of_10 * ((max < 0.f) ? -1 : 1); + const F32 starting_min = power_of_10 * ((min < 0.f) ? -1 : 1); - F32 new_max = starting_max; - F32 new_min = starting_min; + F32 cur_max = starting_max; + F32 cur_min = starting_min; F32 out_max = max; F32 out_min = min; + F32 cur_tick_min = 0.f; + F32 cur_tick_max = 0.f; + for (S32 range_idx = 0; range_idx < LL_ARRAY_SIZE(RANGES); range_idx++) { - new_max = starting_max * RANGES[range_idx]; - new_min = starting_min * RANGES[range_idx]; + cur_max = starting_max * RANGES[range_idx]; + cur_min = starting_min * RANGES[range_idx]; - if (min > 0.f && new_min < min) + if (min > 0.f && cur_min <= min) { - out_min = new_min; + out_min = cur_min; + cur_tick_min = TICKS[range_idx]; } - if (max < 0.f && new_max > max) + if (max < 0.f && cur_max >= max) { - out_max = new_max; + out_max = cur_max; + cur_tick_max = TICKS[range_idx]; } } - new_max = starting_max; - new_min = starting_min; + cur_max = starting_max; + cur_min = starting_min; for (S32 range_idx = LL_ARRAY_SIZE(RANGES) - 1; range_idx >= 0; range_idx--) { - new_max = starting_max * RANGES[range_idx]; - new_min = starting_min * RANGES[range_idx]; + cur_max = starting_max * RANGES[range_idx]; + cur_min = starting_min * RANGES[range_idx]; - if (min < 0.f && new_min < min) + if (min < 0.f && cur_min <= min) { - out_min = new_min; + out_min = cur_min; + cur_tick_min = TICKS[range_idx]; } - if (max > 0.f && new_max > max) + if (max > 0.f && cur_max >= max) { - out_max = new_max; + out_max = cur_max; + cur_tick_max = TICKS[range_idx]; } } + tick = power_of_10 * llmax(cur_tick_min, cur_tick_max); min = out_min; max = out_max; } @@ -133,21 +147,26 @@ LLStatBar::LLStatBar(const Params& p) : LLView(p), mLabel(p.label), mUnitLabel(p.unit_label), - mMinBar(p.bar_min), - mMaxBar(p.bar_max), + mMinBar(llmin(p.bar_min, p.bar_max)), + mMaxBar(llmax(p.bar_max, p.bar_min)), mCurMaxBar(p.bar_max), - mTickValue(p.tick_spacing.isProvided() ? p.tick_spacing : calc_reasonable_tick_value(p.bar_min, p.bar_max)), mDecimalDigits(p.decimal_digits), mNumFrames(p.num_frames), mMaxHeight(p.max_height), mPerSec(p.show_per_sec), mDisplayBar(p.show_bar), mDisplayHistory(p.show_history), - mDisplayMean(p.show_mean), mOrientation(p.orientation), - mScaleMax(!p.bar_max.isProvided()), - mScaleMin(!p.bar_min.isProvided()) + mAutoScaleMax(!p.bar_max.isProvided()), + mAutoScaleMin(!p.bar_min.isProvided()), + mTickValue(p.tick_spacing) { + // tick value will be automatically calculated later + if (!p.tick_spacing.isProvided() && p.bar_min.isProvided() && p.bar_max.isProvided()) + { + mTickValue = calc_tick_value(mMinBar, mMaxBar); + } + setStat(p.stat); } @@ -204,9 +223,9 @@ void LLStatBar::draw() F32 current = 0, min = 0, max = 0, - mean = 0, - value = 0; + mean = 0; + LLLocalClipRect _(getLocalRect()); LLTrace::PeriodicRecording& frame_recording = LLTrace::get_frame_recording(); std::string unit_label; @@ -221,7 +240,6 @@ void LLStatBar::draw() min = frame_recording.getPeriodMinPerSec(*mCountFloatp, mNumFrames); max = frame_recording.getPeriodMaxPerSec(*mCountFloatp, mNumFrames); mean = frame_recording.getPeriodMeanPerSec(*mCountFloatp, mNumFrames); - value = mDisplayMean ? mean : current; } else { @@ -229,7 +247,6 @@ void LLStatBar::draw() min = frame_recording.getPeriodMin(*mCountFloatp, mNumFrames); max = frame_recording.getPeriodMax(*mCountFloatp, mNumFrames); mean = frame_recording.getPeriodMean(*mCountFloatp, mNumFrames); - value = mDisplayMean ? mean : current; } } else if (mEventFloatp) @@ -241,18 +258,16 @@ void LLStatBar::draw() min = frame_recording.getPeriodMin(*mEventFloatp, mNumFrames); max = frame_recording.getPeriodMax(*mEventFloatp, mNumFrames); mean = frame_recording.getPeriodMean(*mEventFloatp, mNumFrames); - value = mDisplayMean ? mean : current; } else if (mSampleFloatp) { LLTrace::Recording& last_frame_recording = frame_recording.getLastRecording(); unit_label = mUnitLabel.empty() ? mSampleFloatp->getUnitLabel() : mUnitLabel; - current = last_frame_recording.getLastValue(*mSampleFloatp); + current = last_frame_recording.getMean(*mSampleFloatp); min = frame_recording.getPeriodMin(*mSampleFloatp, mNumFrames); max = frame_recording.getPeriodMax(*mSampleFloatp, mNumFrames); mean = frame_recording.getPeriodMean(*mSampleFloatp, mNumFrames); - value = mDisplayMean ? mean : current; } S32 bar_top, bar_left, bar_right, bar_bottom; @@ -273,16 +288,24 @@ void LLStatBar::draw() const S32 tick_length = 4; const S32 tick_width = 1; - if ((mScaleMax && max >= mCurMaxBar)|| (mScaleMin && min <= mCurMinBar)) + if ((mAutoScaleMax && max >= mCurMaxBar)|| (mAutoScaleMin && min <= mCurMinBar)) { - F32 range_min = min; - F32 range_max = max; - calc_display_range(range_min, range_max); - if (mScaleMax) { mMaxBar = llmax(mMaxBar, range_max); } - if (mScaleMin) { mMinBar = llmin(mMinBar, range_min); } - mTickValue = calc_reasonable_tick_value(mMinBar, mMaxBar); - + F32 range_min = mAutoScaleMin ? llmin(mMinBar, min) : mMinBar; + F32 range_max = mAutoScaleMax ? llmax(mMaxBar, max) : mMaxBar; + F32 tick_value = 0.f; + calc_auto_scale_range(range_min, range_max, tick_value); + if (mAutoScaleMin) { mMinBar = range_min; } + if (mAutoScaleMax) { mMaxBar = range_max; } + if (mAutoScaleMin && mAutoScaleMax) + { + mTickValue = tick_value; + } + else + { + mTickValue = calc_tick_value(mMinBar, mMaxBar); + } } + mCurMaxBar = LLSmoothInterpolation::lerp(mCurMaxBar, mMaxBar, 0.05f); mCurMinBar = LLSmoothInterpolation::lerp(mCurMinBar, mMinBar, 0.05f); @@ -302,13 +325,13 @@ void LLStatBar::draw() LLFontGL::LEFT, LLFontGL::TOP); S32 decimal_digits = mDecimalDigits; - if (is_approx_equal((F32)(S32)value, value)) + if (is_approx_equal((F32)(S32)mean, mean)) { decimal_digits = 0; } - std::string value_str = llformat("%10.*f %s", decimal_digits, value, unit_label.c_str()); + std::string value_str = llformat("%10.*f %s", decimal_digits, mean, unit_label.c_str()); - // Draw the value. + // Draw the current value. if (mOrientation == HORIZONTAL) { LLFontGL::getFontMonospace()->renderUTF8(value_str, 0, bar_right, getRect().getHeight(), @@ -330,53 +353,65 @@ void LLStatBar::draw() S32 last_tick = 0; S32 last_label = 0; const S32 MIN_TICK_SPACING = mOrientation == HORIZONTAL ? 20 : 30; - const S32 MIN_LABEL_SPACING = mOrientation == HORIZONTAL ? 40 : 60; + const S32 MIN_LABEL_SPACING = mOrientation == HORIZONTAL ? 30 : 60; // start counting from actual min, not current, animating min, so that ticks don't float between numbers - for (F32 tick_value = mMinBar; tick_value <= mCurMaxBar; tick_value += mTickValue) + // ensure ticks always hit 0 + if (mTickValue > 0.f) { - const S32 begin = llfloor((tick_value - mCurMinBar)*value_scale); - const S32 end = begin + tick_width; - if (begin - last_tick < MIN_TICK_SPACING) + F32 start = mCurMinBar < 0.f + ? llceil(-mCurMinBar / mTickValue) * -mTickValue + : 0.f; + for (F32 tick_value = start; ;tick_value += mTickValue) { - continue; - } - last_tick = begin; - - S32 decimal_digits = mDecimalDigits; - if (is_approx_equal((F32)(S32)tick_value, tick_value)) - { - decimal_digits = 0; - } - std::string tick_string = llformat("%10.*f", decimal_digits, tick_value); - - if (mOrientation == HORIZONTAL) - { - if (begin - last_label > MIN_LABEL_SPACING) + const S32 begin = llfloor((tick_value - mCurMinBar)*value_scale); + const S32 end = begin + tick_width; + if (begin - last_tick < MIN_TICK_SPACING) { - gl_rect_2d(bar_left, end, bar_right - tick_length, begin, LLColor4(1.f, 1.f, 1.f, 0.25f)); - LLFontGL::getFontMonospace()->renderUTF8(tick_string, 0, bar_right, begin, - LLColor4(1.f, 1.f, 1.f, 0.5f), - LLFontGL::LEFT, LLFontGL::VCENTER); - last_label = begin; + continue; } - else + last_tick = begin; + + S32 decimal_digits = mDecimalDigits; + if (is_approx_equal((F32)(S32)tick_value, tick_value)) { - gl_rect_2d(bar_left, end, bar_right - tick_length/2, begin, LLColor4(1.f, 1.f, 1.f, 0.1f)); + decimal_digits = 0; } - } - else - { - if (begin - last_label > MIN_LABEL_SPACING) + std::string tick_string = llformat("%10.*f", decimal_digits, tick_value); + + if (mOrientation == HORIZONTAL) { - gl_rect_2d(begin, bar_top, end, bar_bottom - tick_length, LLColor4(1.f, 1.f, 1.f, 0.25f)); - LLFontGL::getFontMonospace()->renderUTF8(tick_string, 0, begin - 1, bar_bottom - tick_length, - LLColor4(1.f, 1.f, 1.f, 0.5f), - LLFontGL::RIGHT, LLFontGL::TOP); - last_label = begin; + if (begin - last_label > MIN_LABEL_SPACING) + { + gl_rect_2d(bar_left, end, bar_right - tick_length, begin, LLColor4(1.f, 1.f, 1.f, 0.25f)); + LLFontGL::getFontMonospace()->renderUTF8(tick_string, 0, bar_right, begin, + LLColor4(1.f, 1.f, 1.f, 0.5f), + LLFontGL::LEFT, LLFontGL::VCENTER); + last_label = begin; + } + else + { + gl_rect_2d(bar_left, end, bar_right - tick_length/2, begin, LLColor4(1.f, 1.f, 1.f, 0.1f)); + } } else { - gl_rect_2d(begin, bar_top, end, bar_bottom - tick_length/2, LLColor4(1.f, 1.f, 1.f, 0.1f)); + if (begin - last_label > MIN_LABEL_SPACING) + { + gl_rect_2d(begin, bar_top, end, bar_bottom - tick_length, LLColor4(1.f, 1.f, 1.f, 0.25f)); + LLFontGL::getFontMonospace()->renderUTF8(tick_string, 0, begin - 1, bar_bottom - tick_length, + LLColor4(1.f, 1.f, 1.f, 0.5f), + LLFontGL::RIGHT, LLFontGL::TOP); + last_label = begin; + } + else + { + gl_rect_2d(begin, bar_top, end, bar_bottom - tick_length/2, LLColor4(1.f, 1.f, 1.f, 0.1f)); + } + } + // always draw one tick value past end, so we can see part of the text, if possible + if (tick_value > mCurMaxBar) + { + break; } } } @@ -416,8 +451,7 @@ void LLStatBar::draw() if (mDisplayHistory && (mCountFloatp || mEventFloatp || mSampleFloatp)) { const S32 num_values = frame_recording.getNumRecordedPeriods() - 1; - F32 begin = 0; - F32 end = 0; + F32 value = 0; S32 i; gGL.color4f( 1.f, 0.f, 0.f, 1.f ); gGL.begin( LLRender::QUADS ); @@ -427,49 +461,41 @@ void LLStatBar::draw() { F32 offset = ((F32)i / (F32)mNumFrames) * span; LLTrace::Recording& recording = frame_recording.getPrevRecording(i); - if (mPerSec && mCountFloatp) + + if (mCountFloatp) { - begin = ((recording.getPerSec(*mCountFloatp) - mCurMinBar) * value_scale); - end = ((recording.getPerSec(*mCountFloatp) - mCurMinBar) * value_scale) + 1; + value = mPerSec + ? recording.getPerSec(*mCountFloatp) + : recording.getSum(*mCountFloatp); num_samples = recording.getSampleCount(*mCountFloatp); } - else + else if (mEventFloatp) { - if (mCountFloatp) - { - begin = ((recording.getSum(*mCountFloatp) - mCurMinBar) * value_scale); - end = ((recording.getSum(*mCountFloatp) - mCurMinBar) * value_scale) + 1; - num_samples = recording.getSampleCount(*mCountFloatp); - } - else if (mEventFloatp) - { - begin = ((recording.getMean(*mEventFloatp) - mCurMinBar) * value_scale); - end = ((recording.getMean(*mEventFloatp) - mCurMinBar) * value_scale) + 1; - num_samples = recording.getSampleCount(*mEventFloatp); - } - else if (mSampleFloatp) - { - begin = ((recording.getMean(*mSampleFloatp) - mCurMinBar) * value_scale); - end = ((recording.getMean(*mSampleFloatp) - mCurMinBar) * value_scale) + 1; - num_samples = recording.getSampleCount(*mSampleFloatp); - } - } + value = recording.getMean(*mEventFloatp); + num_samples = recording.getSampleCount(*mEventFloatp); + } + else if (mSampleFloatp) + { + value = recording.getMean(*mSampleFloatp); + num_samples = recording.getSampleCount(*mSampleFloatp); + } if (!num_samples) continue; + F32 begin = (value - mCurMinBar) * value_scale; if (mOrientation == HORIZONTAL) { - gGL.vertex2f((F32)bar_right - offset, end); + gGL.vertex2f((F32)bar_right - offset, begin + 1); gGL.vertex2f((F32)bar_right - offset, begin); - gGL.vertex2f((F32)bar_right - offset - 1.f, begin); - gGL.vertex2f((F32)bar_right - offset - 1.f, end); + gGL.vertex2f((F32)bar_right - offset - 1, begin); + gGL.vertex2f((F32)bar_right - offset - 1, begin + 1); } else { - gGL.vertex2f(begin, (F32)bar_bottom+offset+1.f); - gGL.vertex2f(begin, (F32)bar_bottom+offset); - gGL.vertex2f(end, (F32)bar_bottom+offset); - gGL.vertex2f(end, (F32)bar_bottom+offset+1.f); + gGL.vertex2f(begin, (F32)bar_bottom + offset + 1); + gGL.vertex2f(begin, (F32)bar_bottom + offset); + gGL.vertex2f(begin + 1, (F32)bar_bottom + offset); + gGL.vertex2f(begin + 1, (F32)bar_bottom + offset + 1 ); } } gGL.end(); @@ -517,9 +543,9 @@ void LLStatBar::setStat(const std::string& stat_name) void LLStatBar::setRange(F32 bar_min, F32 bar_max) { - mMinBar = bar_min; - mMaxBar = bar_max; - mTickValue = calc_reasonable_tick_value(mMinBar, mMaxBar); + mMinBar = llmin(bar_min, bar_max); + mMaxBar = llmax(bar_min, bar_max); + mTickValue = calc_tick_value(mMinBar, mMaxBar); } LLRect LLStatBar::getRequiredRect() -- cgit v1.2.3 From c2a456e9f2d92a62551cfbd1367c9a0303a1570d Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Mon, 15 Jul 2013 11:41:47 -0700 Subject: BUILDFIX: remove ambiguity of is_approx_equal, use llabs instead of fabs --- indra/llui/llstatbar.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'indra/llui/llstatbar.cpp') diff --git a/indra/llui/llstatbar.cpp b/indra/llui/llstatbar.cpp index a0a14f4610..3cd60a3f73 100755 --- a/indra/llui/llstatbar.cpp +++ b/indra/llui/llstatbar.cpp @@ -80,12 +80,12 @@ void calc_auto_scale_range(F32& min, F32& max, F32& tick) const F32 RANGES[] = {0.f, 1.f, 1.5f, 2.f, 3.f, 5.f, 10.f}; const F32 TICKS[] = {0.f, 0.25f, 0.5f, 1.f, 1.f, 1.f, 2.f }; - const S32 num_digits_max = is_approx_equal(fabs(max), 0.f) + const S32 num_digits_max = is_approx_equal(llabs(max), 0.f) ? S32_MIN + 1 - : llceil(logf(fabs(max)) * OO_LN10); - const S32 num_digits_min = is_approx_equal(fabs(min), 0.f) + : llceil(logf(llabs(max)) * OO_LN10); + const S32 num_digits_min = is_approx_equal(llabs(min), 0.f) ? S32_MIN + 1 - : llceil(logf(fabs(min)) * OO_LN10); + : llceil(logf(llabs(min)) * OO_LN10); const S32 num_digits = llmax(num_digits_max, num_digits_min); const F32 power_of_10 = pow(10.0, num_digits - 1); -- cgit v1.2.3 From 0127e66228acd41402da9acab8ce91d394c3096f Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Tue, 23 Jul 2013 16:42:22 -0700 Subject: stat bars with no stats now show n/a instead of o --- indra/llui/llstatbar.cpp | 180 +++++++++++++++++++++++++---------------------- 1 file changed, 96 insertions(+), 84 deletions(-) (limited to 'indra/llui/llstatbar.cpp') diff --git a/indra/llui/llstatbar.cpp b/indra/llui/llstatbar.cpp index 3cd60a3f73..7f1632b48b 100755 --- a/indra/llui/llstatbar.cpp +++ b/indra/llui/llstatbar.cpp @@ -225,6 +225,9 @@ void LLStatBar::draw() max = 0, mean = 0; + + S32 num_samples = 0; + LLLocalClipRect _(getLocalRect()); LLTrace::PeriodicRecording& frame_recording = LLTrace::get_frame_recording(); @@ -236,6 +239,7 @@ void LLStatBar::draw() if (mPerSec) { unit_label += "/s"; + num_samples = frame_recording.getSampleCount(*mCountFloatp, mNumFrames); current = last_frame_recording.getPerSec(*mCountFloatp); min = frame_recording.getPeriodMinPerSec(*mCountFloatp, mNumFrames); max = frame_recording.getPeriodMaxPerSec(*mCountFloatp, mNumFrames); @@ -243,6 +247,7 @@ void LLStatBar::draw() } else { + num_samples = frame_recording.getSampleCount(*mCountFloatp, mNumFrames); current = last_frame_recording.getSum(*mCountFloatp); min = frame_recording.getPeriodMin(*mCountFloatp, mNumFrames); max = frame_recording.getPeriodMax(*mCountFloatp, mNumFrames); @@ -254,6 +259,7 @@ void LLStatBar::draw() LLTrace::Recording& last_frame_recording = frame_recording.getLastRecording(); unit_label = mUnitLabel.empty() ? mEventFloatp->getUnitLabel() : mUnitLabel; + num_samples = frame_recording.getSampleCount(*mEventFloatp, mNumFrames); current = last_frame_recording.getMean(*mEventFloatp); min = frame_recording.getPeriodMin(*mEventFloatp, mNumFrames); max = frame_recording.getPeriodMax(*mEventFloatp, mNumFrames); @@ -264,6 +270,7 @@ void LLStatBar::draw() LLTrace::Recording& last_frame_recording = frame_recording.getLastRecording(); unit_label = mUnitLabel.empty() ? mSampleFloatp->getUnitLabel() : mUnitLabel; + num_samples = frame_recording.getSampleCount(*mSampleFloatp, mNumFrames); current = last_frame_recording.getMean(*mSampleFloatp); min = frame_recording.getPeriodMin(*mSampleFloatp, mNumFrames); max = frame_recording.getPeriodMax(*mSampleFloatp, mNumFrames); @@ -329,7 +336,9 @@ void LLStatBar::draw() { decimal_digits = 0; } - std::string value_str = llformat("%10.*f %s", decimal_digits, mean, unit_label.c_str()); + std::string value_str = num_samples + ? llformat("%10.*f %s", decimal_digits, mean, unit_label.c_str()) + : "n/a"; // Draw the current value. if (mOrientation == HORIZONTAL) @@ -345,7 +354,8 @@ void LLStatBar::draw() LLFontGL::RIGHT, LLFontGL::TOP); } - if (mDisplayBar && (mCountFloatp || mEventFloatp || mSampleFloatp)) + if (mDisplayBar + && (mCountFloatp || mEventFloatp || mSampleFloatp)) { // Draw the tick marks. LLGLSUIDefault gls_ui; @@ -431,7 +441,6 @@ void LLStatBar::draw() if (begin < 0) { begin = 0; - llwarns << "Min:" << min << llendl; } S32 end = (S32) ((max - mCurMinBar) * value_scale); @@ -444,90 +453,93 @@ void LLStatBar::draw() gl_rect_2d(begin, bar_top, end, bar_bottom, LLColor4(1.f, 0.f, 0.f, 0.25f)); } - F32 span = (mOrientation == HORIZONTAL) + if (num_samples) + { + F32 span = (mOrientation == HORIZONTAL) ? (bar_right - bar_left) : (bar_top - bar_bottom); - if (mDisplayHistory && (mCountFloatp || mEventFloatp || mSampleFloatp)) - { - const S32 num_values = frame_recording.getNumRecordedPeriods() - 1; - F32 value = 0; - S32 i; - gGL.color4f( 1.f, 0.f, 0.f, 1.f ); - gGL.begin( LLRender::QUADS ); - const S32 max_frame = llmin(mNumFrames, num_values); - U32 num_samples = 0; - for (i = 1; i <= max_frame; i++) - { - F32 offset = ((F32)i / (F32)mNumFrames) * span; - LLTrace::Recording& recording = frame_recording.getPrevRecording(i); - - if (mCountFloatp) - { - value = mPerSec - ? recording.getPerSec(*mCountFloatp) - : recording.getSum(*mCountFloatp); - num_samples = recording.getSampleCount(*mCountFloatp); - } - else if (mEventFloatp) - { - value = recording.getMean(*mEventFloatp); - num_samples = recording.getSampleCount(*mEventFloatp); - } - else if (mSampleFloatp) - { - value = recording.getMean(*mSampleFloatp); - num_samples = recording.getSampleCount(*mSampleFloatp); - } - - if (!num_samples) continue; - - F32 begin = (value - mCurMinBar) * value_scale; - if (mOrientation == HORIZONTAL) - { - gGL.vertex2f((F32)bar_right - offset, begin + 1); - gGL.vertex2f((F32)bar_right - offset, begin); - gGL.vertex2f((F32)bar_right - offset - 1, begin); - gGL.vertex2f((F32)bar_right - offset - 1, begin + 1); - } - else - { - gGL.vertex2f(begin, (F32)bar_bottom + offset + 1); - gGL.vertex2f(begin, (F32)bar_bottom + offset); - gGL.vertex2f(begin + 1, (F32)bar_bottom + offset); - gGL.vertex2f(begin + 1, (F32)bar_bottom + offset + 1 ); - } - } - gGL.end(); - } - else - { - S32 begin = (S32) ((current - mCurMinBar) * value_scale) - 1; - S32 end = (S32) ((current - mCurMinBar) * value_scale) + 1; - // draw current - if (mOrientation == HORIZONTAL) - { - gl_rect_2d(bar_left, end, bar_right, begin, LLColor4(1.f, 0.f, 0.f, 1.f)); - } - else - { - gl_rect_2d(begin, bar_top, end, bar_bottom, LLColor4(1.f, 0.f, 0.f, 1.f)); - } - } - - // draw mean bar - { - const S32 begin = (S32) ((mean - mCurMinBar) * value_scale) - 1; - const S32 end = (S32) ((mean - mCurMinBar) * value_scale) + 1; - if (mOrientation == HORIZONTAL) - { - gl_rect_2d(bar_left - 2, begin, bar_right + 2, end, LLColor4(0.f, 1.f, 0.f, 1.f)); - } - else - { - gl_rect_2d(begin, bar_top + 2, end, bar_bottom - 2, LLColor4(0.f, 1.f, 0.f, 1.f)); - } - } + if (mDisplayHistory && (mCountFloatp || mEventFloatp || mSampleFloatp)) + { + const S32 num_values = frame_recording.getNumRecordedPeriods() - 1; + F32 value = 0; + S32 i; + gGL.color4f( 1.f, 0.f, 0.f, 1.f ); + gGL.begin( LLRender::QUADS ); + const S32 max_frame = llmin(mNumFrames, num_values); + U32 num_samples = 0; + for (i = 1; i <= max_frame; i++) + { + F32 offset = ((F32)i / (F32)mNumFrames) * span; + LLTrace::Recording& recording = frame_recording.getPrevRecording(i); + + if (mCountFloatp) + { + value = mPerSec + ? recording.getPerSec(*mCountFloatp) + : recording.getSum(*mCountFloatp); + num_samples = recording.getSampleCount(*mCountFloatp); + } + else if (mEventFloatp) + { + value = recording.getMean(*mEventFloatp); + num_samples = recording.getSampleCount(*mEventFloatp); + } + else if (mSampleFloatp) + { + value = recording.getMean(*mSampleFloatp); + num_samples = recording.getSampleCount(*mSampleFloatp); + } + + if (!num_samples) continue; + + F32 begin = (value - mCurMinBar) * value_scale; + if (mOrientation == HORIZONTAL) + { + gGL.vertex2f((F32)bar_right - offset, begin + 1); + gGL.vertex2f((F32)bar_right - offset, begin); + gGL.vertex2f((F32)bar_right - offset - 1, begin); + gGL.vertex2f((F32)bar_right - offset - 1, begin + 1); + } + else + { + gGL.vertex2f(begin, (F32)bar_bottom + offset + 1); + gGL.vertex2f(begin, (F32)bar_bottom + offset); + gGL.vertex2f(begin + 1, (F32)bar_bottom + offset); + gGL.vertex2f(begin + 1, (F32)bar_bottom + offset + 1 ); + } + } + gGL.end(); + } + else + { + S32 begin = (S32) ((current - mCurMinBar) * value_scale) - 1; + S32 end = (S32) ((current - mCurMinBar) * value_scale) + 1; + // draw current + if (mOrientation == HORIZONTAL) + { + gl_rect_2d(bar_left, end, bar_right, begin, LLColor4(1.f, 0.f, 0.f, 1.f)); + } + else + { + gl_rect_2d(begin, bar_top, end, bar_bottom, LLColor4(1.f, 0.f, 0.f, 1.f)); + } + } + + // draw mean bar + { + const S32 begin = (S32) ((mean - mCurMinBar) * value_scale) - 1; + const S32 end = (S32) ((mean - mCurMinBar) * value_scale) + 1; + if (mOrientation == HORIZONTAL) + { + gl_rect_2d(bar_left - 2, begin, bar_right + 2, end, LLColor4(0.f, 1.f, 0.f, 1.f)); + } + else + { + gl_rect_2d(begin, bar_top + 2, end, bar_bottom - 2, LLColor4(0.f, 1.f, 0.f, 1.f)); + } + } + } } LLView::draw(); -- cgit v1.2.3 From d9b8544fd437aaed14091c6642fb7da19e146b34 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Tue, 23 Jul 2013 17:30:56 -0700 Subject: SH-4366 FIX: Interesting Viewer Crashes when opening Statistics floater --- indra/llui/llstatbar.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'indra/llui/llstatbar.cpp') diff --git a/indra/llui/llstatbar.cpp b/indra/llui/llstatbar.cpp index 7f1632b48b..d9f4a36f8d 100755 --- a/indra/llui/llstatbar.cpp +++ b/indra/llui/llstatbar.cpp @@ -150,6 +150,7 @@ LLStatBar::LLStatBar(const Params& p) mMinBar(llmin(p.bar_min, p.bar_max)), mMaxBar(llmax(p.bar_max, p.bar_min)), mCurMaxBar(p.bar_max), + mCurMinBar(0), mDecimalDigits(p.decimal_digits), mNumFrames(p.num_frames), mMaxHeight(p.max_height), -- cgit v1.2.3 From 1e8f9fd80d0ac4e0eab656ed8e8e32f91ab8b533 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Wed, 24 Jul 2013 19:36:43 -0700 Subject: SH-4376 FIX: Interesting: in Statistics, replace the text "0" with "n/a" when there are no samples during the time period. added hasValue to SampleAccumulator so we don't print a value when we don't have a single sample yet added some disabled log output for scene load timing --- indra/llui/llstatbar.cpp | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) (limited to 'indra/llui/llstatbar.cpp') diff --git a/indra/llui/llstatbar.cpp b/indra/llui/llstatbar.cpp index d9f4a36f8d..2543bd8f0a 100755 --- a/indra/llui/llstatbar.cpp +++ b/indra/llui/llstatbar.cpp @@ -226,8 +226,7 @@ void LLStatBar::draw() max = 0, mean = 0; - - S32 num_samples = 0; + bool show_data = false; LLLocalClipRect _(getLocalRect()); LLTrace::PeriodicRecording& frame_recording = LLTrace::get_frame_recording(); @@ -240,7 +239,6 @@ void LLStatBar::draw() if (mPerSec) { unit_label += "/s"; - num_samples = frame_recording.getSampleCount(*mCountFloatp, mNumFrames); current = last_frame_recording.getPerSec(*mCountFloatp); min = frame_recording.getPeriodMinPerSec(*mCountFloatp, mNumFrames); max = frame_recording.getPeriodMaxPerSec(*mCountFloatp, mNumFrames); @@ -248,34 +246,41 @@ void LLStatBar::draw() } else { - num_samples = frame_recording.getSampleCount(*mCountFloatp, mNumFrames); current = last_frame_recording.getSum(*mCountFloatp); min = frame_recording.getPeriodMin(*mCountFloatp, mNumFrames); max = frame_recording.getPeriodMax(*mCountFloatp, mNumFrames); mean = frame_recording.getPeriodMean(*mCountFloatp, mNumFrames); } + + // always show count-style data + show_data = true; } else if (mEventFloatp) { LLTrace::Recording& last_frame_recording = frame_recording.getLastRecording(); unit_label = mUnitLabel.empty() ? mEventFloatp->getUnitLabel() : mUnitLabel; - num_samples = frame_recording.getSampleCount(*mEventFloatp, mNumFrames); + // only show data if there is an event in the relevant time period current = last_frame_recording.getMean(*mEventFloatp); min = frame_recording.getPeriodMin(*mEventFloatp, mNumFrames); max = frame_recording.getPeriodMax(*mEventFloatp, mNumFrames); mean = frame_recording.getPeriodMean(*mEventFloatp, mNumFrames); + + show_data = frame_recording.getSampleCount(*mEventFloatp, mNumFrames) != 0; } else if (mSampleFloatp) { + LLTrace::Recording& last_frame_recording = frame_recording.getLastRecording(); unit_label = mUnitLabel.empty() ? mSampleFloatp->getUnitLabel() : mUnitLabel; - num_samples = frame_recording.getSampleCount(*mSampleFloatp, mNumFrames); current = last_frame_recording.getMean(*mSampleFloatp); min = frame_recording.getPeriodMin(*mSampleFloatp, mNumFrames); max = frame_recording.getPeriodMax(*mSampleFloatp, mNumFrames); mean = frame_recording.getPeriodMean(*mSampleFloatp, mNumFrames); + + // always show sample data if we've ever grabbed any samples + show_data = mSampleFloatp->getPrimaryAccumulator()->hasValue(); } S32 bar_top, bar_left, bar_right, bar_bottom; @@ -337,7 +342,7 @@ void LLStatBar::draw() { decimal_digits = 0; } - std::string value_str = num_samples + std::string value_str = show_data ? llformat("%10.*f %s", decimal_digits, mean, unit_label.c_str()) : "n/a"; @@ -454,7 +459,7 @@ void LLStatBar::draw() gl_rect_2d(begin, bar_top, end, bar_bottom, LLColor4(1.f, 0.f, 0.f, 0.25f)); } - if (num_samples) + if (show_data) { F32 span = (mOrientation == HORIZONTAL) ? (bar_right - bar_left) -- cgit v1.2.3 From a2e22732f195dc075a733c79f15156752f522a43 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Tue, 30 Jul 2013 19:13:45 -0700 Subject: Summer cleaning - removed a lot of llcommon dependencies to speed up build times consolidated most indra-specific constants in llcommon under indra_constants.h fixed issues with operations on mixed unit types (implicit and explicit) made LL_INFOS() style macros variadic in order to subsume other logging methods such as ll_infos added optional tag output to error recorders --- indra/llui/llstatbar.cpp | 58 ++++++++++++++++++++---------------------------- 1 file changed, 24 insertions(+), 34 deletions(-) (limited to 'indra/llui/llstatbar.cpp') diff --git a/indra/llui/llstatbar.cpp b/indra/llui/llstatbar.cpp index 2543bd8f0a..1af36c6fdb 100755 --- a/indra/llui/llstatbar.cpp +++ b/indra/llui/llstatbar.cpp @@ -152,9 +152,9 @@ LLStatBar::LLStatBar(const Params& p) mCurMaxBar(p.bar_max), mCurMinBar(0), mDecimalDigits(p.decimal_digits), - mNumFrames(p.num_frames), + mNumHistoryFrames(p.num_frames), + mNumShortHistoryFrames(p.num_frames_short), mMaxHeight(p.max_height), - mPerSec(p.show_per_sec), mDisplayBar(p.show_bar), mDisplayHistory(p.show_history), mOrientation(p.orientation), @@ -221,36 +221,28 @@ BOOL LLStatBar::handleMouseDown(S32 x, S32 y, MASK mask) void LLStatBar::draw() { - F32 current = 0, - min = 0, - max = 0, - mean = 0; + F32 current = 0, + min = 0, + max = 0, + mean = 0; bool show_data = false; LLLocalClipRect _(getLocalRect()); LLTrace::PeriodicRecording& frame_recording = LLTrace::get_frame_recording(); + S32 num_frames = mDisplayHistory ? mNumHistoryFrames : mNumShortHistoryFrames; + std::string unit_label; if (mCountFloatp) { LLTrace::Recording& last_frame_recording = frame_recording.getLastRecording(); unit_label = mUnitLabel.empty() ? mCountFloatp->getUnitLabel() : mUnitLabel; - if (mPerSec) - { - unit_label += "/s"; - current = last_frame_recording.getPerSec(*mCountFloatp); - min = frame_recording.getPeriodMinPerSec(*mCountFloatp, mNumFrames); - max = frame_recording.getPeriodMaxPerSec(*mCountFloatp, mNumFrames); - mean = frame_recording.getPeriodMeanPerSec(*mCountFloatp, mNumFrames); - } - else - { - current = last_frame_recording.getSum(*mCountFloatp); - min = frame_recording.getPeriodMin(*mCountFloatp, mNumFrames); - max = frame_recording.getPeriodMax(*mCountFloatp, mNumFrames); - mean = frame_recording.getPeriodMean(*mCountFloatp, mNumFrames); - } + unit_label += "/s"; + current = last_frame_recording.getPerSec(*mCountFloatp); + min = frame_recording.getPeriodMinPerSec(*mCountFloatp, num_frames); + max = frame_recording.getPeriodMaxPerSec(*mCountFloatp, num_frames); + mean = frame_recording.getPeriodMeanPerSec(*mCountFloatp, num_frames); // always show count-style data show_data = true; @@ -262,11 +254,11 @@ void LLStatBar::draw() // only show data if there is an event in the relevant time period current = last_frame_recording.getMean(*mEventFloatp); - min = frame_recording.getPeriodMin(*mEventFloatp, mNumFrames); - max = frame_recording.getPeriodMax(*mEventFloatp, mNumFrames); - mean = frame_recording.getPeriodMean(*mEventFloatp, mNumFrames); - - show_data = frame_recording.getSampleCount(*mEventFloatp, mNumFrames) != 0; + min = frame_recording.getPeriodMin(*mEventFloatp, num_frames); + max = frame_recording.getPeriodMax(*mEventFloatp, num_frames); + mean = frame_recording.getPeriodMean(*mEventFloatp, num_frames); + + show_data = frame_recording.getSampleCount(*mEventFloatp, num_frames) != 0; } else if (mSampleFloatp) { @@ -275,9 +267,9 @@ void LLStatBar::draw() unit_label = mUnitLabel.empty() ? mSampleFloatp->getUnitLabel() : mUnitLabel; current = last_frame_recording.getMean(*mSampleFloatp); - min = frame_recording.getPeriodMin(*mSampleFloatp, mNumFrames); - max = frame_recording.getPeriodMax(*mSampleFloatp, mNumFrames); - mean = frame_recording.getPeriodMean(*mSampleFloatp, mNumFrames); + min = frame_recording.getPeriodMin(*mSampleFloatp, num_frames); + max = frame_recording.getPeriodMax(*mSampleFloatp, num_frames); + mean = frame_recording.getPeriodMean(*mSampleFloatp, num_frames); // always show sample data if we've ever grabbed any samples show_data = mSampleFloatp->getPrimaryAccumulator()->hasValue(); @@ -472,18 +464,16 @@ void LLStatBar::draw() S32 i; gGL.color4f( 1.f, 0.f, 0.f, 1.f ); gGL.begin( LLRender::QUADS ); - const S32 max_frame = llmin(mNumFrames, num_values); + const S32 max_frame = llmin(num_frames, num_values); U32 num_samples = 0; for (i = 1; i <= max_frame; i++) { - F32 offset = ((F32)i / (F32)mNumFrames) * span; + F32 offset = ((F32)i / (F32)num_frames) * span; LLTrace::Recording& recording = frame_recording.getPrevRecording(i); if (mCountFloatp) { - value = mPerSec - ? recording.getPerSec(*mCountFloatp) - : recording.getSum(*mCountFloatp); + value = recording.getPerSec(*mCountFloatp); num_samples = recording.getSampleCount(*mCountFloatp); } else if (mEventFloatp) -- cgit v1.2.3 From f58eb60b1e0bbdf2148255c61100cbc20d1ba1b0 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Thu, 1 Aug 2013 08:17:21 -0700 Subject: SH-4374 WIP Interesting: Statistics Object cache hit rate is always 100% --- indra/llui/llstatbar.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/llui/llstatbar.cpp') diff --git a/indra/llui/llstatbar.cpp b/indra/llui/llstatbar.cpp index 1af36c6fdb..ee73cfa40d 100755 --- a/indra/llui/llstatbar.cpp +++ b/indra/llui/llstatbar.cpp @@ -272,7 +272,7 @@ void LLStatBar::draw() mean = frame_recording.getPeriodMean(*mSampleFloatp, num_frames); // always show sample data if we've ever grabbed any samples - show_data = mSampleFloatp->getPrimaryAccumulator()->hasValue(); + show_data = last_frame_recording.hasValue(*mSampleFloatp); } S32 bar_top, bar_left, bar_right, bar_bottom; -- cgit v1.2.3 From cc31b4ae7934010762b8aaaa7e190c74a1cd7820 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Mon, 12 Aug 2013 20:05:16 -0700 Subject: SH-4399 FIX: Interesting: Texture console MB Bound 0/384 and texture queue bounces once per second SH-4346 FIX: Interesting: some integer Statistics are displayed as floating point after crossing region boundary made llerrs/infos/etc properly variadic wrt tags LL_INFOS("A", "B", "C") works, for example fixed unit tests remove llsimplestat --- indra/llui/llstatbar.cpp | 600 +++++++++++++++++++++++++++-------------------- 1 file changed, 340 insertions(+), 260 deletions(-) (limited to 'indra/llui/llstatbar.cpp') diff --git a/indra/llui/llstatbar.cpp b/indra/llui/llstatbar.cpp index ee73cfa40d..900f81992c 100755 --- a/indra/llui/llstatbar.cpp +++ b/indra/llui/llstatbar.cpp @@ -160,7 +160,8 @@ LLStatBar::LLStatBar(const Params& p) mOrientation(p.orientation), mAutoScaleMax(!p.bar_max.isProvided()), mAutoScaleMin(!p.bar_min.isProvided()), - mTickValue(p.tick_spacing) + mTickValue(p.tick_spacing), + mLastDisplayValue(0.f) { // tick value will be automatically calculated later if (!p.tick_spacing.isProvided() && p.bar_min.isProvided() && p.bar_max.isProvided()) @@ -219,323 +220,281 @@ BOOL LLStatBar::handleMouseDown(S32 x, S32 y, MASK mask) return TRUE; } -void LLStatBar::draw() +template +S32 calc_num_rapid_changes(LLTrace::PeriodicRecording& periodic_recording, const T& stat, const LLUnit time_period) { - F32 current = 0, - min = 0, - max = 0, - mean = 0; + LLUnit elapsed_time, + time_since_value_changed; + S32 num_rapid_changes = 0; + const LLUnit RAPID_CHANGE_THRESHOLD = LLUnits::Seconds::fromValue(0.3f); - bool show_data = false; - - LLLocalClipRect _(getLocalRect()); - LLTrace::PeriodicRecording& frame_recording = LLTrace::get_frame_recording(); + F64 last_value = periodic_recording.getPrevRecording(1).getLastValue(stat); + for (S32 i = 2; i < periodic_recording.getNumRecordedPeriods(); i++) + { + LLTrace::Recording& recording = periodic_recording.getPrevRecording(i); + F64 cur_value = recording.getLastValue(stat); - S32 num_frames = mDisplayHistory ? mNumHistoryFrames : mNumShortHistoryFrames; + if (last_value != cur_value) + { + if (time_since_value_changed < RAPID_CHANGE_THRESHOLD) num_rapid_changes++; + time_since_value_changed = 0; + } + last_value = cur_value; - std::string unit_label; - if (mCountFloatp) - { - LLTrace::Recording& last_frame_recording = frame_recording.getLastRecording(); - unit_label = mUnitLabel.empty() ? mCountFloatp->getUnitLabel() : mUnitLabel; - unit_label += "/s"; - current = last_frame_recording.getPerSec(*mCountFloatp); - min = frame_recording.getPeriodMinPerSec(*mCountFloatp, num_frames); - max = frame_recording.getPeriodMaxPerSec(*mCountFloatp, num_frames); - mean = frame_recording.getPeriodMeanPerSec(*mCountFloatp, num_frames); - - // always show count-style data - show_data = true; + elapsed_time += recording.getDuration(); + if (elapsed_time > time_period) break; } - else if (mEventFloatp) + + return num_rapid_changes; +} + +S32 calc_num_rapid_changes(LLTrace::PeriodicRecording& periodic_recording, const LLTrace::TraceType& stat, const LLUnit time_period) +{ + LLUnit elapsed_time, + time_since_value_changed; + S32 num_rapid_changes = 0; + const LLUnit RAPID_CHANGE_THRESHOLD = LLUnits::Seconds::fromValue(0.3f); + + F64 last_value = periodic_recording.getPrevRecording(1).getSum(stat); + for (S32 i = 1; i < periodic_recording.getNumRecordedPeriods(); i++) { - LLTrace::Recording& last_frame_recording = frame_recording.getLastRecording(); - unit_label = mUnitLabel.empty() ? mEventFloatp->getUnitLabel() : mUnitLabel; + LLTrace::Recording& recording = periodic_recording.getPrevRecording(i); + F64 cur_value = recording.getSum(stat); - // only show data if there is an event in the relevant time period - current = last_frame_recording.getMean(*mEventFloatp); - min = frame_recording.getPeriodMin(*mEventFloatp, num_frames); - max = frame_recording.getPeriodMax(*mEventFloatp, num_frames); - mean = frame_recording.getPeriodMean(*mEventFloatp, num_frames); + if (last_value != cur_value) + { + if (time_since_value_changed < RAPID_CHANGE_THRESHOLD) num_rapid_changes++; + time_since_value_changed = 0; + } + last_value = cur_value; - show_data = frame_recording.getSampleCount(*mEventFloatp, num_frames) != 0; + elapsed_time += recording.getDuration(); + if (elapsed_time > time_period) break; } - else if (mSampleFloatp) - { - LLTrace::Recording& last_frame_recording = frame_recording.getLastRecording(); - unit_label = mUnitLabel.empty() ? mSampleFloatp->getUnitLabel() : mUnitLabel; + return num_rapid_changes; +} - current = last_frame_recording.getMean(*mSampleFloatp); - min = frame_recording.getPeriodMin(*mSampleFloatp, num_frames); - max = frame_recording.getPeriodMax(*mSampleFloatp, num_frames); - mean = frame_recording.getPeriodMean(*mSampleFloatp, num_frames); +void LLStatBar::draw() +{ + LLLocalClipRect _(getLocalRect()); - // always show sample data if we've ever grabbed any samples - show_data = last_frame_recording.hasValue(*mSampleFloatp); - } + LLTrace::PeriodicRecording& frame_recording = LLTrace::get_frame_recording(); + LLTrace::Recording& last_frame_recording = frame_recording.getLastRecording(); - S32 bar_top, bar_left, bar_right, bar_bottom; - if (mOrientation == HORIZONTAL) + std::string unit_label; + F32 current = 0, + min = 0, + max = 0, + mean = 0, + display_value = 0; + S32 num_frames = mDisplayHistory + ? mNumHistoryFrames + : mNumShortHistoryFrames; + S32 num_rapid_changes = 0; + + const S32 MAX_RAPID_CHANGES = 6; + const F32 MIN_VALUE_UPDATE_TIME = 1.f / 4.f; + const LLUnit CHANGE_WINDOW = LLUnits::Seconds::fromValue(2.f); + + if (mCountFloatp) { - bar_top = llmax(5, getRect().getHeight() - 15); - bar_left = 0; - bar_right = getRect().getWidth() - 40; - bar_bottom = llmin(bar_top - 5, 0); + const LLTrace::TraceType& count_stat = *mCountFloatp; + + unit_label = mUnitLabel.empty() ? (std::string(count_stat.getUnitLabel()) + "/s") : mUnitLabel; + current = last_frame_recording.getPerSec(count_stat); + min = frame_recording.getPeriodMinPerSec(count_stat, num_frames); + max = frame_recording.getPeriodMaxPerSec(count_stat, num_frames); + mean = frame_recording.getPeriodMeanPerSec(count_stat, num_frames); + num_rapid_changes = calc_num_rapid_changes(frame_recording, count_stat, CHANGE_WINDOW); } - else // VERTICAL + else if (mEventFloatp) { - bar_top = llmax(5, getRect().getHeight() - 15); - bar_left = 0; - bar_right = getRect().getWidth(); - bar_bottom = llmin(bar_top - 5, 20); - } - const S32 tick_length = 4; - const S32 tick_width = 1; + const LLTrace::TraceType& event_stat = *mEventFloatp; - if ((mAutoScaleMax && max >= mCurMaxBar)|| (mAutoScaleMin && min <= mCurMinBar)) - { - F32 range_min = mAutoScaleMin ? llmin(mMinBar, min) : mMinBar; - F32 range_max = mAutoScaleMax ? llmax(mMaxBar, max) : mMaxBar; - F32 tick_value = 0.f; - calc_auto_scale_range(range_min, range_max, tick_value); - if (mAutoScaleMin) { mMinBar = range_min; } - if (mAutoScaleMax) { mMaxBar = range_max; } - if (mAutoScaleMin && mAutoScaleMax) - { - mTickValue = tick_value; - } - else - { - mTickValue = calc_tick_value(mMinBar, mMaxBar); - } + unit_label = mUnitLabel.empty() ? event_stat.getUnitLabel() : mUnitLabel; + + current = last_frame_recording.getLastValue(event_stat); + min = frame_recording.getPeriodMin(event_stat, num_frames); + max = frame_recording.getPeriodMax(event_stat, num_frames); + mean = frame_recording.getPeriodMean(event_stat, num_frames); + num_rapid_changes = calc_num_rapid_changes(frame_recording, event_stat, CHANGE_WINDOW); } + else if (mSampleFloatp) + { + const LLTrace::TraceType& sample_stat = *mSampleFloatp; - mCurMaxBar = LLSmoothInterpolation::lerp(mCurMaxBar, mMaxBar, 0.05f); - mCurMinBar = LLSmoothInterpolation::lerp(mCurMinBar, mMinBar, 0.05f); + unit_label = mUnitLabel.empty() ? sample_stat.getUnitLabel() : mUnitLabel; - F32 value_scale; - if (mCurMaxBar == mCurMinBar) - { - value_scale = 0.f; + current = last_frame_recording.getLastValue(sample_stat); + min = frame_recording.getPeriodMin(sample_stat, num_frames); + max = frame_recording.getPeriodMax(sample_stat, num_frames); + mean = frame_recording.getPeriodMean(sample_stat, num_frames); + num_rapid_changes = calc_num_rapid_changes(frame_recording, sample_stat, CHANGE_WINDOW); } - else + + if (mLastDisplayValueTimer.getElapsedTimeF32() > MIN_VALUE_UPDATE_TIME) { - value_scale = (mOrientation == HORIZONTAL) - ? (bar_top - bar_bottom)/(mCurMaxBar - mCurMinBar) - : (bar_right - bar_left)/(mCurMaxBar - mCurMinBar); + mLastDisplayValueTimer.reset(); + display_value = (num_rapid_changes > MAX_RAPID_CHANGES) + ? mean + : current; + mLastDisplayValue = display_value; } - - LLFontGL::getFontMonospace()->renderUTF8(mLabel, 0, 0, getRect().getHeight(), LLColor4(1.f, 1.f, 1.f, 1.f), - LLFontGL::LEFT, LLFontGL::TOP); - - S32 decimal_digits = mDecimalDigits; - if (is_approx_equal((F32)(S32)mean, mean)) + else { - decimal_digits = 0; + display_value = mLastDisplayValue; } - std::string value_str = show_data - ? llformat("%10.*f %s", decimal_digits, mean, unit_label.c_str()) - : "n/a"; - // Draw the current value. + LLRect bar_rect; if (mOrientation == HORIZONTAL) { - LLFontGL::getFontMonospace()->renderUTF8(value_str, 0, bar_right, getRect().getHeight(), - LLColor4(1.f, 1.f, 1.f, 0.5f), - LLFontGL::RIGHT, LLFontGL::TOP); + bar_rect.mTop = llmax(5, getRect().getHeight() - 15); + bar_rect.mLeft = 0; + bar_rect.mRight = getRect().getWidth() - 40; + bar_rect.mBottom = llmin(bar_rect.mTop - 5, 0); } - else + else // VERTICAL { - LLFontGL::getFontMonospace()->renderUTF8(value_str, 0, bar_right, getRect().getHeight(), - LLColor4(1.f, 1.f, 1.f, 0.5f), - LLFontGL::RIGHT, LLFontGL::TOP); + bar_rect.mTop = llmax(5, getRect().getHeight() - 15); + bar_rect.mLeft = 0; + bar_rect.mRight = getRect().getWidth(); + bar_rect.mBottom = llmin(bar_rect.mTop - 5, 20); } + mCurMaxBar = LLSmoothInterpolation::lerp(mCurMaxBar, mMaxBar, 0.05f); + mCurMinBar = LLSmoothInterpolation::lerp(mCurMinBar, mMinBar, 0.05f); + + drawLabelAndValue(display_value, unit_label, bar_rect); + if (mDisplayBar && (mCountFloatp || mEventFloatp || mSampleFloatp)) { // Draw the tick marks. LLGLSUIDefault gls_ui; gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); - S32 last_tick = 0; - S32 last_label = 0; - const S32 MIN_TICK_SPACING = mOrientation == HORIZONTAL ? 20 : 30; - const S32 MIN_LABEL_SPACING = mOrientation == HORIZONTAL ? 30 : 60; - // start counting from actual min, not current, animating min, so that ticks don't float between numbers - // ensure ticks always hit 0 - if (mTickValue > 0.f) + + F32 value_scale; + if (mCurMaxBar == mCurMinBar) + { + value_scale = 0.f; + } + else { - F32 start = mCurMinBar < 0.f - ? llceil(-mCurMinBar / mTickValue) * -mTickValue - : 0.f; - for (F32 tick_value = start; ;tick_value += mTickValue) + value_scale = (mOrientation == HORIZONTAL) + ? (bar_rect.getHeight())/(mCurMaxBar - mCurMinBar) + : (bar_rect.getWidth())/(mCurMaxBar - mCurMinBar); + } + + drawTicks(min, max, value_scale, bar_rect); + + // draw background bar. + gl_rect_2d(bar_rect.mLeft, bar_rect.mTop, bar_rect.mRight, bar_rect.mBottom, LLColor4(0.f, 0.f, 0.f, 0.25f)); + + // draw values + if (!llisnan(display_value) && frame_recording.getNumRecordedPeriods() != 0) + { + // draw min and max + S32 begin = (S32) ((min - mCurMinBar) * value_scale); + + if (begin < 0) { - const S32 begin = llfloor((tick_value - mCurMinBar)*value_scale); - const S32 end = begin + tick_width; - if (begin - last_tick < MIN_TICK_SPACING) - { - continue; - } - last_tick = begin; + begin = 0; + } - S32 decimal_digits = mDecimalDigits; - if (is_approx_equal((F32)(S32)tick_value, tick_value)) - { - decimal_digits = 0; - } - std::string tick_string = llformat("%10.*f", decimal_digits, tick_value); + S32 end = (S32) ((max - mCurMinBar) * value_scale); + if (mOrientation == HORIZONTAL) + { + gl_rect_2d(bar_rect.mLeft, end, bar_rect.mRight, begin, LLColor4(1.f, 0.f, 0.f, 0.25f)); + } + else // VERTICAL + { + gl_rect_2d(begin, bar_rect.mTop, end, bar_rect.mBottom, LLColor4(1.f, 0.f, 0.f, 0.25f)); + } - if (mOrientation == HORIZONTAL) + F32 span = (mOrientation == HORIZONTAL) + ? (bar_rect.getWidth()) + : (bar_rect.getHeight()); + + if (mDisplayHistory && (mCountFloatp || mEventFloatp || mSampleFloatp)) + { + const S32 num_values = frame_recording.getNumRecordedPeriods() - 1; + F32 value = 0; + S32 i; + gGL.color4f( 1.f, 0.f, 0.f, 1.f ); + gGL.begin( LLRender::QUADS ); + const S32 max_frame = llmin(num_frames, num_values); + U32 num_samples = 0; + for (i = 1; i <= max_frame; i++) { - if (begin - last_label > MIN_LABEL_SPACING) + F32 offset = ((F32)i / (F32)num_frames) * span; + LLTrace::Recording& recording = frame_recording.getPrevRecording(i); + + if (mCountFloatp) { - gl_rect_2d(bar_left, end, bar_right - tick_length, begin, LLColor4(1.f, 1.f, 1.f, 0.25f)); - LLFontGL::getFontMonospace()->renderUTF8(tick_string, 0, bar_right, begin, - LLColor4(1.f, 1.f, 1.f, 0.5f), - LLFontGL::LEFT, LLFontGL::VCENTER); - last_label = begin; + value = recording.getPerSec(*mCountFloatp); + num_samples = recording.getSampleCount(*mCountFloatp); } - else + else if (mEventFloatp) { - gl_rect_2d(bar_left, end, bar_right - tick_length/2, begin, LLColor4(1.f, 1.f, 1.f, 0.1f)); + value = recording.getMean(*mEventFloatp); + num_samples = recording.getSampleCount(*mEventFloatp); } - } - else - { - if (begin - last_label > MIN_LABEL_SPACING) + else if (mSampleFloatp) + { + value = recording.getMean(*mSampleFloatp); + num_samples = recording.getSampleCount(*mSampleFloatp); + } + + if (!num_samples) continue; + + F32 begin = (value - mCurMinBar) * value_scale; + if (mOrientation == HORIZONTAL) { - gl_rect_2d(begin, bar_top, end, bar_bottom - tick_length, LLColor4(1.f, 1.f, 1.f, 0.25f)); - LLFontGL::getFontMonospace()->renderUTF8(tick_string, 0, begin - 1, bar_bottom - tick_length, - LLColor4(1.f, 1.f, 1.f, 0.5f), - LLFontGL::RIGHT, LLFontGL::TOP); - last_label = begin; + gGL.vertex2f((F32)bar_rect.mRight - offset, begin + 1); + gGL.vertex2f((F32)bar_rect.mRight - offset, begin); + gGL.vertex2f((F32)bar_rect.mRight - offset - 1, begin); + gGL.vertex2f((F32)bar_rect.mRight - offset - 1, begin + 1); } else { - gl_rect_2d(begin, bar_top, end, bar_bottom - tick_length/2, LLColor4(1.f, 1.f, 1.f, 0.1f)); + gGL.vertex2f(begin, (F32)bar_rect.mBottom + offset + 1); + gGL.vertex2f(begin, (F32)bar_rect.mBottom + offset); + gGL.vertex2f(begin + 1, (F32)bar_rect.mBottom + offset); + gGL.vertex2f(begin + 1, (F32)bar_rect.mBottom + offset + 1 ); } } - // always draw one tick value past end, so we can see part of the text, if possible - if (tick_value > mCurMaxBar) + gGL.end(); + } + else + { + S32 begin = (S32) ((current - mCurMinBar) * value_scale) - 1; + S32 end = (S32) ((current - mCurMinBar) * value_scale) + 1; + // draw current + if (mOrientation == HORIZONTAL) + { + gl_rect_2d(bar_rect.mLeft, end, bar_rect.mRight, begin, LLColor4(1.f, 0.f, 0.f, 1.f)); + } + else { - break; + gl_rect_2d(begin, bar_rect.mTop, end, bar_rect.mBottom, LLColor4(1.f, 0.f, 0.f, 1.f)); } } - } - - // draw background bar. - gl_rect_2d(bar_left, bar_top, bar_right, bar_bottom, LLColor4(0.f, 0.f, 0.f, 0.25f)); - - if (frame_recording.getNumRecordedPeriods() == 0) - { - // No data, don't draw anything... - return; - } - // draw min and max - S32 begin = (S32) ((min - mCurMinBar) * value_scale); - - if (begin < 0) - { - begin = 0; - } - - S32 end = (S32) ((max - mCurMinBar) * value_scale); - if (mOrientation == HORIZONTAL) - { - gl_rect_2d(bar_left, end, bar_right, begin, LLColor4(1.f, 0.f, 0.f, 0.25f)); - } - else // VERTICAL - { - gl_rect_2d(begin, bar_top, end, bar_bottom, LLColor4(1.f, 0.f, 0.f, 0.25f)); + // draw mean bar + { + const S32 begin = (S32) ((mean - mCurMinBar) * value_scale) - 1; + const S32 end = (S32) ((mean - mCurMinBar) * value_scale) + 1; + if (mOrientation == HORIZONTAL) + { + gl_rect_2d(bar_rect.mLeft - 2, begin, bar_rect.mRight + 2, end, LLColor4(0.f, 1.f, 0.f, 1.f)); + } + else + { + gl_rect_2d(begin, bar_rect.mTop + 2, end, bar_rect.mBottom - 2, LLColor4(0.f, 1.f, 0.f, 1.f)); + } + } } - - if (show_data) - { - F32 span = (mOrientation == HORIZONTAL) - ? (bar_right - bar_left) - : (bar_top - bar_bottom); - - if (mDisplayHistory && (mCountFloatp || mEventFloatp || mSampleFloatp)) - { - const S32 num_values = frame_recording.getNumRecordedPeriods() - 1; - F32 value = 0; - S32 i; - gGL.color4f( 1.f, 0.f, 0.f, 1.f ); - gGL.begin( LLRender::QUADS ); - const S32 max_frame = llmin(num_frames, num_values); - U32 num_samples = 0; - for (i = 1; i <= max_frame; i++) - { - F32 offset = ((F32)i / (F32)num_frames) * span; - LLTrace::Recording& recording = frame_recording.getPrevRecording(i); - - if (mCountFloatp) - { - value = recording.getPerSec(*mCountFloatp); - num_samples = recording.getSampleCount(*mCountFloatp); - } - else if (mEventFloatp) - { - value = recording.getMean(*mEventFloatp); - num_samples = recording.getSampleCount(*mEventFloatp); - } - else if (mSampleFloatp) - { - value = recording.getMean(*mSampleFloatp); - num_samples = recording.getSampleCount(*mSampleFloatp); - } - - if (!num_samples) continue; - - F32 begin = (value - mCurMinBar) * value_scale; - if (mOrientation == HORIZONTAL) - { - gGL.vertex2f((F32)bar_right - offset, begin + 1); - gGL.vertex2f((F32)bar_right - offset, begin); - gGL.vertex2f((F32)bar_right - offset - 1, begin); - gGL.vertex2f((F32)bar_right - offset - 1, begin + 1); - } - else - { - gGL.vertex2f(begin, (F32)bar_bottom + offset + 1); - gGL.vertex2f(begin, (F32)bar_bottom + offset); - gGL.vertex2f(begin + 1, (F32)bar_bottom + offset); - gGL.vertex2f(begin + 1, (F32)bar_bottom + offset + 1 ); - } - } - gGL.end(); - } - else - { - S32 begin = (S32) ((current - mCurMinBar) * value_scale) - 1; - S32 end = (S32) ((current - mCurMinBar) * value_scale) + 1; - // draw current - if (mOrientation == HORIZONTAL) - { - gl_rect_2d(bar_left, end, bar_right, begin, LLColor4(1.f, 0.f, 0.f, 1.f)); - } - else - { - gl_rect_2d(begin, bar_top, end, bar_bottom, LLColor4(1.f, 0.f, 0.f, 1.f)); - } - } - - // draw mean bar - { - const S32 begin = (S32) ((mean - mCurMinBar) * value_scale) - 1; - const S32 end = (S32) ((mean - mCurMinBar) * value_scale) + 1; - if (mOrientation == HORIZONTAL) - { - gl_rect_2d(bar_left - 2, begin, bar_right + 2, end, LLColor4(0.f, 1.f, 0.f, 1.f)); - } - else - { - gl_rect_2d(begin, bar_top + 2, end, bar_bottom - 2, LLColor4(0.f, 1.f, 0.f, 1.f)); - } - } - } } LLView::draw(); @@ -578,3 +537,124 @@ LLRect LLStatBar::getRequiredRect() return rect; } +void LLStatBar::drawLabelAndValue( F32 value, std::string &label, LLRect &bar_rect ) +{ + LLFontGL::getFontMonospace()->renderUTF8(mLabel, 0, 0, getRect().getHeight(), LLColor4(1.f, 1.f, 1.f, 1.f), + LLFontGL::LEFT, LLFontGL::TOP); + + S32 decimal_digits = mDecimalDigits; + if (is_approx_equal((F32)(S32)value, value)) + { + decimal_digits = 0; + } + std::string value_str = !llisnan(value) + ? llformat("%10.*f %s", decimal_digits, value, label.c_str()) + : "n/a"; + + // Draw the current value. + if (mOrientation == HORIZONTAL) + { + LLFontGL::getFontMonospace()->renderUTF8(value_str, 0, bar_rect.mRight, getRect().getHeight(), + LLColor4(1.f, 1.f, 1.f, 0.5f), + LLFontGL::RIGHT, LLFontGL::TOP); + } + else + { + LLFontGL::getFontMonospace()->renderUTF8(value_str, 0, bar_rect.mRight, getRect().getHeight(), + LLColor4(1.f, 1.f, 1.f, 0.5f), + LLFontGL::RIGHT, LLFontGL::TOP); + } +} + +void LLStatBar::drawTicks( F32 min, F32 max, F32 value_scale, LLRect &bar_rect ) +{ + if ((mAutoScaleMax && max >= mCurMaxBar)|| (mAutoScaleMin && min <= mCurMinBar)) + { + F32 range_min = mAutoScaleMin ? llmin(mMinBar, min) : mMinBar; + F32 range_max = mAutoScaleMax ? llmax(mMaxBar, max) : mMaxBar; + F32 tick_value = 0.f; + calc_auto_scale_range(range_min, range_max, tick_value); + if (mAutoScaleMin) { mMinBar = range_min; } + if (mAutoScaleMax) { mMaxBar = range_max; } + if (mAutoScaleMin && mAutoScaleMax) + { + mTickValue = tick_value; + } + else + { + mTickValue = calc_tick_value(mMinBar, mMaxBar); + } + } + + // start counting from actual min, not current, animating min, so that ticks don't float between numbers + // ensure ticks always hit 0 + S32 last_tick = 0; + S32 last_label = 0; + if (mTickValue > 0.f && value_scale > 0.f) + { + const S32 MIN_TICK_SPACING = mOrientation == HORIZONTAL ? 20 : 30; + const S32 MIN_LABEL_SPACING = mOrientation == HORIZONTAL ? 30 : 60; + const S32 TICK_LENGTH = 4; + const S32 TICK_WIDTH = 1; + + F32 start = mCurMinBar < 0.f + ? llceil(-mCurMinBar / mTickValue) * -mTickValue + : 0.f; + for (F32 tick_value = start; ;tick_value += mTickValue) + { + const S32 begin = llfloor((tick_value - mCurMinBar)*value_scale); + const S32 end = begin + TICK_WIDTH; + if (begin - last_tick < MIN_TICK_SPACING) + { + continue; + } + last_tick = begin; + + S32 decimal_digits = mDecimalDigits; + if (is_approx_equal((F32)(S32)tick_value, tick_value)) + { + decimal_digits = 0; + } + std::string tick_string = llformat("%10.*f", decimal_digits, tick_value); + + if (mOrientation == HORIZONTAL) + { + if (begin - last_label > MIN_LABEL_SPACING) + { + gl_rect_2d(bar_rect.mLeft, end, bar_rect.mRight - TICK_LENGTH, begin, LLColor4(1.f, 1.f, 1.f, 0.25f)); + LLFontGL::getFontMonospace()->renderUTF8(tick_string, 0, bar_rect.mRight, begin, + LLColor4(1.f, 1.f, 1.f, 0.5f), + LLFontGL::LEFT, LLFontGL::VCENTER); + last_label = begin; + } + else + { + gl_rect_2d(bar_rect.mLeft, end, bar_rect.mRight - TICK_LENGTH/2, begin, LLColor4(1.f, 1.f, 1.f, 0.1f)); + } + } + else + { + if (begin - last_label > MIN_LABEL_SPACING) + { + gl_rect_2d(begin, bar_rect.mTop, end, bar_rect.mBottom - TICK_LENGTH, LLColor4(1.f, 1.f, 1.f, 0.25f)); + LLFontGL::getFontMonospace()->renderUTF8(tick_string, 0, begin - 1, bar_rect.mBottom - TICK_LENGTH, + LLColor4(1.f, 1.f, 1.f, 0.5f), + LLFontGL::RIGHT, LLFontGL::TOP); + last_label = begin; + } + else + { + gl_rect_2d(begin, bar_rect.mTop, end, bar_rect.mBottom - TICK_LENGTH/2, LLColor4(1.f, 1.f, 1.f, 0.1f)); + } + } + // always draw one tick value past end, so we can see part of the text, if possible + if (tick_value > mCurMaxBar) + { + break; + } + } + } +} + + + -- cgit v1.2.3 From 9faaa28f4445425e8c5b7b002faffbe0365b905d Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Tue, 13 Aug 2013 18:33:07 -0700 Subject: SH-4346 FIX Interesting: some integer Statistics are displayed as floating point after crossing region boundary fine-tuned heuristics for switching between mean and current values in stat bar display added comments to LLUnits unit test --- indra/llui/llstatbar.cpp | 107 ++++++++++++++++++++++++++++++----------------- 1 file changed, 69 insertions(+), 38 deletions(-) (limited to 'indra/llui/llstatbar.cpp') diff --git a/indra/llui/llstatbar.cpp b/indra/llui/llstatbar.cpp index 900f81992c..b564ad5cee 100755 --- a/indra/llui/llstatbar.cpp +++ b/indra/llui/llstatbar.cpp @@ -41,6 +41,16 @@ #include "lllocalcliprect.h" #include +// rate at which to update display of value that is rapidly changing +const F32 MEAN_VALUE_UPDATE_TIME = 1.f / 4.f; +// time between value changes that qualifies as a "rapid change" +const LLUnit RAPID_CHANGE_THRESHOLD = 0.2f; +// maximum number of rapid changes in RAPID_CHANGE_WINDOW before switching over to displaying the mean +// instead of latest value +const S32 MAX_RAPID_CHANGES_PER_SEC = 10; +// period of time over which to measure rapid changes +const LLUnit RAPID_CHANGE_WINDOW = 1.f; + F32 calc_tick_value(F32 min, F32 max) { F32 range = max - min; @@ -141,6 +151,25 @@ void calc_auto_scale_range(F32& min, F32& max, F32& tick) max = out_max; } +LLStatBar::Params::Params() +: label("label"), + unit_label("unit_label"), + bar_min("bar_min", 0.f), + bar_max("bar_max", 0.f), + tick_spacing("tick_spacing", 0.f), + decimal_digits("decimal_digits", 3), + show_bar("show_bar", false), + show_history("show_history", false), + scale_range("scale_range", true), + num_frames("num_frames", 200), + num_frames_short("num_frames_short", 20), + max_height("max_height", 100), + stat("stat"), + orientation("orientation", VERTICAL) +{ + changeDefault(follows.flags, FOLLOWS_TOP | FOLLOWS_LEFT); +} + /////////////////////////////////////////////////////////////////////////////////// LLStatBar::LLStatBar(const Params& p) @@ -253,7 +282,6 @@ S32 calc_num_rapid_changes(LLTrace::PeriodicRecording& periodic_recording, const LLUnit elapsed_time, time_since_value_changed; S32 num_rapid_changes = 0; - const LLUnit RAPID_CHANGE_THRESHOLD = LLUnits::Seconds::fromValue(0.3f); F64 last_value = periodic_recording.getPrevRecording(1).getSum(stat); for (S32 i = 1; i < periodic_recording.getNumRecordedPeriods(); i++) @@ -293,57 +321,50 @@ void LLStatBar::draw() : mNumShortHistoryFrames; S32 num_rapid_changes = 0; - const S32 MAX_RAPID_CHANGES = 6; - const F32 MIN_VALUE_UPDATE_TIME = 1.f / 4.f; - const LLUnit CHANGE_WINDOW = LLUnits::Seconds::fromValue(2.f); - if (mCountFloatp) { const LLTrace::TraceType& count_stat = *mCountFloatp; - unit_label = mUnitLabel.empty() ? (std::string(count_stat.getUnitLabel()) + "/s") : mUnitLabel; - current = last_frame_recording.getPerSec(count_stat); - min = frame_recording.getPeriodMinPerSec(count_stat, num_frames); - max = frame_recording.getPeriodMaxPerSec(count_stat, num_frames); - mean = frame_recording.getPeriodMeanPerSec(count_stat, num_frames); - num_rapid_changes = calc_num_rapid_changes(frame_recording, count_stat, CHANGE_WINDOW); + unit_label = mUnitLabel.empty() ? (std::string(count_stat.getUnitLabel()) + "/s") : mUnitLabel; + current = last_frame_recording.getPerSec(count_stat); + min = frame_recording.getPeriodMinPerSec(count_stat, num_frames); + max = frame_recording.getPeriodMaxPerSec(count_stat, num_frames); + mean = frame_recording.getPeriodMeanPerSec(count_stat, num_frames); + display_value = mean; } else if (mEventFloatp) { const LLTrace::TraceType& event_stat = *mEventFloatp; - unit_label = mUnitLabel.empty() ? event_stat.getUnitLabel() : mUnitLabel; - - current = last_frame_recording.getLastValue(event_stat); - min = frame_recording.getPeriodMin(event_stat, num_frames); - max = frame_recording.getPeriodMax(event_stat, num_frames); - mean = frame_recording.getPeriodMean(event_stat, num_frames); - num_rapid_changes = calc_num_rapid_changes(frame_recording, event_stat, CHANGE_WINDOW); + unit_label = mUnitLabel.empty() ? event_stat.getUnitLabel() : mUnitLabel; + current = last_frame_recording.getLastValue(event_stat); + min = frame_recording.getPeriodMin(event_stat, num_frames); + max = frame_recording.getPeriodMax(event_stat, num_frames); + mean = frame_recording.getPeriodMean(event_stat, num_frames); + num_rapid_changes = calc_num_rapid_changes(frame_recording, event_stat, RAPID_CHANGE_WINDOW); + display_value = mean; } else if (mSampleFloatp) { const LLTrace::TraceType& sample_stat = *mSampleFloatp; - unit_label = mUnitLabel.empty() ? sample_stat.getUnitLabel() : mUnitLabel; + unit_label = mUnitLabel.empty() ? sample_stat.getUnitLabel() : mUnitLabel; + current = last_frame_recording.getLastValue(sample_stat); + min = frame_recording.getPeriodMin(sample_stat, num_frames); + max = frame_recording.getPeriodMax(sample_stat, num_frames); + mean = frame_recording.getPeriodMean(sample_stat, num_frames); + num_rapid_changes = calc_num_rapid_changes(frame_recording, sample_stat, RAPID_CHANGE_WINDOW); - current = last_frame_recording.getLastValue(sample_stat); - min = frame_recording.getPeriodMin(sample_stat, num_frames); - max = frame_recording.getPeriodMax(sample_stat, num_frames); - mean = frame_recording.getPeriodMean(sample_stat, num_frames); - num_rapid_changes = calc_num_rapid_changes(frame_recording, sample_stat, CHANGE_WINDOW); - } - - if (mLastDisplayValueTimer.getElapsedTimeF32() > MIN_VALUE_UPDATE_TIME) - { - mLastDisplayValueTimer.reset(); - display_value = (num_rapid_changes > MAX_RAPID_CHANGES) - ? mean - : current; - mLastDisplayValue = display_value; - } - else - { - display_value = mLastDisplayValue; + if (num_rapid_changes / RAPID_CHANGE_WINDOW > MAX_RAPID_CHANGES_PER_SEC) + { + display_value = mean; + } + else + { + display_value = current; + // always display current value, don't rate limit + mLastDisplayValue = current; + } } LLRect bar_rect; @@ -365,7 +386,17 @@ void LLStatBar::draw() mCurMaxBar = LLSmoothInterpolation::lerp(mCurMaxBar, mMaxBar, 0.05f); mCurMinBar = LLSmoothInterpolation::lerp(mCurMinBar, mMinBar, 0.05f); - drawLabelAndValue(display_value, unit_label, bar_rect); + // rate limited updates + if (mLastDisplayValueTimer.getElapsedTimeF32() > MEAN_VALUE_UPDATE_TIME) + { + mLastDisplayValueTimer.reset(); + drawLabelAndValue(display_value, unit_label, bar_rect); + mLastDisplayValue = display_value; + } + else + { + drawLabelAndValue(mLastDisplayValue, unit_label, bar_rect); + } if (mDisplayBar && (mCountFloatp || mEventFloatp || mSampleFloatp)) -- 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/llui/llstatbar.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'indra/llui/llstatbar.cpp') diff --git a/indra/llui/llstatbar.cpp b/indra/llui/llstatbar.cpp index b564ad5cee..5857e32821 100755 --- a/indra/llui/llstatbar.cpp +++ b/indra/llui/llstatbar.cpp @@ -44,12 +44,12 @@ // rate at which to update display of value that is rapidly changing const F32 MEAN_VALUE_UPDATE_TIME = 1.f / 4.f; // time between value changes that qualifies as a "rapid change" -const LLUnit RAPID_CHANGE_THRESHOLD = 0.2f; +const LLUnits::F32Seconds RAPID_CHANGE_THRESHOLD(0.2f); // maximum number of rapid changes in RAPID_CHANGE_WINDOW before switching over to displaying the mean // instead of latest value const S32 MAX_RAPID_CHANGES_PER_SEC = 10; // period of time over which to measure rapid changes -const LLUnit RAPID_CHANGE_WINDOW = 1.f; +const LLUnits::F32Seconds RAPID_CHANGE_WINDOW(1.f); F32 calc_tick_value(F32 min, F32 max) { @@ -250,12 +250,12 @@ BOOL LLStatBar::handleMouseDown(S32 x, S32 y, MASK mask) } template -S32 calc_num_rapid_changes(LLTrace::PeriodicRecording& periodic_recording, const T& stat, const LLUnit time_period) +S32 calc_num_rapid_changes(LLTrace::PeriodicRecording& periodic_recording, const T& stat, const LLUnits::F32Seconds time_period) { - LLUnit elapsed_time, + LLUnits::F32Seconds elapsed_time, time_since_value_changed; S32 num_rapid_changes = 0; - const LLUnit RAPID_CHANGE_THRESHOLD = LLUnits::Seconds::fromValue(0.3f); + const LLUnits::F32Seconds RAPID_CHANGE_THRESHOLD = LLUnits::F32Seconds(0.3f); F64 last_value = periodic_recording.getPrevRecording(1).getLastValue(stat); for (S32 i = 2; i < periodic_recording.getNumRecordedPeriods(); i++) @@ -277,9 +277,9 @@ S32 calc_num_rapid_changes(LLTrace::PeriodicRecording& periodic_recording, const return num_rapid_changes; } -S32 calc_num_rapid_changes(LLTrace::PeriodicRecording& periodic_recording, const LLTrace::TraceType& stat, const LLUnit time_period) +S32 calc_num_rapid_changes(LLTrace::PeriodicRecording& periodic_recording, const LLTrace::TraceType& stat, const LLUnits::F32Seconds time_period) { - LLUnit elapsed_time, + LLUnits::F32Seconds elapsed_time, time_since_value_changed; S32 num_rapid_changes = 0; -- 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/llui/llstatbar.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'indra/llui/llstatbar.cpp') diff --git a/indra/llui/llstatbar.cpp b/indra/llui/llstatbar.cpp index 5857e32821..4c64cc944e 100755 --- a/indra/llui/llstatbar.cpp +++ b/indra/llui/llstatbar.cpp @@ -44,12 +44,12 @@ // rate at which to update display of value that is rapidly changing const F32 MEAN_VALUE_UPDATE_TIME = 1.f / 4.f; // time between value changes that qualifies as a "rapid change" -const LLUnits::F32Seconds RAPID_CHANGE_THRESHOLD(0.2f); +const F32Seconds RAPID_CHANGE_THRESHOLD(0.2f); // maximum number of rapid changes in RAPID_CHANGE_WINDOW before switching over to displaying the mean // instead of latest value const S32 MAX_RAPID_CHANGES_PER_SEC = 10; // period of time over which to measure rapid changes -const LLUnits::F32Seconds RAPID_CHANGE_WINDOW(1.f); +const F32Seconds RAPID_CHANGE_WINDOW(1.f); F32 calc_tick_value(F32 min, F32 max) { @@ -250,12 +250,12 @@ BOOL LLStatBar::handleMouseDown(S32 x, S32 y, MASK mask) } template -S32 calc_num_rapid_changes(LLTrace::PeriodicRecording& periodic_recording, const T& stat, const LLUnits::F32Seconds time_period) +S32 calc_num_rapid_changes(LLTrace::PeriodicRecording& periodic_recording, const T& stat, const F32Seconds time_period) { - LLUnits::F32Seconds elapsed_time, + F32Seconds elapsed_time, time_since_value_changed; S32 num_rapid_changes = 0; - const LLUnits::F32Seconds RAPID_CHANGE_THRESHOLD = LLUnits::F32Seconds(0.3f); + const F32Seconds RAPID_CHANGE_THRESHOLD = F32Seconds(0.3f); F64 last_value = periodic_recording.getPrevRecording(1).getLastValue(stat); for (S32 i = 2; i < periodic_recording.getNumRecordedPeriods(); i++) @@ -277,9 +277,9 @@ S32 calc_num_rapid_changes(LLTrace::PeriodicRecording& periodic_recording, const return num_rapid_changes; } -S32 calc_num_rapid_changes(LLTrace::PeriodicRecording& periodic_recording, const LLTrace::TraceType& stat, const LLUnits::F32Seconds time_period) +S32 calc_num_rapid_changes(LLTrace::PeriodicRecording& periodic_recording, const LLTrace::TraceType& stat, const F32Seconds time_period) { - LLUnits::F32Seconds elapsed_time, + F32Seconds elapsed_time, time_since_value_changed; S32 num_rapid_changes = 0; -- 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/llui/llstatbar.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'indra/llui/llstatbar.cpp') diff --git a/indra/llui/llstatbar.cpp b/indra/llui/llstatbar.cpp index 4c64cc944e..03a2895289 100755 --- a/indra/llui/llstatbar.cpp +++ b/indra/llui/llstatbar.cpp @@ -253,7 +253,7 @@ template S32 calc_num_rapid_changes(LLTrace::PeriodicRecording& periodic_recording, const T& stat, const F32Seconds time_period) { F32Seconds elapsed_time, - time_since_value_changed; + time_since_value_changed; S32 num_rapid_changes = 0; const F32Seconds RAPID_CHANGE_THRESHOLD = F32Seconds(0.3f); @@ -266,7 +266,7 @@ S32 calc_num_rapid_changes(LLTrace::PeriodicRecording& periodic_recording, const if (last_value != cur_value) { if (time_since_value_changed < RAPID_CHANGE_THRESHOLD) num_rapid_changes++; - time_since_value_changed = 0; + time_since_value_changed = (F32Seconds)0; } last_value = cur_value; @@ -280,7 +280,7 @@ S32 calc_num_rapid_changes(LLTrace::PeriodicRecording& periodic_recording, const S32 calc_num_rapid_changes(LLTrace::PeriodicRecording& periodic_recording, const LLTrace::TraceType& stat, const F32Seconds time_period) { F32Seconds elapsed_time, - time_since_value_changed; + time_since_value_changed; S32 num_rapid_changes = 0; F64 last_value = periodic_recording.getPrevRecording(1).getSum(stat); @@ -292,7 +292,7 @@ S32 calc_num_rapid_changes(LLTrace::PeriodicRecording& periodic_recording, const if (last_value != cur_value) { if (time_since_value_changed < RAPID_CHANGE_THRESHOLD) num_rapid_changes++; - time_since_value_changed = 0; + time_since_value_changed = (F32Seconds)0; } last_value = cur_value; @@ -355,7 +355,7 @@ void LLStatBar::draw() mean = frame_recording.getPeriodMean(sample_stat, num_frames); num_rapid_changes = calc_num_rapid_changes(frame_recording, sample_stat, RAPID_CHANGE_WINDOW); - if (num_rapid_changes / RAPID_CHANGE_WINDOW > MAX_RAPID_CHANGES_PER_SEC) + if (num_rapid_changes / RAPID_CHANGE_WINDOW.value() > MAX_RAPID_CHANGES_PER_SEC) { display_value = mean; } -- cgit v1.2.3 From 2c6bc5afa59a88136fd6de4ebf0cb99ea7cdef3f Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Wed, 21 Aug 2013 14:06:57 -0700 Subject: SH-4433 WIP Interesting: Statistics > Ping Sim is always 0 ms made getPrimaryAccumulator return a reference since it was an always non-null pointer changed unit conversion to perform lazy division in order to avoid truncation of timer values --- indra/llui/llstatbar.cpp | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) (limited to 'indra/llui/llstatbar.cpp') diff --git a/indra/llui/llstatbar.cpp b/indra/llui/llstatbar.cpp index 03a2895289..8658a2f968 100755 --- a/indra/llui/llstatbar.cpp +++ b/indra/llui/llstatbar.cpp @@ -386,17 +386,24 @@ void LLStatBar::draw() mCurMaxBar = LLSmoothInterpolation::lerp(mCurMaxBar, mMaxBar, 0.05f); mCurMinBar = LLSmoothInterpolation::lerp(mCurMinBar, mMinBar, 0.05f); + S32 decimal_digits = mDecimalDigits; + if (is_approx_equal((F32)(S32)display_value, display_value)) + { + decimal_digits = 0; + } + // rate limited updates - if (mLastDisplayValueTimer.getElapsedTimeF32() > MEAN_VALUE_UPDATE_TIME) + if (mLastDisplayValueTimer.getElapsedTimeF32() < MEAN_VALUE_UPDATE_TIME) { - mLastDisplayValueTimer.reset(); - drawLabelAndValue(display_value, unit_label, bar_rect); - mLastDisplayValue = display_value; + display_value = mLastDisplayValue; } else { - drawLabelAndValue(mLastDisplayValue, unit_label, bar_rect); + mLastDisplayValueTimer.reset(); } + drawLabelAndValue(display_value, unit_label, bar_rect, mDecimalDigits); + mLastDisplayValue = display_value; + if (mDisplayBar && (mCountFloatp || mEventFloatp || mSampleFloatp)) @@ -568,16 +575,11 @@ LLRect LLStatBar::getRequiredRect() return rect; } -void LLStatBar::drawLabelAndValue( F32 value, std::string &label, LLRect &bar_rect ) +void LLStatBar::drawLabelAndValue( F32 value, std::string &label, LLRect &bar_rect, S32 decimal_digits ) { LLFontGL::getFontMonospace()->renderUTF8(mLabel, 0, 0, getRect().getHeight(), LLColor4(1.f, 1.f, 1.f, 1.f), LLFontGL::LEFT, LLFontGL::TOP); - S32 decimal_digits = mDecimalDigits; - if (is_approx_equal((F32)(S32)value, value)) - { - decimal_digits = 0; - } std::string value_str = !llisnan(value) ? llformat("%10.*f %s", decimal_digits, value, label.c_str()) : "n/a"; -- cgit v1.2.3 From cf014375b8b408d58bd35deb4e58e4369fb3bf62 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Thu, 22 Aug 2013 14:21:16 -0700 Subject: SH-4433 FIX: Interesting: Statistics > Ping Sim is always 0 ms removed bad assert fixed precision issues during int->unsigned int conversions and vice versa --- indra/llui/llstatbar.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/llui/llstatbar.cpp') diff --git a/indra/llui/llstatbar.cpp b/indra/llui/llstatbar.cpp index 8658a2f968..3cd2e53001 100755 --- a/indra/llui/llstatbar.cpp +++ b/indra/llui/llstatbar.cpp @@ -401,7 +401,7 @@ void LLStatBar::draw() { mLastDisplayValueTimer.reset(); } - drawLabelAndValue(display_value, unit_label, bar_rect, mDecimalDigits); + drawLabelAndValue(display_value, unit_label, bar_rect, decimal_digits); mLastDisplayValue = display_value; -- cgit v1.2.3 From 662d6a17712fbba5cea0d9cf20f5a2f32e2dd537 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Mon, 26 Aug 2013 10:51:08 -0700 Subject: added compile time warnings to use of deprecated llinfos, llwarns, etc. --- indra/llui/llstatbar.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/llui/llstatbar.cpp') diff --git a/indra/llui/llstatbar.cpp b/indra/llui/llstatbar.cpp index 3cd2e53001..725a835f7f 100755 --- a/indra/llui/llstatbar.cpp +++ b/indra/llui/llstatbar.cpp @@ -325,7 +325,7 @@ void LLStatBar::draw() { const LLTrace::TraceType& count_stat = *mCountFloatp; - unit_label = mUnitLabel.empty() ? (std::string(count_stat.getUnitLabel()) + "/s") : mUnitLabel; + unit_label = std::string(count_stat.getUnitLabel()) + "/s"; current = last_frame_recording.getPerSec(count_stat); min = frame_recording.getPeriodMinPerSec(count_stat, num_frames); max = frame_recording.getPeriodMaxPerSec(count_stat, num_frames); -- cgit v1.2.3 From 0dfc08d22a21728ec670bd75e6fd0ed60c97bf06 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Thu, 19 Sep 2013 15:21:46 -0700 Subject: BUILDFIX: more bad merge stuff also added ability for statbar to show memtrackable info --- indra/llui/llstatbar.cpp | 195 ++++++++++++++++++++++++++++++----------------- 1 file changed, 123 insertions(+), 72 deletions(-) (limited to 'indra/llui/llstatbar.cpp') diff --git a/indra/llui/llstatbar.cpp b/indra/llui/llstatbar.cpp index 725a835f7f..9f96dd642d 100755 --- a/indra/llui/llstatbar.cpp +++ b/indra/llui/llstatbar.cpp @@ -190,8 +190,10 @@ LLStatBar::LLStatBar(const Params& p) mAutoScaleMax(!p.bar_max.isProvided()), mAutoScaleMin(!p.bar_min.isProvided()), mTickValue(p.tick_spacing), - mLastDisplayValue(0.f) + mLastDisplayValue(0.f), + mStatType(STAT_NONE) { + mStat.valid = NULL; // tick value will be automatically calculated later if (!p.tick_spacing.isProvided() && p.bar_min.isProvided() && p.bar_max.isProvided()) { @@ -203,17 +205,22 @@ LLStatBar::LLStatBar(const Params& p) BOOL LLStatBar::handleHover(S32 x, S32 y, MASK mask) { - if (mCountFloatp) + switch(mStatType) { - LLToolTipMgr::instance().show(LLToolTip::Params().message(mCountFloatp->getDescription()).sticky_rect(calcScreenRect())); - } - else if ( mEventFloatp) - { - LLToolTipMgr::instance().show(LLToolTip::Params().message(mEventFloatp->getDescription()).sticky_rect(calcScreenRect())); - } - else if (mSampleFloatp) - { - LLToolTipMgr::instance().show(LLToolTip::Params().message(mSampleFloatp->getDescription()).sticky_rect(calcScreenRect())); + case STAT_COUNT: + LLToolTipMgr::instance().show(LLToolTip::Params().message(mStat.countStatp->getDescription()).sticky_rect(calcScreenRect())); + break; + case STAT_EVENT: + LLToolTipMgr::instance().show(LLToolTip::Params().message(mStat.eventStatp->getDescription()).sticky_rect(calcScreenRect())); + break; + case STAT_SAMPLE: + LLToolTipMgr::instance().show(LLToolTip::Params().message(mStat.sampleStatp->getDescription()).sticky_rect(calcScreenRect())); + break; + case STAT_MEM: + LLToolTipMgr::instance().show(LLToolTip::Params().message(mStat.memStatp->getDescription()).sticky_rect(calcScreenRect())); + break; + default: + break; } return TRUE; } @@ -321,50 +328,69 @@ void LLStatBar::draw() : mNumShortHistoryFrames; S32 num_rapid_changes = 0; - if (mCountFloatp) - { - const LLTrace::TraceType& count_stat = *mCountFloatp; - - unit_label = std::string(count_stat.getUnitLabel()) + "/s"; - current = last_frame_recording.getPerSec(count_stat); - min = frame_recording.getPeriodMinPerSec(count_stat, num_frames); - max = frame_recording.getPeriodMaxPerSec(count_stat, num_frames); - mean = frame_recording.getPeriodMeanPerSec(count_stat, num_frames); - display_value = mean; - } - else if (mEventFloatp) - { - const LLTrace::TraceType& event_stat = *mEventFloatp; - - unit_label = mUnitLabel.empty() ? event_stat.getUnitLabel() : mUnitLabel; - current = last_frame_recording.getLastValue(event_stat); - min = frame_recording.getPeriodMin(event_stat, num_frames); - max = frame_recording.getPeriodMax(event_stat, num_frames); - mean = frame_recording.getPeriodMean(event_stat, num_frames); - num_rapid_changes = calc_num_rapid_changes(frame_recording, event_stat, RAPID_CHANGE_WINDOW); - display_value = mean; - } - else if (mSampleFloatp) + switch(mStatType) { - const LLTrace::TraceType& sample_stat = *mSampleFloatp; - - unit_label = mUnitLabel.empty() ? sample_stat.getUnitLabel() : mUnitLabel; - current = last_frame_recording.getLastValue(sample_stat); - min = frame_recording.getPeriodMin(sample_stat, num_frames); - max = frame_recording.getPeriodMax(sample_stat, num_frames); - mean = frame_recording.getPeriodMean(sample_stat, num_frames); - num_rapid_changes = calc_num_rapid_changes(frame_recording, sample_stat, RAPID_CHANGE_WINDOW); - - if (num_rapid_changes / RAPID_CHANGE_WINDOW.value() > MAX_RAPID_CHANGES_PER_SEC) + case STAT_COUNT: { + const LLTrace::TraceType& count_stat = *mStat.countStatp; + + unit_label = std::string(count_stat.getUnitLabel()) + "/s"; + current = last_frame_recording.getPerSec(count_stat); + min = frame_recording.getPeriodMinPerSec(count_stat, num_frames); + max = frame_recording.getPeriodMaxPerSec(count_stat, num_frames); + mean = frame_recording.getPeriodMeanPerSec(count_stat, num_frames); display_value = mean; } - else + break; + case STAT_EVENT: + { + const LLTrace::TraceType& event_stat = *mStat.eventStatp; + + unit_label = mUnitLabel.empty() ? event_stat.getUnitLabel() : mUnitLabel; + current = last_frame_recording.getLastValue(event_stat); + min = frame_recording.getPeriodMin(event_stat, num_frames); + max = frame_recording.getPeriodMax(event_stat, num_frames); + mean = frame_recording.getPeriodMean(event_stat, num_frames); + display_value = mean; + } + break; + case STAT_SAMPLE: + { + const LLTrace::TraceType& sample_stat = *mStat.sampleStatp; + + unit_label = mUnitLabel.empty() ? sample_stat.getUnitLabel() : mUnitLabel; + current = last_frame_recording.getLastValue(sample_stat); + min = frame_recording.getPeriodMin(sample_stat, num_frames); + max = frame_recording.getPeriodMax(sample_stat, num_frames); + mean = frame_recording.getPeriodMean(sample_stat, num_frames); + num_rapid_changes = calc_num_rapid_changes(frame_recording, sample_stat, RAPID_CHANGE_WINDOW); + + if (num_rapid_changes / RAPID_CHANGE_WINDOW.value() > MAX_RAPID_CHANGES_PER_SEC) + { + display_value = mean; + } + else + { + display_value = current; + // always display current value, don't rate limit + mLastDisplayValue = current; + } + } + break; + case STAT_MEM: { - display_value = current; - // always display current value, don't rate limit - mLastDisplayValue = current; + const LLTrace::TraceType& mem_stat = *mStat.memStatp; + + unit_label = mUnitLabel.empty() ? mem_stat.getUnitLabel() : mUnitLabel; + current = last_frame_recording.getLastValue(mem_stat).value(); + min = frame_recording.getPeriodMin(mem_stat, num_frames).value(); + max = frame_recording.getPeriodMax(mem_stat, num_frames).value(); + mean = frame_recording.getPeriodMean(mem_stat, num_frames).value(); + display_value = current; } + break; + default: + break; } LLRect bar_rect; @@ -405,8 +431,7 @@ void LLStatBar::draw() mLastDisplayValue = display_value; - if (mDisplayBar - && (mCountFloatp || mEventFloatp || mSampleFloatp)) + if (mDisplayBar && mStat.valid) { // Draw the tick marks. LLGLSUIDefault gls_ui; @@ -454,7 +479,7 @@ void LLStatBar::draw() ? (bar_rect.getWidth()) : (bar_rect.getHeight()); - if (mDisplayHistory && (mCountFloatp || mEventFloatp || mSampleFloatp)) + if (mDisplayHistory && mStat.valid) { const S32 num_values = frame_recording.getNumRecordedPeriods() - 1; F32 value = 0; @@ -468,22 +493,28 @@ void LLStatBar::draw() F32 offset = ((F32)i / (F32)num_frames) * span; LLTrace::Recording& recording = frame_recording.getPrevRecording(i); - if (mCountFloatp) - { - value = recording.getPerSec(*mCountFloatp); - num_samples = recording.getSampleCount(*mCountFloatp); - } - else if (mEventFloatp) + switch(mStatType) { - value = recording.getMean(*mEventFloatp); - num_samples = recording.getSampleCount(*mEventFloatp); + case STAT_COUNT: + value = recording.getPerSec(*mStat.countStatp); + num_samples = recording.getSampleCount(*mStat.countStatp); + break; + case STAT_EVENT: + value = recording.getMean(*mStat.eventStatp); + num_samples = recording.getSampleCount(*mStat.eventStatp); + break; + case STAT_SAMPLE: + value = recording.getMean(*mStat.sampleStatp); + num_samples = recording.getSampleCount(*mStat.sampleStatp); + break; + case STAT_MEM: + value = recording.getMean(*mStat.memStatp).value(); + num_samples = 1; + break; + default: + break; } - else if (mSampleFloatp) - { - value = recording.getMean(*mSampleFloatp); - num_samples = recording.getSampleCount(*mSampleFloatp); - } - + if (!num_samples) continue; F32 begin = (value - mCurMinBar) * value_scale; @@ -540,9 +571,32 @@ void LLStatBar::draw() void LLStatBar::setStat(const std::string& stat_name) { - mCountFloatp = LLTrace::TraceType::getInstance(stat_name); - mEventFloatp = LLTrace::TraceType::getInstance(stat_name); - mSampleFloatp = LLTrace::TraceType::getInstance(stat_name); + using namespace LLTrace; + const TraceType* count_stat; + const TraceType* event_stat; + const TraceType* sample_stat; + const TraceType* mem_stat; + + if ((count_stat = TraceType::getInstance(stat_name))) + { + mStat.countStatp = count_stat; + mStatType = STAT_COUNT; + } + else if ((event_stat = TraceType::getInstance(stat_name))) + { + mStat.eventStatp = event_stat; + mStatType = STAT_EVENT; + } + else if ((sample_stat = TraceType::getInstance(stat_name))) + { + mStat.sampleStatp = sample_stat; + mStatType = STAT_SAMPLE; + } + else if ((mem_stat = TraceType::getInstance(stat_name))) + { + mStat.memStatp = mem_stat; + mStatType = STAT_MEM; + } } @@ -688,6 +742,3 @@ void LLStatBar::drawTicks( F32 min, F32 max, F32 value_scale, LLRect &bar_rect ) } } } - - - -- cgit v1.2.3 From 6c856aba6bdb0d136133a344e13fe13978e1be01 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Thu, 19 Sep 2013 15:23:17 -0700 Subject: line endings fix --- indra/llui/llstatbar.cpp | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) (limited to 'indra/llui/llstatbar.cpp') diff --git a/indra/llui/llstatbar.cpp b/indra/llui/llstatbar.cpp index 9f96dd642d..a6f7dd0ea4 100755 --- a/indra/llui/llstatbar.cpp +++ b/indra/llui/llstatbar.cpp @@ -495,23 +495,23 @@ void LLStatBar::draw() switch(mStatType) { - case STAT_COUNT: - value = recording.getPerSec(*mStat.countStatp); - num_samples = recording.getSampleCount(*mStat.countStatp); - break; - case STAT_EVENT: - value = recording.getMean(*mStat.eventStatp); - num_samples = recording.getSampleCount(*mStat.eventStatp); - break; - case STAT_SAMPLE: - value = recording.getMean(*mStat.sampleStatp); - num_samples = recording.getSampleCount(*mStat.sampleStatp); - break; - case STAT_MEM: - value = recording.getMean(*mStat.memStatp).value(); - num_samples = 1; - break; - default: + case STAT_COUNT: + value = recording.getPerSec(*mStat.countStatp); + num_samples = recording.getSampleCount(*mStat.countStatp); + break; + case STAT_EVENT: + value = recording.getMean(*mStat.eventStatp); + num_samples = recording.getSampleCount(*mStat.eventStatp); + break; + case STAT_SAMPLE: + value = recording.getMean(*mStat.sampleStatp); + num_samples = recording.getSampleCount(*mStat.sampleStatp); + break; + case STAT_MEM: + value = recording.getMean(*mStat.memStatp).value(); + num_samples = 1; + break; + default: break; } -- cgit v1.2.3 From 05ec5ca3d592ed7c730026582a2573d04c6e4c16 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Thu, 19 Sep 2013 20:05:53 -0700 Subject: BUILDFIX: forgot forward declaration better overrides for memclaim and memdisclaim of sizes added occlusion stats to stats floater stats now render range instead of mean --- indra/llui/llstatbar.cpp | 46 ++++++++++++++++++++++++++-------------------- 1 file changed, 26 insertions(+), 20 deletions(-) (limited to 'indra/llui/llstatbar.cpp') diff --git a/indra/llui/llstatbar.cpp b/indra/llui/llstatbar.cpp index a6f7dd0ea4..222db70d2b 100755 --- a/indra/llui/llstatbar.cpp +++ b/indra/llui/llstatbar.cpp @@ -482,13 +482,14 @@ void LLStatBar::draw() if (mDisplayHistory && mStat.valid) { const S32 num_values = frame_recording.getNumRecordedPeriods() - 1; - F32 value = 0; - S32 i; - gGL.color4f( 1.f, 0.f, 0.f, 1.f ); + F32 min_value = 0.f, + max_value = 0.f; + + gGL.color4f(1.f, 0.f, 0.f, 1.f); gGL.begin( LLRender::QUADS ); const S32 max_frame = llmin(num_frames, num_values); U32 num_samples = 0; - for (i = 1; i <= max_frame; i++) + for (S32 i = 1; i <= max_frame; i++) { F32 offset = ((F32)i / (F32)num_frames) * span; LLTrace::Recording& recording = frame_recording.getPrevRecording(i); @@ -496,19 +497,23 @@ void LLStatBar::draw() switch(mStatType) { case STAT_COUNT: - value = recording.getPerSec(*mStat.countStatp); - num_samples = recording.getSampleCount(*mStat.countStatp); + min_value = recording.getPerSec(*mStat.countStatp); + max_value = min_value; + num_samples = recording.getSampleCount(*mStat.countStatp); break; case STAT_EVENT: - value = recording.getMean(*mStat.eventStatp); - num_samples = recording.getSampleCount(*mStat.eventStatp); + min_value = recording.getMin(*mStat.eventStatp); + max_value = recording.getMax(*mStat.eventStatp); + num_samples = recording.getSampleCount(*mStat.eventStatp); break; case STAT_SAMPLE: - value = recording.getMean(*mStat.sampleStatp); - num_samples = recording.getSampleCount(*mStat.sampleStatp); + min_value = recording.getMin(*mStat.sampleStatp); + max_value = recording.getMax(*mStat.sampleStatp); + num_samples = recording.getSampleCount(*mStat.sampleStatp); break; case STAT_MEM: - value = recording.getMean(*mStat.memStatp).value(); + min_value = recording.getMin(*mStat.memStatp).value(); + max_value = recording.getMax(*mStat.memStatp).value(); num_samples = 1; break; default: @@ -517,20 +522,21 @@ void LLStatBar::draw() if (!num_samples) continue; - F32 begin = (value - mCurMinBar) * value_scale; + F32 min = (min_value - mCurMinBar) * value_scale; + F32 max = llmax(min + 1, (max_value - mCurMinBar) * value_scale); if (mOrientation == HORIZONTAL) { - gGL.vertex2f((F32)bar_rect.mRight - offset, begin + 1); - gGL.vertex2f((F32)bar_rect.mRight - offset, begin); - gGL.vertex2f((F32)bar_rect.mRight - offset - 1, begin); - gGL.vertex2f((F32)bar_rect.mRight - offset - 1, begin + 1); + gGL.vertex2f((F32)bar_rect.mRight - offset, max); + gGL.vertex2f((F32)bar_rect.mRight - offset, min); + gGL.vertex2f((F32)bar_rect.mRight - offset - 1, min); + gGL.vertex2f((F32)bar_rect.mRight - offset - 1, max); } else { - gGL.vertex2f(begin, (F32)bar_rect.mBottom + offset + 1); - gGL.vertex2f(begin, (F32)bar_rect.mBottom + offset); - gGL.vertex2f(begin + 1, (F32)bar_rect.mBottom + offset); - gGL.vertex2f(begin + 1, (F32)bar_rect.mBottom + offset + 1 ); + gGL.vertex2f(min, (F32)bar_rect.mBottom + offset + 1); + gGL.vertex2f(min, (F32)bar_rect.mBottom + offset); + gGL.vertex2f(max, (F32)bar_rect.mBottom + offset); + gGL.vertex2f(max, (F32)bar_rect.mBottom + offset + 1 ); } } gGL.end(); -- cgit v1.2.3 From 4db06820f0a89d480a3d5c49c26313a3bb78544d Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Thu, 26 Sep 2013 11:34:07 -0700 Subject: fix for display of joystick statbar monitors --- indra/llui/llstatbar.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'indra/llui/llstatbar.cpp') diff --git a/indra/llui/llstatbar.cpp b/indra/llui/llstatbar.cpp index 222db70d2b..4ee10837b6 100755 --- a/indra/llui/llstatbar.cpp +++ b/indra/llui/llstatbar.cpp @@ -62,7 +62,7 @@ F32 calc_tick_value(F32 min, F32 max) { S32 divisor = DIVISORS[divisor_idx]; F32 possible_tick_value = range / divisor; - S32 num_whole_digits = llceil(logf(min + possible_tick_value) * OO_LN10); + S32 num_whole_digits = llceil(logf(llabs(min + possible_tick_value)) * OO_LN10); for (S32 digit_count = -(num_whole_digits - 1); digit_count < 6; digit_count++) { F32 test_tick_value = min + (possible_tick_value * pow(10.0, digit_count)); @@ -681,8 +681,8 @@ void LLStatBar::drawTicks( F32 min, F32 max, F32 value_scale, LLRect &bar_rect ) // start counting from actual min, not current, animating min, so that ticks don't float between numbers // ensure ticks always hit 0 - S32 last_tick = 0; - S32 last_label = 0; + S32 last_tick = S32_MIN; + S32 last_label = S32_MIN; if (mTickValue > 0.f && value_scale > 0.f) { const S32 MIN_TICK_SPACING = mOrientation == HORIZONTAL ? 20 : 30; @@ -697,7 +697,7 @@ void LLStatBar::drawTicks( F32 min, F32 max, F32 value_scale, LLRect &bar_rect ) { const S32 begin = llfloor((tick_value - mCurMinBar)*value_scale); const S32 end = begin + TICK_WIDTH; - if (begin - last_tick < MIN_TICK_SPACING) + if (begin < last_tick + MIN_TICK_SPACING) { continue; } @@ -712,7 +712,7 @@ void LLStatBar::drawTicks( F32 min, F32 max, F32 value_scale, LLRect &bar_rect ) if (mOrientation == HORIZONTAL) { - if (begin - last_label > MIN_LABEL_SPACING) + if (begin > last_label + MIN_LABEL_SPACING) { gl_rect_2d(bar_rect.mLeft, end, bar_rect.mRight - TICK_LENGTH, begin, LLColor4(1.f, 1.f, 1.f, 0.25f)); LLFontGL::getFontMonospace()->renderUTF8(tick_string, 0, bar_rect.mRight, begin, @@ -727,7 +727,7 @@ void LLStatBar::drawTicks( F32 min, F32 max, F32 value_scale, LLRect &bar_rect ) } else { - if (begin - last_label > MIN_LABEL_SPACING) + if (begin > last_label + MIN_LABEL_SPACING) { gl_rect_2d(begin, bar_rect.mTop, end, bar_rect.mBottom - TICK_LENGTH, LLColor4(1.f, 1.f, 1.f, 0.25f)); LLFontGL::getFontMonospace()->renderUTF8(tick_string, 0, begin - 1, bar_rect.mBottom - TICK_LENGTH, -- cgit v1.2.3 From e0a443f5a6b76fd1ab5ffaa8e7a1941d47c80f4f Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Fri, 27 Sep 2013 11:18:39 -0700 Subject: BUILDFIX: fix for mac builds also, fixed alignment of tick labels on stat bars --- indra/llui/llstatbar.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'indra/llui/llstatbar.cpp') diff --git a/indra/llui/llstatbar.cpp b/indra/llui/llstatbar.cpp index 4ee10837b6..bc8235132e 100755 --- a/indra/llui/llstatbar.cpp +++ b/indra/llui/llstatbar.cpp @@ -708,14 +708,14 @@ void LLStatBar::drawTicks( F32 min, F32 max, F32 value_scale, LLRect &bar_rect ) { decimal_digits = 0; } - std::string tick_string = llformat("%10.*f", decimal_digits, tick_value); - + std::string tick_label = llformat("%.*f", decimal_digits, tick_value); + S32 tick_label_width = LLFontGL::getFontMonospace()->getWidth(tick_label); if (mOrientation == HORIZONTAL) { if (begin > last_label + MIN_LABEL_SPACING) { gl_rect_2d(bar_rect.mLeft, end, bar_rect.mRight - TICK_LENGTH, begin, LLColor4(1.f, 1.f, 1.f, 0.25f)); - LLFontGL::getFontMonospace()->renderUTF8(tick_string, 0, bar_rect.mRight, begin, + LLFontGL::getFontMonospace()->renderUTF8(tick_label, 0, bar_rect.mRight, begin, LLColor4(1.f, 1.f, 1.f, 0.5f), LLFontGL::LEFT, LLFontGL::VCENTER); last_label = begin; @@ -730,10 +730,11 @@ void LLStatBar::drawTicks( F32 min, F32 max, F32 value_scale, LLRect &bar_rect ) if (begin > last_label + MIN_LABEL_SPACING) { gl_rect_2d(begin, bar_rect.mTop, end, bar_rect.mBottom - TICK_LENGTH, LLColor4(1.f, 1.f, 1.f, 0.25f)); - LLFontGL::getFontMonospace()->renderUTF8(tick_string, 0, begin - 1, bar_rect.mBottom - TICK_LENGTH, + S32 label_pos = begin - llround((F32)tick_label_width * ((F32)begin / (F32)bar_rect.getWidth())); + LLFontGL::getFontMonospace()->renderUTF8(tick_label, 0, label_pos, bar_rect.mBottom - TICK_LENGTH, LLColor4(1.f, 1.f, 1.f, 0.5f), - LLFontGL::RIGHT, LLFontGL::TOP); - last_label = begin; + LLFontGL::LEFT, LLFontGL::TOP); + last_label = label_pos; } else { -- cgit v1.2.3 From 17df8988fec3f2ba991ca9e34ff8148253a2fc04 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Mon, 7 Oct 2013 13:38:03 -0700 Subject: renamed TraceType to StatType added more MemTrackable types optimized memory usage of LLTrace some more --- indra/llui/llstatbar.cpp | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) (limited to 'indra/llui/llstatbar.cpp') diff --git a/indra/llui/llstatbar.cpp b/indra/llui/llstatbar.cpp index bc8235132e..24256c3193 100755 --- a/indra/llui/llstatbar.cpp +++ b/indra/llui/llstatbar.cpp @@ -284,7 +284,7 @@ S32 calc_num_rapid_changes(LLTrace::PeriodicRecording& periodic_recording, const return num_rapid_changes; } -S32 calc_num_rapid_changes(LLTrace::PeriodicRecording& periodic_recording, const LLTrace::TraceType& stat, const F32Seconds time_period) +S32 calc_num_rapid_changes(LLTrace::PeriodicRecording& periodic_recording, const LLTrace::StatType& stat, const F32Seconds time_period) { F32Seconds elapsed_time, time_since_value_changed; @@ -332,7 +332,7 @@ void LLStatBar::draw() { case STAT_COUNT: { - const LLTrace::TraceType& count_stat = *mStat.countStatp; + const LLTrace::StatType& count_stat = *mStat.countStatp; unit_label = std::string(count_stat.getUnitLabel()) + "/s"; current = last_frame_recording.getPerSec(count_stat); @@ -344,7 +344,7 @@ void LLStatBar::draw() break; case STAT_EVENT: { - const LLTrace::TraceType& event_stat = *mStat.eventStatp; + const LLTrace::StatType& event_stat = *mStat.eventStatp; unit_label = mUnitLabel.empty() ? event_stat.getUnitLabel() : mUnitLabel; current = last_frame_recording.getLastValue(event_stat); @@ -356,7 +356,7 @@ void LLStatBar::draw() break; case STAT_SAMPLE: { - const LLTrace::TraceType& sample_stat = *mStat.sampleStatp; + const LLTrace::StatType& sample_stat = *mStat.sampleStatp; unit_label = mUnitLabel.empty() ? sample_stat.getUnitLabel() : mUnitLabel; current = last_frame_recording.getLastValue(sample_stat); @@ -379,7 +379,7 @@ void LLStatBar::draw() break; case STAT_MEM: { - const LLTrace::TraceType& mem_stat = *mStat.memStatp; + const LLTrace::StatType& mem_stat = *mStat.memStatp; unit_label = mUnitLabel.empty() ? mem_stat.getUnitLabel() : mUnitLabel; current = last_frame_recording.getLastValue(mem_stat).value(); @@ -578,27 +578,27 @@ void LLStatBar::draw() void LLStatBar::setStat(const std::string& stat_name) { using namespace LLTrace; - const TraceType* count_stat; - const TraceType* event_stat; - const TraceType* sample_stat; - const TraceType* mem_stat; + const StatType* count_stat; + const StatType* event_stat; + const StatType* sample_stat; + const StatType* mem_stat; - if ((count_stat = TraceType::getInstance(stat_name))) + if ((count_stat = StatType::getInstance(stat_name))) { mStat.countStatp = count_stat; mStatType = STAT_COUNT; } - else if ((event_stat = TraceType::getInstance(stat_name))) + else if ((event_stat = StatType::getInstance(stat_name))) { mStat.eventStatp = event_stat; mStatType = STAT_EVENT; } - else if ((sample_stat = TraceType::getInstance(stat_name))) + else if ((sample_stat = StatType::getInstance(stat_name))) { mStat.sampleStatp = sample_stat; mStatType = STAT_SAMPLE; } - else if ((mem_stat = TraceType::getInstance(stat_name))) + else if ((mem_stat = StatType::getInstance(stat_name))) { mStat.memStatp = mem_stat; mStatType = STAT_MEM; -- cgit v1.2.3 From 155ca2f926afcbfd86b42ce6db68684ed266ef67 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Tue, 29 Oct 2013 16:23:53 -0700 Subject: fixed timer bars not appearing in fast timer view fixed "bouncing" stat values when a value ended in zeroes --- indra/llui/llstatbar.cpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'indra/llui/llstatbar.cpp') diff --git a/indra/llui/llstatbar.cpp b/indra/llui/llstatbar.cpp index 24256c3193..2b325c27f0 100755 --- a/indra/llui/llstatbar.cpp +++ b/indra/llui/llstatbar.cpp @@ -327,6 +327,7 @@ void LLStatBar::draw() ? mNumHistoryFrames : mNumShortHistoryFrames; S32 num_rapid_changes = 0; + S32 decimal_digits = mDecimalDigits; switch(mStatType) { @@ -374,6 +375,10 @@ void LLStatBar::draw() display_value = current; // always display current value, don't rate limit mLastDisplayValue = current; + if (is_approx_equal((F32)(S32)display_value, display_value)) + { + decimal_digits = 0; + } } } break; @@ -412,12 +417,6 @@ void LLStatBar::draw() mCurMaxBar = LLSmoothInterpolation::lerp(mCurMaxBar, mMaxBar, 0.05f); mCurMinBar = LLSmoothInterpolation::lerp(mCurMinBar, mMinBar, 0.05f); - S32 decimal_digits = mDecimalDigits; - if (is_approx_equal((F32)(S32)display_value, display_value)) - { - decimal_digits = 0; - } - // rate limited updates if (mLastDisplayValueTimer.getElapsedTimeF32() < MEAN_VALUE_UPDATE_TIME) { -- cgit v1.2.3 From ea2494a0839ec02d3889a405306009c2f4f9aea7 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Wed, 30 Oct 2013 00:37:11 -0700 Subject: stats now autoscale back down in range, instead of sticking at high water mark --- indra/llui/llstatbar.cpp | 132 ++++++++++++++++++++--------------------------- 1 file changed, 57 insertions(+), 75 deletions(-) (limited to 'indra/llui/llstatbar.cpp') diff --git a/indra/llui/llstatbar.cpp b/indra/llui/llstatbar.cpp index 2b325c27f0..bfdc6571c2 100755 --- a/indra/llui/llstatbar.cpp +++ b/indra/llui/llstatbar.cpp @@ -176,8 +176,8 @@ LLStatBar::LLStatBar(const Params& p) : LLView(p), mLabel(p.label), mUnitLabel(p.unit_label), - mMinBar(llmin(p.bar_min, p.bar_max)), - mMaxBar(llmax(p.bar_max, p.bar_min)), + mTargetMinBar(llmin(p.bar_min, p.bar_max)), + mTargetMaxBar(llmax(p.bar_max, p.bar_min)), mCurMaxBar(p.bar_max), mCurMinBar(0), mDecimalDigits(p.decimal_digits), @@ -189,15 +189,18 @@ LLStatBar::LLStatBar(const Params& p) mOrientation(p.orientation), mAutoScaleMax(!p.bar_max.isProvided()), mAutoScaleMin(!p.bar_min.isProvided()), - mTickValue(p.tick_spacing), + mTickSpacing(p.tick_spacing), mLastDisplayValue(0.f), mStatType(STAT_NONE) { + mFloatingTargetMinBar = mTargetMinBar; + mFloatingTargetMaxBar = mTargetMaxBar; + mStat.valid = NULL; // tick value will be automatically calculated later if (!p.tick_spacing.isProvided() && p.bar_min.isProvided() && p.bar_max.isProvided()) { - mTickValue = calc_tick_value(mMinBar, mMaxBar); + mTickSpacing = calc_tick_value(mTargetMinBar, mTargetMaxBar); } setStat(p.stat); @@ -259,12 +262,12 @@ BOOL LLStatBar::handleMouseDown(S32 x, S32 y, MASK mask) template S32 calc_num_rapid_changes(LLTrace::PeriodicRecording& periodic_recording, const T& stat, const F32Seconds time_period) { - F32Seconds elapsed_time, - time_since_value_changed; - S32 num_rapid_changes = 0; - const F32Seconds RAPID_CHANGE_THRESHOLD = F32Seconds(0.3f); + F32Seconds elapsed_time, + time_since_value_changed; + S32 num_rapid_changes = 0; + const F32Seconds RAPID_CHANGE_THRESHOLD = F32Seconds(0.3f); + F64 last_value = periodic_recording.getPrevRecording(1).getLastValue(stat); - F64 last_value = periodic_recording.getPrevRecording(1).getLastValue(stat); for (S32 i = 2; i < periodic_recording.getNumRecordedPeriods(); i++) { LLTrace::Recording& recording = periodic_recording.getPrevRecording(i); @@ -284,32 +287,6 @@ S32 calc_num_rapid_changes(LLTrace::PeriodicRecording& periodic_recording, const return num_rapid_changes; } -S32 calc_num_rapid_changes(LLTrace::PeriodicRecording& periodic_recording, const LLTrace::StatType& stat, const F32Seconds time_period) -{ - F32Seconds elapsed_time, - time_since_value_changed; - S32 num_rapid_changes = 0; - - F64 last_value = periodic_recording.getPrevRecording(1).getSum(stat); - for (S32 i = 1; i < periodic_recording.getNumRecordedPeriods(); i++) - { - LLTrace::Recording& recording = periodic_recording.getPrevRecording(i); - F64 cur_value = recording.getSum(stat); - - if (last_value != cur_value) - { - if (time_since_value_changed < RAPID_CHANGE_THRESHOLD) num_rapid_changes++; - time_since_value_changed = (F32Seconds)0; - } - last_value = cur_value; - - elapsed_time += recording.getDuration(); - if (elapsed_time > time_period) break; - } - - return num_rapid_changes; -} - void LLStatBar::draw() { LLLocalClipRect _(getLocalRect()); @@ -318,16 +295,16 @@ void LLStatBar::draw() LLTrace::Recording& last_frame_recording = frame_recording.getLastRecording(); std::string unit_label; - F32 current = 0, - min = 0, - max = 0, - mean = 0, - display_value = 0; - S32 num_frames = mDisplayHistory - ? mNumHistoryFrames - : mNumShortHistoryFrames; - S32 num_rapid_changes = 0; - S32 decimal_digits = mDecimalDigits; + F32 current = 0, + min = 0, + max = 0, + mean = 0, + display_value = 0; + S32 num_frames = mDisplayHistory + ? mNumHistoryFrames + : mNumShortHistoryFrames; + S32 num_rapid_changes = 0; + S32 decimal_digits = mDecimalDigits; switch(mStatType) { @@ -414,8 +391,8 @@ void LLStatBar::draw() bar_rect.mBottom = llmin(bar_rect.mTop - 5, 20); } - mCurMaxBar = LLSmoothInterpolation::lerp(mCurMaxBar, mMaxBar, 0.05f); - mCurMinBar = LLSmoothInterpolation::lerp(mCurMinBar, mMinBar, 0.05f); + mCurMaxBar = LLSmoothInterpolation::lerp(mCurMaxBar, mTargetMaxBar, 0.05f); + mCurMinBar = LLSmoothInterpolation::lerp(mCurMinBar, mTargetMinBar, 0.05f); // rate limited updates if (mLastDisplayValueTimer.getElapsedTimeF32() < MEAN_VALUE_UPDATE_TIME) @@ -429,7 +406,6 @@ void LLStatBar::draw() drawLabelAndValue(display_value, unit_label, bar_rect, decimal_digits); mLastDisplayValue = display_value; - if (mDisplayBar && mStat.valid) { // Draw the tick marks. @@ -607,9 +583,11 @@ void LLStatBar::setStat(const std::string& stat_name) void LLStatBar::setRange(F32 bar_min, F32 bar_max) { - mMinBar = llmin(bar_min, bar_max); - mMaxBar = llmax(bar_min, bar_max); - mTickValue = calc_tick_value(mMinBar, mMaxBar); + mTargetMinBar = llmin(bar_min, bar_max); + mTargetMaxBar = llmax(bar_min, bar_max); + mFloatingTargetMinBar = mTargetMinBar; + mFloatingTargetMaxBar = mTargetMaxBar; + mTickSpacing = calc_tick_value(mTargetMinBar, mTargetMaxBar); } LLRect LLStatBar::getRequiredRect() @@ -660,21 +638,24 @@ void LLStatBar::drawLabelAndValue( F32 value, std::string &label, LLRect &bar_re void LLStatBar::drawTicks( F32 min, F32 max, F32 value_scale, LLRect &bar_rect ) { - if ((mAutoScaleMax && max >= mCurMaxBar)|| (mAutoScaleMin && min <= mCurMinBar)) + if (mAutoScaleMax || mAutoScaleMin) { - F32 range_min = mAutoScaleMin ? llmin(mMinBar, min) : mMinBar; - F32 range_max = mAutoScaleMax ? llmax(mMaxBar, max) : mMaxBar; + F32 u = LLSmoothInterpolation::getInterpolant(10.f); + mFloatingTargetMinBar = llmin(min, lerp(mFloatingTargetMinBar, min, u)); + mFloatingTargetMaxBar = llmax(max, lerp(mFloatingTargetMaxBar, max, u)); + F32 range_min = mAutoScaleMin ? mFloatingTargetMinBar : mTargetMinBar; + F32 range_max = mAutoScaleMax ? mFloatingTargetMaxBar : mTargetMaxBar; F32 tick_value = 0.f; calc_auto_scale_range(range_min, range_max, tick_value); - if (mAutoScaleMin) { mMinBar = range_min; } - if (mAutoScaleMax) { mMaxBar = range_max; } + if (mAutoScaleMin) { mTargetMinBar = range_min; } + if (mAutoScaleMax) { mTargetMaxBar = range_max; } if (mAutoScaleMin && mAutoScaleMax) { - mTickValue = tick_value; + mTickSpacing = tick_value; } else { - mTickValue = calc_tick_value(mMinBar, mMaxBar); + mTickSpacing = calc_tick_value(mTargetMinBar, mTargetMaxBar); } } @@ -682,7 +663,7 @@ void LLStatBar::drawTicks( F32 min, F32 max, F32 value_scale, LLRect &bar_rect ) // ensure ticks always hit 0 S32 last_tick = S32_MIN; S32 last_label = S32_MIN; - if (mTickValue > 0.f && value_scale > 0.f) + if (mTickSpacing > 0.f && value_scale > 0.f) { const S32 MIN_TICK_SPACING = mOrientation == HORIZONTAL ? 20 : 30; const S32 MIN_LABEL_SPACING = mOrientation == HORIZONTAL ? 30 : 60; @@ -690,17 +671,18 @@ void LLStatBar::drawTicks( F32 min, F32 max, F32 value_scale, LLRect &bar_rect ) const S32 TICK_WIDTH = 1; F32 start = mCurMinBar < 0.f - ? llceil(-mCurMinBar / mTickValue) * -mTickValue + ? llceil(-mCurMinBar / mTickSpacing) * -mTickSpacing : 0.f; - for (F32 tick_value = start; ;tick_value += mTickValue) + for (F32 tick_value = start; ;tick_value += mTickSpacing) { - const S32 begin = llfloor((tick_value - mCurMinBar)*value_scale); - const S32 end = begin + TICK_WIDTH; - if (begin < last_tick + MIN_TICK_SPACING) + // clamp to S32_MAX / 2 to avoid floating point to integer overflow resulting in S32_MIN + const S32 tick_begin = llfloor(llmin((F32)(S32_MAX / 2), (tick_value - mCurMinBar)*value_scale)); + const S32 tick_end = tick_begin + TICK_WIDTH; + if (tick_begin < last_tick + MIN_TICK_SPACING) { continue; } - last_tick = begin; + last_tick = tick_begin; S32 decimal_digits = mDecimalDigits; if (is_approx_equal((F32)(S32)tick_value, tick_value)) @@ -711,25 +693,25 @@ void LLStatBar::drawTicks( F32 min, F32 max, F32 value_scale, LLRect &bar_rect ) S32 tick_label_width = LLFontGL::getFontMonospace()->getWidth(tick_label); if (mOrientation == HORIZONTAL) { - if (begin > last_label + MIN_LABEL_SPACING) + if (tick_begin > last_label + MIN_LABEL_SPACING) { - gl_rect_2d(bar_rect.mLeft, end, bar_rect.mRight - TICK_LENGTH, begin, LLColor4(1.f, 1.f, 1.f, 0.25f)); - LLFontGL::getFontMonospace()->renderUTF8(tick_label, 0, bar_rect.mRight, begin, + gl_rect_2d(bar_rect.mLeft, tick_end, bar_rect.mRight - TICK_LENGTH, tick_begin, LLColor4(1.f, 1.f, 1.f, 0.25f)); + LLFontGL::getFontMonospace()->renderUTF8(tick_label, 0, bar_rect.mRight, tick_begin, LLColor4(1.f, 1.f, 1.f, 0.5f), LLFontGL::LEFT, LLFontGL::VCENTER); - last_label = begin; + last_label = tick_begin; } else { - gl_rect_2d(bar_rect.mLeft, end, bar_rect.mRight - TICK_LENGTH/2, begin, LLColor4(1.f, 1.f, 1.f, 0.1f)); + gl_rect_2d(bar_rect.mLeft, tick_end, bar_rect.mRight - TICK_LENGTH/2, tick_begin, LLColor4(1.f, 1.f, 1.f, 0.1f)); } } else { - if (begin > last_label + MIN_LABEL_SPACING) + if (tick_begin > last_label + MIN_LABEL_SPACING) { - gl_rect_2d(begin, bar_rect.mTop, end, bar_rect.mBottom - TICK_LENGTH, LLColor4(1.f, 1.f, 1.f, 0.25f)); - S32 label_pos = begin - llround((F32)tick_label_width * ((F32)begin / (F32)bar_rect.getWidth())); + gl_rect_2d(tick_begin, bar_rect.mTop, tick_end, bar_rect.mBottom - TICK_LENGTH, LLColor4(1.f, 1.f, 1.f, 0.25f)); + S32 label_pos = tick_begin - llround((F32)tick_label_width * ((F32)tick_begin / (F32)bar_rect.getWidth())); LLFontGL::getFontMonospace()->renderUTF8(tick_label, 0, label_pos, bar_rect.mBottom - TICK_LENGTH, LLColor4(1.f, 1.f, 1.f, 0.5f), LLFontGL::LEFT, LLFontGL::TOP); @@ -737,10 +719,10 @@ void LLStatBar::drawTicks( F32 min, F32 max, F32 value_scale, LLRect &bar_rect ) } else { - gl_rect_2d(begin, bar_rect.mTop, end, bar_rect.mBottom - TICK_LENGTH/2, LLColor4(1.f, 1.f, 1.f, 0.1f)); + gl_rect_2d(tick_begin, bar_rect.mTop, tick_end, bar_rect.mBottom - TICK_LENGTH/2, LLColor4(1.f, 1.f, 1.f, 0.1f)); } } - // always draw one tick value past end, so we can see part of the text, if possible + // always draw one tick value past tick_end, so we can see part of the text, if possible if (tick_value > mCurMaxBar) { break; -- cgit v1.2.3 From 391ac367d6922f30bf3a186bc15e1fc38366eecf Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Tue, 19 Nov 2013 17:40:44 -0800 Subject: SH-4634 FIX Interesting: Viewer crashes when receiving teleport offer renamed fast timers to have unique names, changes instance tracker to never allow duplicates --- indra/llui/llstatbar.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'indra/llui/llstatbar.cpp') diff --git a/indra/llui/llstatbar.cpp b/indra/llui/llstatbar.cpp index bfdc6571c2..1bd2bc06f4 100755 --- a/indra/llui/llstatbar.cpp +++ b/indra/llui/llstatbar.cpp @@ -553,10 +553,10 @@ void LLStatBar::draw() void LLStatBar::setStat(const std::string& stat_name) { using namespace LLTrace; - const StatType* count_stat; - const StatType* event_stat; - const StatType* sample_stat; - const StatType* mem_stat; + const StatType* count_stat; + const StatType* event_stat; + const StatType* sample_stat; + const StatType* mem_stat; if ((count_stat = StatType::getInstance(stat_name))) { -- cgit v1.2.3