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/llcommon/lltracerecording.h | 244 ++++++++++++++++++++++++++++++++------ 1 file changed, 206 insertions(+), 38 deletions(-) (limited to 'indra/llcommon/lltracerecording.h') diff --git a/indra/llcommon/lltracerecording.h b/indra/llcommon/lltracerecording.h index b339e72e5c..19a4fae737 100644 --- a/indra/llcommon/lltracerecording.h +++ b/indra/llcommon/lltracerecording.h @@ -117,11 +117,14 @@ namespace LLTrace void append(const RecordingBuffers& other); void merge(const RecordingBuffers& other); void reset(RecordingBuffers* other = NULL); + void flush(); AccumulatorBuffer > mCountsFloat; - AccumulatorBuffer > mMeasurementsFloat; AccumulatorBuffer > mCounts; - AccumulatorBuffer > mMeasurements; + AccumulatorBuffer > mSamplesFloat; + AccumulatorBuffer > mSamples; + AccumulatorBuffer > mEventsFloat; + AccumulatorBuffer > mEvents; AccumulatorBuffer mStackTimers; AccumulatorBuffer mMemStats; }; @@ -181,57 +184,101 @@ namespace LLTrace U32 getSampleCount(const TraceType >& stat) const; - // MeasurementStatHandle accessors - F64 getSum(const TraceType >& stat) const; - S64 getSum(const TraceType >& stat) const; + // SampleStatHandle accessors + F64 getMin(const TraceType >& stat) const; + S64 getMin(const TraceType >& stat) const; template - T getSum(const MeasurementStatHandle& stat) const + T getMin(const SampleStatHandle& stat) const { - return (T)getSum(static_cast::type_t> >&> (stat)); + return (T)getMin(static_cast::type_t> >&> (stat)); } - F64 getMin(const TraceType >& stat) const; - S64 getMin(const TraceType >& stat) const; + F64 getMax(const TraceType >& stat) const; + S64 getMax(const TraceType >& stat) const; template - T getMin(const MeasurementStatHandle& stat) const + T getMax(const SampleStatHandle& stat) const { - return (T)getMin(static_cast::type_t> >&> (stat)); + return (T)getMax(static_cast::type_t> >&> (stat)); } - F64 getMax(const TraceType >& stat) const; - S64 getMax(const TraceType >& stat) const; + F64 getMean(const TraceType >& stat) const; + F64 getMean(const TraceType >& stat) const; template - T getMax(const MeasurementStatHandle& stat) const + T getMean(SampleStatHandle& stat) const { - return (T)getMax(static_cast::type_t> >&> (stat)); + return (T)getMean(static_cast::type_t> >&> (stat)); } - F64 getMean(const TraceType >& stat) const; - F64 getMean(const TraceType >& stat) const; + F64 getStandardDeviation(const TraceType >& stat) const; + F64 getStandardDeviation(const TraceType >& stat) const; template - T getMean(MeasurementStatHandle& stat) const + T getStandardDeviation(const SampleStatHandle& stat) const { - return (T)getMean(static_cast::type_t> >&> (stat)); + return (T)getStandardDeviation(static_cast::type_t> >&> (stat)); } - F64 getStandardDeviation(const TraceType >& stat) const; - F64 getStandardDeviation(const TraceType >& stat) const; + F64 getLastValue(const TraceType >& stat) const; + S64 getLastValue(const TraceType >& stat) const; template - T getStandardDeviation(const MeasurementStatHandle& stat) const + T getLastValue(const SampleStatHandle& stat) const { - return (T)getMean(static_cast::type_t> >&> (stat)); + return (T)getLastValue(static_cast::type_t> >&> (stat)); } - F64 getLastValue(const TraceType >& stat) const; - S64 getLastValue(const TraceType >& stat) const; + U32 getSampleCount(const TraceType >& stat) const; + U32 getSampleCount(const TraceType >& stat) const; + + // EventStatHandle accessors + F64 getSum(const TraceType >& stat) const; + S64 getSum(const TraceType >& stat) const; + template + T getSum(const EventStatHandle& stat) const + { + return (T)getSum(static_cast::type_t> >&> (stat)); + } + + F64 getMin(const TraceType >& stat) const; + S64 getMin(const TraceType >& stat) const; + template + T getMin(const EventStatHandle& stat) const + { + return (T)getMin(static_cast::type_t> >&> (stat)); + } + + F64 getMax(const TraceType >& stat) const; + S64 getMax(const TraceType >& stat) const; + template + T getMax(const EventStatHandle& stat) const + { + return (T)getMax(static_cast::type_t> >&> (stat)); + } + + F64 getMean(const TraceType >& stat) const; + F64 getMean(const TraceType >& stat) const; + template + T getMean(EventStatHandle& stat) const + { + return (T)getMean(static_cast::type_t> >&> (stat)); + } + + F64 getStandardDeviation(const TraceType >& stat) const; + F64 getStandardDeviation(const TraceType >& stat) const; + template + T getStandardDeviation(const EventStatHandle& stat) const + { + return (T)getStandardDeviation(static_cast::type_t> >&> (stat)); + } + + F64 getLastValue(const TraceType >& stat) const; + S64 getLastValue(const TraceType >& stat) const; template - T getLastValue(const MeasurementStatHandle& stat) const + T getLastValue(const EventStatHandle& stat) const { - return (T)getLastValue(static_cast::type_t> >&> (stat)); + return (T)getLastValue(static_cast::type_t> >&> (stat)); } - U32 getSampleCount(const TraceType >& stat) const; - U32 getSampleCount(const TraceType >& stat) const; + U32 getSampleCount(const TraceType >& stat) const; + U32 getSampleCount(const TraceType >& stat) const; LLUnit getDuration() const { return LLUnit(mElapsedSeconds); } @@ -272,13 +319,14 @@ namespace LLTrace const Recording& getPrevRecording(U32 offset) const; Recording snapshotCurRecording() const; + // catch all for stats that have a defined sum template typename T::value_t getPeriodMin(const TraceType& stat, size_t num_periods = U32_MAX) const { size_t total_periods = mRecordingPeriods.size(); num_periods = llmin(num_periods, total_periods); - typename T::value_t min_val = (std::numeric_limits::max)(); + typename T::value_t min_val = std::numeric_limits::max(); for (S32 i = 1; i <= num_periods; i++) { S32 index = (mCurPeriod + total_periods - i) % total_periods; @@ -287,13 +335,43 @@ namespace LLTrace return min_val; } + template + typename T getPeriodMin(const TraceType >& stat, size_t num_periods = U32_MAX) const + { + size_t total_periods = mRecordingPeriods.size(); + num_periods = llmin(num_periods, total_periods); + + typename T min_val = std::numeric_limits::max(); + for (S32 i = 1; i <= num_periods; i++) + { + S32 index = (mCurPeriod + total_periods - i) % total_periods; + min_val = llmin(min_val, mRecordingPeriods[index].getMin(stat)); + } + return min_val; + } + + template + typename T getPeriodMin(const TraceType >& stat, size_t num_periods = U32_MAX) const + { + size_t total_periods = mRecordingPeriods.size(); + num_periods = llmin(num_periods, total_periods); + + typename T min_val = std::numeric_limits::max(); + for (S32 i = 1; i <= num_periods; i++) + { + S32 index = (mCurPeriod + total_periods - i) % total_periods; + min_val = llmin(min_val, mRecordingPeriods[index].getMin(stat)); + } + return min_val; + } + template F64 getPeriodMinPerSec(const TraceType& stat, size_t num_periods = U32_MAX) const { size_t total_periods = mRecordingPeriods.size(); num_periods = llmin(num_periods, total_periods); - F64 min_val = (std::numeric_limits::max)(); + F64 min_val = std::numeric_limits::max(); for (S32 i = 1; i <= num_periods; i++) { S32 index = (mCurPeriod + total_periods - i) % total_periods; @@ -302,13 +380,14 @@ namespace LLTrace return min_val; } + // catch all for stats that have a defined sum template typename T::value_t getPeriodMax(const TraceType& stat, size_t num_periods = U32_MAX) const { size_t total_periods = mRecordingPeriods.size(); num_periods = llmin(num_periods, total_periods); - typename T::value_t max_val = (std::numeric_limits::min)(); + typename T::value_t max_val = std::numeric_limits::min(); for (S32 i = 1; i <= num_periods; i++) { S32 index = (mCurPeriod + total_periods - i) % total_periods; @@ -317,13 +396,43 @@ namespace LLTrace return max_val; } + template + typename T getPeriodMax(const TraceType >& stat, size_t num_periods = U32_MAX) const + { + size_t total_periods = mRecordingPeriods.size(); + num_periods = llmin(num_periods, total_periods); + + typename T max_val = std::numeric_limits::min(); + for (S32 i = 1; i <= num_periods; i++) + { + S32 index = (mCurPeriod + total_periods - i) % total_periods; + max_val = llmax(max_val, mRecordingPeriods[index].getMax(stat)); + } + return max_val; + } + + template + typename T getPeriodMax(const TraceType >& stat, size_t num_periods = U32_MAX) const + { + size_t total_periods = mRecordingPeriods.size(); + num_periods = llmin(num_periods, total_periods); + + typename T max_val = std::numeric_limits::min(); + for (S32 i = 1; i <= num_periods; i++) + { + S32 index = (mCurPeriod + total_periods - i) % total_periods; + max_val = llmax(max_val, mRecordingPeriods[index].getMax(stat)); + } + return max_val; + } + template F64 getPeriodMaxPerSec(const TraceType& stat, size_t num_periods = U32_MAX) const { size_t total_periods = mRecordingPeriods.size(); num_periods = llmin(num_periods, total_periods); - F64 max_val = (std::numeric_limits::min)(); + F64 max_val = std::numeric_limits::min(); for (S32 i = 1; i <= num_periods; i++) { S32 index = (mCurPeriod + total_periods - i) % total_periods; @@ -332,13 +441,14 @@ namespace LLTrace return max_val; } + // catch all for stats that have a defined sum template - typename T::mean_t getPeriodMean(const TraceType& stat, size_t num_periods = U32_MAX) const + typename T::mean_t getPeriodMean(const TraceType& stat, size_t num_periods = U32_MAX) const { size_t total_periods = mRecordingPeriods.size(); num_periods = llmin(num_periods, total_periods); - typename T::mean_t mean = typename T::mean_t(); + typename T::mean_t mean = 0; if (num_periods <= 0) { return mean; } for (S32 i = 1; i <= num_periods; i++) @@ -349,7 +459,65 @@ namespace LLTrace mean += mRecordingPeriods[index].getSum(stat); } } - mean /= num_periods; + mean = mean / num_periods; + return mean; + } + + template + typename SampleAccumulator::mean_t getPeriodMean(const TraceType >& stat, size_t num_periods = U32_MAX) const + { + size_t total_periods = mRecordingPeriods.size(); + num_periods = llmin(num_periods, total_periods); + + LLUnit total_duration = 0.f; + + typename SampleAccumulator::mean_t mean = 0; + if (num_periods <= 0) { return mean; } + + for (S32 i = 1; i <= num_periods; i++) + { + S32 index = (mCurPeriod + total_periods - i) % total_periods; + if (mRecordingPeriods[index].getDuration() > 0.f) + { + LLUnit recording_duration = mRecordingPeriods[index].getDuration(); + mean += mRecordingPeriods[index].getMean(stat) * recording_duration.value(); + total_duration += recording_duration; + } + } + + if (total_duration.value()) + { + mean = mean / total_duration; + } + return mean; + } + + template + typename EventAccumulator::mean_t getPeriodMean(const TraceType >& stat, size_t num_periods = U32_MAX) const + { + size_t total_periods = mRecordingPeriods.size(); + num_periods = llmin(num_periods, total_periods); + + typename EventAccumulator::mean_t mean = 0; + if (num_periods <= 0) { return mean; } + + S32 total_sample_count = 0; + + for (S32 i = 1; i <= num_periods; i++) + { + S32 index = (mCurPeriod + total_periods - i) % total_periods; + if (mRecordingPeriods[index].getDuration() > 0.f) + { + S32 period_sample_count = mRecordingPeriods[index].getSampleCount(stat); + mean += mRecordingPeriods[index].getMean(stat) * period_sample_count; + total_sample_count += period_sample_count; + } + } + + if (total_sample_count) + { + mean = mean / total_sample_count; + } return mean; } @@ -359,7 +527,7 @@ namespace LLTrace size_t total_periods = mRecordingPeriods.size(); num_periods = llmin(num_periods, total_periods); - typename T::mean_t mean = typename T::mean_t(); + typename T::mean_t mean = 0; if (num_periods <= 0) { return mean; } for (S32 i = 1; i <= num_periods; i++) @@ -370,7 +538,7 @@ namespace LLTrace mean += mRecordingPeriods[index].getPerSec(stat); } } - mean /= num_periods; + mean = mean / num_periods; return mean; } -- cgit v1.2.3