diff options
author | Richard Linden <none@none> | 2013-04-11 19:12:27 -0700 |
---|---|---|
committer | Richard Linden <none@none> | 2013-04-11 19:12:27 -0700 |
commit | bdc6d58b7e84bc81977148995b0028f7420eee65 (patch) | |
tree | 9bb49c521a79b5da1d2e510c7a5691b971135fa8 /indra/llcommon | |
parent | ae028e79872f166db8e514ca3b442c7807d6ebdb (diff) |
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
Diffstat (limited to 'indra/llcommon')
-rw-r--r-- | indra/llcommon/lltracerecording.h | 74 |
1 files changed, 48 insertions, 26 deletions
diff --git a/indra/llcommon/lltracerecording.h b/indra/llcommon/lltracerecording.h index 9ebcbdd8ce..6cf6f4f84f 100644 --- a/indra/llcommon/lltracerecording.h +++ b/indra/llcommon/lltracerecording.h @@ -297,63 +297,80 @@ namespace LLTrace } template <typename T> - typename T::value_t getPeriodMin(const TraceType<T>& stat) const + typename T::value_t getPeriodMin(const TraceType<T>& stat, U32 num_periods = S32_MAX) const { + size_t total_periods = mRecordingPeriods.size(); + num_periods = llmin(num_periods, total_periods); + typename T::value_t min_val = (std::numeric_limits<typename T::value_t>::max)(); - U32 num_periods = mRecordingPeriods.size(); - for (S32 i = 0; i < num_periods; i++) + for (S32 i = 1; i <= num_periods; i++) { - min_val = llmin(min_val, mRecordingPeriods[(mCurPeriod + i) % num_periods].getSum(stat)); + S32 index = (mCurPeriod + total_periods - i) % total_periods; + min_val = llmin(min_val, mRecordingPeriods[index].getSum(stat)); } return min_val; } template <typename T> - F64 getPeriodMinPerSec(const TraceType<T>& stat) const + F64 getPeriodMinPerSec(const TraceType<T>& stat, U32 num_periods = S32_MAX) const { + size_t total_periods = mRecordingPeriods.size(); + num_periods = llmin(num_periods, total_periods); + F64 min_val = (std::numeric_limits<F64>::max)(); - U32 num_periods = mRecordingPeriods.size(); - for (S32 i = 0; i < num_periods; i++) + for (S32 i = 1; i <= num_periods; i++) { - min_val = llmin(min_val, mRecordingPeriods[(mCurPeriod + i) % num_periods].getPerSec(stat)); + S32 index = (mCurPeriod + total_periods - i) % total_periods; + min_val = llmin(min_val, mRecordingPeriods[index].getPerSec(stat)); } return min_val; } template <typename T> - typename T::value_t getPeriodMax(const TraceType<T>& stat) const + typename T::value_t getPeriodMax(const TraceType<T>& stat, U32 num_periods = S32_MAX) const { + size_t total_periods = mRecordingPeriods.size(); + num_periods = llmin(num_periods, total_periods); + typename T::value_t max_val = (std::numeric_limits<typename T::value_t>::min)(); - U32 num_periods = mRecordingPeriods.size(); - for (S32 i = 0; i < num_periods; i++) + for (S32 i = 1; i <= num_periods; i++) { - max_val = llmax(max_val, mRecordingPeriods[(mCurPeriod + i) % num_periods].getSum(stat)); + S32 index = (mCurPeriod + total_periods - i) % total_periods; + max_val = llmax(max_val, mRecordingPeriods[index].getSum(stat)); } return max_val; } template <typename T> - F64 getPeriodMaxPerSec(const TraceType<T>& stat) const + F64 getPeriodMaxPerSec(const TraceType<T>& stat, U32 num_periods = S32_MAX) const { + size_t total_periods = mRecordingPeriods.size(); + num_periods = llmin(num_periods, total_periods); + F64 max_val = (std::numeric_limits<F64>::min)(); - U32 num_periods = mRecordingPeriods.size(); - for (S32 i = 1; i < num_periods; i++) + for (S32 i = 1; i <= num_periods; i++) { - max_val = llmax(max_val, mRecordingPeriods[(mCurPeriod + i) % num_periods].getPerSec(stat)); + S32 index = (mCurPeriod + total_periods - i) % total_periods; + max_val = llmax(max_val, mRecordingPeriods[index].getPerSec(stat)); } return max_val; } template <typename T> - typename T::value_t getPeriodMean(const TraceType<T>& stat) const + typename T::value_t getPeriodMean(const TraceType<T>& stat, U32 num_periods = S32_MAX) const { + size_t total_periods = mRecordingPeriods.size(); + num_periods = llmin(num_periods, total_periods); + typename T::value_t mean = 0.0; - U32 num_periods = mRecordingPeriods.size(); - for (S32 i = 0; i < num_periods; i++) + if (num_periods <= 0) { return mean; } + + for (S32 i = 1; i <= num_periods; i++) { - if (mRecordingPeriods[(mCurPeriod + i) % num_periods].getDuration() > 0.f) + S32 index = (mCurPeriod + total_periods - i) % total_periods; + if (mRecordingPeriods[index].getDuration() > 0.f) { - mean += mRecordingPeriods[(mCurPeriod + i) % num_periods].getSum(stat); + mean += mRecordingPeriods[index].getSum(stat); } } mean /= num_periods; @@ -361,15 +378,20 @@ namespace LLTrace } template <typename T> - typename T::value_t getPeriodMeanPerSec(const TraceType<T>& stat) const + typename T::value_t getPeriodMeanPerSec(const TraceType<T>& stat, U32 num_periods = S32_MAX) const { + size_t total_periods = mRecordingPeriods.size(); + num_periods = llmin(num_periods, total_periods); + typename T::value_t mean = 0.0; - U32 num_periods = mRecordingPeriods.size(); - for (S32 i = 0; i < num_periods; i++) + if (num_periods <= 0) { return mean; } + + for (S32 i = 1; i <= num_periods; i++) { - if (mRecordingPeriods[i].getDuration() > 0.f) + S32 index = (mCurPeriod + total_periods - i) % total_periods; + if (mRecordingPeriods[index].getDuration() > 0.f) { - mean += mRecordingPeriods[(mCurPeriod + i) % num_periods].getPerSec(stat); + mean += mRecordingPeriods[index].getPerSec(stat); } } mean /= num_periods; |