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/llcommon/lltrace.h | 96 ++++++----- indra/llcommon/lltracerecording.cpp | 268 +++++++++++++++---------------- indra/llcommon/lltracerecording.h | 209 +++++++----------------- indra/llcommon/lltracethreadrecorder.cpp | 7 - 4 files changed, 236 insertions(+), 344 deletions(-) (limited to 'indra/llcommon') diff --git a/indra/llcommon/lltrace.h b/indra/llcommon/lltrace.h index 0daac95ea4..d6b51a63ee 100644 --- a/indra/llcommon/lltrace.h +++ b/indra/llcommon/lltrace.h @@ -273,25 +273,23 @@ protected: const size_t mAccumulatorIndex; }; -template class EventAccumulator { public: - typedef T value_t; + typedef F64 value_t; typedef F64 mean_t; - typedef EventAccumulator self_t; EventAccumulator() : mSum(0), - mMin((std::numeric_limits::max)()), - mMax((std::numeric_limits::min)()), + mMin((std::numeric_limits::max)()), + mMax((std::numeric_limits::min)()), mMean(0), mVarianceSum(0), mNumSamples(0), mLastValue(0) {} - void record(T value) + void record(F64 value) { mNumSamples++; mSum += value; @@ -305,12 +303,12 @@ public: mMax = value; } F64 old_mean = mMean; - mMean += ((F64)value - old_mean) / (F64)mNumSamples; - mVarianceSum += ((F64)value - old_mean) * ((F64)value - mMean); + mMean += (value - old_mean) / (F64)mNumSamples; + mVarianceSum += (value - old_mean) * (value - mMean); mLastValue = value; } - void addSamples(const self_t& other, bool append) + void addSamples(const EventAccumulator& other, bool append) { if (other.mNumSamples) { @@ -354,12 +352,12 @@ public: } } - void reset(const self_t* other) + void reset(const EventAccumulator* other) { mNumSamples = 0; mSum = 0; - mMin = std::numeric_limits::max(); - mMax = std::numeric_limits::min(); + mMin = std::numeric_limits::max(); + mMax = std::numeric_limits::min(); mMean = 0; mVarianceSum = 0; mLastValue = other ? other->mLastValue : 0; @@ -367,16 +365,16 @@ public: void flush() {} - T getSum() const { return (T)mSum; } - T getMin() const { return (T)mMin; } - T getMax() const { return (T)mMax; } - T getLastValue() const { return (T)mLastValue; } + F64 getSum() const { return mSum; } + F64 getMin() const { return mMin; } + F64 getMax() const { return mMax; } + F64 getLastValue() const { return mLastValue; } F64 getMean() const { return mMean; } F64 getStandardDeviation() const { return sqrtf(mVarianceSum / mNumSamples); } U32 getSampleCount() const { return mNumSamples; } private: - T mSum, + F64 mSum, mMin, mMax, mLastValue; @@ -388,18 +386,16 @@ private: }; -template class SampleAccumulator { public: - typedef T value_t; + typedef F64 value_t; typedef F64 mean_t; - typedef SampleAccumulator self_t; SampleAccumulator() : mSum(0), - mMin((std::numeric_limits::max)()), - mMax((std::numeric_limits::min)()), + mMin((std::numeric_limits::max)()), + mMax((std::numeric_limits::min)()), mMean(0), mVarianceSum(0), mLastSampleTimeStamp(LLTimer::getTotalSeconds()), @@ -409,7 +405,7 @@ public: mHasValue(false) {} - void sample(T value) + void sample(F64 value) { LLUnitImplicit time_stamp = LLTimer::getTotalSeconds(); LLUnitImplicit delta_time = time_stamp - mLastSampleTimeStamp; @@ -418,15 +414,15 @@ public: if (mHasValue) { mTotalSamplingTime += delta_time; - mSum += (F64)mLastValue * delta_time; + mSum += mLastValue * delta_time; // NOTE: both conditions will hold first time through if (value < mMin) { mMin = value; } if (value > mMax) { mMax = value; } F64 old_mean = mMean; - mMean += (delta_time / mTotalSamplingTime) * ((F64)mLastValue - old_mean); - mVarianceSum += delta_time * ((F64)mLastValue - old_mean) * ((F64)mLastValue - mMean); + mMean += (delta_time / mTotalSamplingTime) * (mLastValue - old_mean); + mVarianceSum += delta_time * (mLastValue - old_mean) * (mLastValue - mMean); } mLastValue = value; @@ -434,7 +430,7 @@ public: mHasValue = true; } - void addSamples(const self_t& other, bool append) + void addSamples(const SampleAccumulator& other, bool append) { if (other.mTotalSamplingTime) { @@ -485,12 +481,12 @@ public: } } - void reset(const self_t* other) + void reset(const SampleAccumulator* other) { mNumSamples = 0; mSum = 0; - mMin = std::numeric_limits::max(); - mMax = std::numeric_limits::min(); + mMin = std::numeric_limits::max(); + mMax = std::numeric_limits::min(); mMean = other ? other->mLastValue : 0; mVarianceSum = 0; mLastSampleTimeStamp = LLTimer::getTotalSeconds(); @@ -506,22 +502,22 @@ public: if (mHasValue) { - mSum += (F64)mLastValue * delta_time; + mSum += mLastValue * delta_time; mTotalSamplingTime += delta_time; } mLastSampleTimeStamp = time_stamp; } - T getSum() const { return (T)mSum; } - T getMin() const { return (T)mMin; } - T getMax() const { return (T)mMax; } - T getLastValue() const { return (T)mLastValue; } + F64 getSum() const { return mSum; } + F64 getMin() const { return mMin; } + F64 getMax() const { return mMax; } + F64 getLastValue() const { return mLastValue; } F64 getMean() const { return mMean; } F64 getStandardDeviation() const { return sqrtf(mVarianceSum / mTotalSamplingTime); } U32 getSampleCount() const { return mNumSamples; } private: - T mSum, + F64 mSum, mMin, mMax, mLastValue; @@ -537,12 +533,10 @@ private: U32 mNumSamples; }; -template class CountAccumulator { public: - typedef CountAccumulator self_t; - typedef T value_t; + typedef F64 value_t; typedef F64 mean_t; CountAccumulator() @@ -550,19 +544,19 @@ public: mNumSamples(0) {} - void add(T value) + void add(F64 value) { mNumSamples++; mSum += value; } - void addSamples(const CountAccumulator& other, bool /*append*/) + void addSamples(const CountAccumulator& other, bool /*append*/) { mSum += other.mSum; mNumSamples += other.mNumSamples; } - void reset(const self_t* other) + void reset(const CountAccumulator* other) { mNumSamples = 0; mSum = 0; @@ -570,12 +564,12 @@ public: void flush() {} - T getSum() const { return (T)mSum; } + F64 getSum() const { return mSum; } U32 getSampleCount() const { return mNumSamples; } private: - T mSum; + F64 mSum; U32 mNumSamples; }; @@ -659,11 +653,11 @@ public: template class EventStatHandle -: public TraceType::type_t> > +: public TraceType { public: typedef typename LLUnits::HighestPrecisionType::type_t storage_t; - typedef TraceType::type_t> > trace_t; + typedef TraceType trace_t; EventStatHandle(const char* name, const char* description = NULL) : trace_t(name, description) @@ -679,11 +673,11 @@ void record(EventStatHandle& measurement, VALUE_T value) template class SampleStatHandle -: public TraceType::type_t> > +: public TraceType { public: - typedef typename LLUnits::HighestPrecisionType::type_t storage_t; - typedef TraceType::type_t> > trace_t; + typedef F64 storage_t; + typedef TraceType trace_t; SampleStatHandle(const char* name, const char* description = NULL) : trace_t(name, description) @@ -699,11 +693,11 @@ void sample(SampleStatHandle& measurement, VALUE_T value) template class CountStatHandle -: public TraceType::type_t> > +: public TraceType { public: typedef typename LLUnits::HighestPrecisionType::type_t storage_t; - typedef TraceType::type_t> > trace_t; + typedef TraceType trace_t; CountStatHandle(const char* name, const char* description = NULL) : trace_t(name) diff --git a/indra/llcommon/lltracerecording.cpp b/indra/llcommon/lltracerecording.cpp index aedb9c7542..61ba21a365 100644 --- a/indra/llcommon/lltracerecording.cpp +++ b/indra/llcommon/lltracerecording.cpp @@ -44,11 +44,8 @@ RecordingBuffers::RecordingBuffers() void RecordingBuffers::handOffTo(RecordingBuffers& other) { - other.mCountsFloat.reset(&mCountsFloat); other.mCounts.reset(&mCounts); - other.mSamplesFloat.reset(&mSamplesFloat); other.mSamples.reset(&mSamples); - other.mEventsFloat.reset(&mEventsFloat); other.mEvents.reset(&mEvents); other.mStackTimers.reset(&mStackTimers); other.mMemStats.reset(&mMemStats); @@ -56,11 +53,8 @@ void RecordingBuffers::handOffTo(RecordingBuffers& other) void RecordingBuffers::makePrimary() { - mCountsFloat.makePrimary(); mCounts.makePrimary(); - mSamplesFloat.makePrimary(); mSamples.makePrimary(); - mEventsFloat.makePrimary(); mEvents.makePrimary(); mStackTimers.makePrimary(); mMemStats.makePrimary(); @@ -85,11 +79,8 @@ bool RecordingBuffers::isPrimary() const void RecordingBuffers::append( const RecordingBuffers& other ) { - mCountsFloat.addSamples(other.mCountsFloat); mCounts.addSamples(other.mCounts); - mSamplesFloat.addSamples(other.mSamplesFloat); mSamples.addSamples(other.mSamples); - mEventsFloat.addSamples(other.mEventsFloat); mEvents.addSamples(other.mEvents); mMemStats.addSamples(other.mMemStats); mStackTimers.addSamples(other.mStackTimers); @@ -97,11 +88,8 @@ void RecordingBuffers::append( const RecordingBuffers& other ) void RecordingBuffers::merge( const RecordingBuffers& other) { - mCountsFloat.addSamples(other.mCountsFloat, false); mCounts.addSamples(other.mCounts, false); - mSamplesFloat.addSamples(other.mSamplesFloat, false); mSamples.addSamples(other.mSamples, false); - mEventsFloat.addSamples(other.mEventsFloat, false); mEvents.addSamples(other.mEvents, false); mMemStats.addSamples(other.mMemStats, false); // for now, hold out timers from merge, need to be displayed per thread @@ -110,11 +98,8 @@ void RecordingBuffers::merge( const RecordingBuffers& other) void RecordingBuffers::reset(RecordingBuffers* other) { - mCountsFloat.reset(other ? &other->mCountsFloat : NULL); mCounts.reset(other ? &other->mCounts : NULL); - mSamplesFloat.reset(other ? &other->mSamplesFloat : NULL); mSamples.reset(other ? &other->mSamples : NULL); - mEventsFloat.reset(other ? &other->mEventsFloat : NULL); mEvents.reset(other ? &other->mEvents : NULL); mStackTimers.reset(other ? &other->mStackTimers : NULL); mMemStats.reset(other ? &other->mMemStats : NULL); @@ -122,7 +107,6 @@ void RecordingBuffers::reset(RecordingBuffers* other) void RecordingBuffers::flush() { - mSamplesFloat.flush(); mSamples.flush(); } @@ -280,200 +264,100 @@ LLUnit Recording::getPerSec(const TraceType >& stat ) -{ - update(); - return mBuffers->mCountsFloat[stat.getIndex()].getSum(); -} - -S64 Recording::getSum( const TraceType >& stat ) +F64 Recording::getSum( const TraceType& stat ) { update(); return mBuffers->mCounts[stat.getIndex()].getSum(); } -F64 Recording::getSum( const TraceType >& stat ) +F64 Recording::getSum( const TraceType& stat ) { update(); - return (F64)mBuffers->mEventsFloat[stat.getIndex()].getSum(); + return (F64)mBuffers->mEvents[stat.getIndex()].getSum(); } -S64 Recording::getSum( const TraceType >& stat ) +F64 Recording::getPerSec( const TraceType& stat ) { update(); - return (S64)mBuffers->mEvents[stat.getIndex()].getSum(); -} - - - -F64 Recording::getPerSec( const TraceType >& stat ) -{ - update(); - F64 sum = mBuffers->mCountsFloat[stat.getIndex()].getSum(); + F64 sum = mBuffers->mCounts[stat.getIndex()].getSum(); return (sum != 0.0) ? (sum / mElapsedSeconds) : 0.0; } -F64 Recording::getPerSec( const TraceType >& stat ) -{ - S64 sum = mBuffers->mCounts[stat.getIndex()].getSum(); - return (sum != 0) - ? ((F64)sum / mElapsedSeconds) - : 0.0; -} - -U32 Recording::getSampleCount( const TraceType >& stat ) -{ - update(); - return mBuffers->mCountsFloat[stat.getIndex()].getSampleCount(); -} - -U32 Recording::getSampleCount( const TraceType >& stat ) +U32 Recording::getSampleCount( const TraceType& stat ) { update(); return mBuffers->mCounts[stat.getIndex()].getSampleCount(); } -F64 Recording::getMin( const TraceType >& stat ) -{ - update(); - return mBuffers->mSamplesFloat[stat.getIndex()].getMin(); -} - -S64 Recording::getMin( const TraceType >& stat ) +F64 Recording::getMin( const TraceType& stat ) { update(); return mBuffers->mSamples[stat.getIndex()].getMin(); } -F64 Recording::getMax( const TraceType >& stat ) -{ - update(); - return mBuffers->mSamplesFloat[stat.getIndex()].getMax(); -} - -S64 Recording::getMax( const TraceType >& stat ) +F64 Recording::getMax( const TraceType& stat ) { update(); return mBuffers->mSamples[stat.getIndex()].getMax(); } -F64 Recording::getMean( const TraceType >& stat ) -{ - update(); - return mBuffers->mSamplesFloat[stat.getIndex()].getMean(); -} - -F64 Recording::getMean( const TraceType >& stat ) +F64 Recording::getMean( const TraceType& stat ) { update(); return mBuffers->mSamples[stat.getIndex()].getMean(); } -F64 Recording::getStandardDeviation( const TraceType >& stat ) -{ - update(); - return mBuffers->mSamplesFloat[stat.getIndex()].getStandardDeviation(); -} - -F64 Recording::getStandardDeviation( const TraceType >& stat ) +F64 Recording::getStandardDeviation( const TraceType& stat ) { update(); return mBuffers->mSamples[stat.getIndex()].getStandardDeviation(); } -F64 Recording::getLastValue( const TraceType >& stat ) -{ - update(); - return mBuffers->mSamplesFloat[stat.getIndex()].getLastValue(); -} - -S64 Recording::getLastValue( const TraceType >& stat ) +F64 Recording::getLastValue( const TraceType& stat ) { update(); return mBuffers->mSamples[stat.getIndex()].getLastValue(); } -U32 Recording::getSampleCount( const TraceType >& stat ) -{ - update(); - return mBuffers->mSamplesFloat[stat.getIndex()].getSampleCount(); -} - -U32 Recording::getSampleCount( const TraceType >& stat ) +U32 Recording::getSampleCount( const TraceType& stat ) { update(); return mBuffers->mSamples[stat.getIndex()].getSampleCount(); } -F64 Recording::getMin( const TraceType >& stat ) -{ - update(); - return mBuffers->mEventsFloat[stat.getIndex()].getMin(); -} - -S64 Recording::getMin( const TraceType >& stat ) +F64 Recording::getMin( const TraceType& stat ) { update(); return mBuffers->mEvents[stat.getIndex()].getMin(); } -F64 Recording::getMax( const TraceType >& stat ) -{ - update(); - return mBuffers->mEventsFloat[stat.getIndex()].getMax(); -} - -S64 Recording::getMax( const TraceType >& stat ) +F64 Recording::getMax( const TraceType& stat ) { update(); return mBuffers->mEvents[stat.getIndex()].getMax(); } -F64 Recording::getMean( const TraceType >& stat ) -{ - update(); - return mBuffers->mEventsFloat[stat.getIndex()].getMean(); -} - -F64 Recording::getMean( const TraceType >& stat ) +F64 Recording::getMean( const TraceType& stat ) { update(); return mBuffers->mEvents[stat.getIndex()].getMean(); } -F64 Recording::getStandardDeviation( const TraceType >& stat ) -{ - update(); - return mBuffers->mEventsFloat[stat.getIndex()].getStandardDeviation(); -} - -F64 Recording::getStandardDeviation( const TraceType >& stat ) +F64 Recording::getStandardDeviation( const TraceType& stat ) { update(); return mBuffers->mEvents[stat.getIndex()].getStandardDeviation(); } -F64 Recording::getLastValue( const TraceType >& stat ) -{ - update(); - return mBuffers->mEventsFloat[stat.getIndex()].getLastValue(); -} - -S64 Recording::getLastValue( const TraceType >& stat ) +F64 Recording::getLastValue( const TraceType& stat ) { update(); return mBuffers->mEvents[stat.getIndex()].getLastValue(); } -U32 Recording::getSampleCount( const TraceType >& stat ) -{ - update(); - return mBuffers->mEventsFloat[stat.getIndex()].getSampleCount(); -} - -U32 Recording::getSampleCount( const TraceType >& stat ) +U32 Recording::getSampleCount( const TraceType& stat ) { update(); return mBuffers->mEvents[stat.getIndex()].getSampleCount(); @@ -667,6 +551,122 @@ void PeriodicRecording::handleSplitTo(PeriodicRecording& other) getCurRecording().splitTo(other.getCurRecording()); } + +F64 PeriodicRecording::getPeriodMean( const TraceType& stat, size_t num_periods /*= U32_MAX*/ ) +{ + size_t total_periods = mRecordingPeriods.size(); + num_periods = llmin(num_periods, total_periods); + + F64 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; +} + +F64 PeriodicRecording::getPeriodMin( const TraceType& stat, size_t num_periods /*= U32_MAX*/ ) +{ + size_t total_periods = mRecordingPeriods.size(); + num_periods = llmin(num_periods, total_periods); + + F64 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; +} + +F64 PeriodicRecording::getPeriodMax( const TraceType& stat, size_t num_periods /*= U32_MAX*/ ) +{ + size_t total_periods = mRecordingPeriods.size(); + num_periods = llmin(num_periods, total_periods); + + F64 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; +} + +F64 PeriodicRecording::getPeriodMin( const TraceType& stat, size_t num_periods /*= U32_MAX*/ ) +{ + size_t total_periods = mRecordingPeriods.size(); + num_periods = llmin(num_periods, total_periods); + + F64 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; +} + +F64 PeriodicRecording::getPeriodMax(const TraceType& stat, size_t num_periods /*= U32_MAX*/) +{ + size_t total_periods = mRecordingPeriods.size(); + num_periods = llmin(num_periods, total_periods); + + F64 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; +} + + +F64 PeriodicRecording::getPeriodMean( const TraceType& stat, size_t num_periods /*= U32_MAX*/ ) +{ + size_t total_periods = mRecordingPeriods.size(); + num_periods = llmin(num_periods, total_periods); + + LLUnit total_duration = 0.f; + + F64 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; +} + + + /////////////////////////////////////////////////////////////////////// // ExtendableRecording /////////////////////////////////////////////////////////////////////// diff --git a/indra/llcommon/lltracerecording.h b/indra/llcommon/lltracerecording.h index 58b40fa378..b4452d67a0 100644 --- a/indra/llcommon/lltracerecording.h +++ b/indra/llcommon/lltracerecording.h @@ -119,12 +119,9 @@ namespace LLTrace void reset(RecordingBuffers* other = NULL); void flush(); - AccumulatorBuffer > mCountsFloat; - AccumulatorBuffer > mCounts; - AccumulatorBuffer > mSamplesFloat; - AccumulatorBuffer > mSamples; - AccumulatorBuffer > mEventsFloat; - AccumulatorBuffer > mEvents; + AccumulatorBuffer mCounts; + AccumulatorBuffer mSamples; + AccumulatorBuffer mEvents; AccumulatorBuffer mStackTimers; AccumulatorBuffer mMemStats; }; @@ -164,121 +161,105 @@ namespace LLTrace LLUnit getPerSec(const TraceType& stat); // CountStatHandle accessors - F64 getSum(const TraceType >& stat); - S64 getSum(const TraceType >& stat); + F64 getSum(const TraceType& stat); template T getSum(const CountStatHandle& stat) { - return (T)getSum(static_cast::type_t> >&> (stat)); + return (T)getSum(static_cast&> (stat)); } - F64 getPerSec(const TraceType >& stat); - F64 getPerSec(const TraceType >& stat); + F64 getPerSec(const TraceType& stat); template T getPerSec(const CountStatHandle& stat) { - return (T)getPerSec(static_cast::type_t> >&> (stat)); + return (T)getPerSec(static_cast&> (stat)); } - U32 getSampleCount(const TraceType >& stat); - U32 getSampleCount(const TraceType >& stat); + U32 getSampleCount(const TraceType& stat); // SampleStatHandle accessors - F64 getMin(const TraceType >& stat); - S64 getMin(const TraceType >& stat); + F64 getMin(const TraceType& stat); template T getMin(const SampleStatHandle& stat) { - return (T)getMin(static_cast::type_t> >&> (stat)); + return (T)getMin(static_cast&> (stat)); } - F64 getMax(const TraceType >& stat); - S64 getMax(const TraceType >& stat); + F64 getMax(const TraceType& stat); template T getMax(const SampleStatHandle& stat) { - return (T)getMax(static_cast::type_t> >&> (stat)); + return (T)getMax(static_cast&> (stat)); } - F64 getMean(const TraceType >& stat); - F64 getMean(const TraceType >& stat); + F64 getMean(const TraceType& stat); template T getMean(SampleStatHandle& stat) { - return (T)getMean(static_cast::type_t> >&> (stat)); + return (T)getMean(static_cast&> (stat)); } - F64 getStandardDeviation(const TraceType >& stat); - F64 getStandardDeviation(const TraceType >& stat); + F64 getStandardDeviation(const TraceType& stat); template T getStandardDeviation(const SampleStatHandle& stat) { - return (T)getStandardDeviation(static_cast::type_t> >&> (stat)); + return (T)getStandardDeviation(static_cast&> (stat)); } - F64 getLastValue(const TraceType >& stat); - S64 getLastValue(const TraceType >& stat); + F64 getLastValue(const TraceType& stat); template T getLastValue(const SampleStatHandle& stat) { - return (T)getLastValue(static_cast::type_t> >&> (stat)); + return (T)getLastValue(static_cast&> (stat)); } - U32 getSampleCount(const TraceType >& stat); - U32 getSampleCount(const TraceType >& stat); + U32 getSampleCount(const TraceType& stat); // EventStatHandle accessors - F64 getSum(const TraceType >& stat); - S64 getSum(const TraceType >& stat); + F64 getSum(const TraceType& stat); template T getSum(const EventStatHandle& stat) { - return (T)getSum(static_cast::type_t> >&> (stat)); + return (T)getSum(static_cast&> (stat)); } - F64 getMin(const TraceType >& stat); - S64 getMin(const TraceType >& stat); + F64 getMin(const TraceType& stat); template T getMin(const EventStatHandle& stat) { - return (T)getMin(static_cast::type_t> >&> (stat)); + return (T)getMin(static_cast&> (stat)); } - F64 getMax(const TraceType >& stat); - S64 getMax(const TraceType >& stat); + F64 getMax(const TraceType& stat); template T getMax(const EventStatHandle& stat) { - return (T)getMax(static_cast::type_t> >&> (stat)); + return (T)getMax(static_cast&> (stat)); } - F64 getMean(const TraceType >& stat); - F64 getMean(const TraceType >& stat); + F64 getMean(const TraceType& stat); template T getMean(EventStatHandle& stat) { - return (T)getMean(static_cast::type_t> >&> (stat)); + return (T)getMean(static_cast&> (stat)); } - F64 getStandardDeviation(const TraceType >& stat); - F64 getStandardDeviation(const TraceType >& stat); + F64 getStandardDeviation(const TraceType& stat); template T getStandardDeviation(const EventStatHandle& stat) { - return (T)getStandardDeviation(static_cast::type_t> >&> (stat)); + return (T)getStandardDeviation(static_cast&> (stat)); } - F64 getLastValue(const TraceType >& stat); - S64 getLastValue(const TraceType >& stat); + F64 getLastValue(const TraceType& stat); template T getLastValue(const EventStatHandle& stat) { - return (T)getLastValue(static_cast::type_t> >&> (stat)); + return (T)getLastValue(static_cast&> (stat)); } - U32 getSampleCount(const TraceType >& stat); - U32 getSampleCount(const TraceType >& stat); + U32 getSampleCount(const TraceType& stat); LLUnit getDuration() const { return LLUnit(mElapsedSeconds); } @@ -335,34 +316,18 @@ namespace LLTrace return min_val; } - template - T getPeriodMin(const TraceType >& stat, size_t num_periods = U32_MAX) + F64 getPeriodMin(const TraceType& stat, size_t num_periods = U32_MAX); + template + T getPeriodMin(const SampleStatHandle& stat, size_t num_periods = U32_MAX) { - size_t total_periods = mRecordingPeriods.size(); - num_periods = llmin(num_periods, total_periods); - - 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; + return T(getPeriodMin(static_cast&>(stat), num_periods)); } - - template - T getPeriodMin(const TraceType >& stat, size_t num_periods = U32_MAX) - { - size_t total_periods = mRecordingPeriods.size(); - num_periods = llmin(num_periods, total_periods); - 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; + F64 getPeriodMin(const TraceType& stat, size_t num_periods = U32_MAX); + template + T getPeriodMin(const EventStatHandle& stat, size_t num_periods = U32_MAX) + { + return T(getPeriodMin(static_cast&>(stat), num_periods)); } template @@ -396,34 +361,18 @@ namespace LLTrace return max_val; } - template - T getPeriodMax(const TraceType >& stat, size_t num_periods = U32_MAX) + F64 getPeriodMax(const TraceType& stat, size_t num_periods = U32_MAX); + template + T getPeriodMax(const SampleStatHandle& stat, size_t num_periods = U32_MAX) { - 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; + return T(getPeriodMax(static_cast&>(stat), num_periods)); } - template - T getPeriodMax(const TraceType >& stat, size_t num_periods = U32_MAX) + F64 getPeriodMax(const TraceType& stat, size_t num_periods = U32_MAX); + template + T getPeriodMax(const EventStatHandle& stat, size_t num_periods = U32_MAX) { - 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; + return T(getPeriodMax(static_cast&>(stat), num_periods)); } template @@ -463,62 +412,18 @@ namespace LLTrace return mean; } - template - typename SampleAccumulator::mean_t getPeriodMean(const TraceType >& stat, size_t num_periods = U32_MAX) + F64 getPeriodMean(const TraceType& stat, size_t num_periods = U32_MAX); + template + T getPeriodMean(const SampleStatHandle& stat, size_t num_periods = U32_MAX) { - 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; + return T(getPeriodMean(static_cast&>(stat), num_periods)); } - template - typename EventAccumulator::mean_t getPeriodMean(const TraceType >& stat, size_t num_periods = U32_MAX) + F64 getPeriodMean(const TraceType& stat, size_t num_periods = U32_MAX); + template + T getPeriodMean(const EventStatHandle& stat, size_t num_periods = U32_MAX) { - 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; + return T(getPeriodMean(static_cast&>(stat), num_periods)); } template diff --git a/indra/llcommon/lltracethreadrecorder.cpp b/indra/llcommon/lltracethreadrecorder.cpp index c281b768ce..c1a0700eff 100644 --- a/indra/llcommon/lltracethreadrecorder.cpp +++ b/indra/llcommon/lltracethreadrecorder.cpp @@ -147,13 +147,6 @@ ThreadRecorder::active_recording_list_t::reverse_iterator ThreadRecorder::bringU return it; } -AccumulatorBuffer > gCountsFloat; -AccumulatorBuffer > gMeasurementsFloat; -AccumulatorBuffer > gCounts; -AccumulatorBuffer > gMeasurements; -AccumulatorBuffer gStackTimers; -AccumulatorBuffer gMemStats; - void ThreadRecorder::deactivate( Recording* recording ) { active_recording_list_t::reverse_iterator it = bringUpToDate(recording); -- cgit v1.2.3