diff options
author | Richard Linden <none@none> | 2013-07-23 16:42:22 -0700 |
---|---|---|
committer | Richard Linden <none@none> | 2013-07-23 16:42:22 -0700 |
commit | 0127e66228acd41402da9acab8ce91d394c3096f (patch) | |
tree | 5b4016402e3a1c7c09ae99f6a397f4cb5fb9598f | |
parent | 40a7c63e897cee5905270602be4387f5eb4fc2b8 (diff) |
stat bars with no stats now show n/a instead of o
-rw-r--r-- | indra/llcommon/lltracerecording.h | 15 | ||||
-rwxr-xr-x | indra/llui/llstatbar.cpp | 180 |
2 files changed, 111 insertions, 84 deletions
diff --git a/indra/llcommon/lltracerecording.h b/indra/llcommon/lltracerecording.h index 31616a52cc..f5e4ea603c 100644 --- a/indra/llcommon/lltracerecording.h +++ b/indra/llcommon/lltracerecording.h @@ -333,6 +333,21 @@ namespace LLTrace const Recording& getPrevRecording(U32 offset) const; Recording snapshotCurRecording() const; + template <typename T> + size_t getSampleCount(const TraceType<T>& stat, size_t num_periods = U32_MAX) + { + size_t total_periods = mNumPeriods; + num_periods = llmin(num_periods, isStarted() ? total_periods - 1 : total_periods); + + size_t num_samples = 0; + for (S32 i = 1; i <= num_periods; i++) + { + S32 index = (mCurPeriod + total_periods - i) % total_periods; + num_samples += mRecordingPeriods[index].getSampleCount(stat); + } + return num_samples; + } + // // PERIODIC MIN // 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(); |