diff options
author | Richard Linden <none@none> | 2013-08-12 20:07:41 -0700 |
---|---|---|
committer | Richard Linden <none@none> | 2013-08-12 20:07:41 -0700 |
commit | b8d49dab9afddf196618d66b1a409cdf7d2d53ba (patch) | |
tree | 535eb32ba4f17c87c0853cda9223c37a4940fea1 /indra/llcommon/lltracerecording.cpp | |
parent | c2601ec9c574ac3bd7a7f4001bc08572483028a6 (diff) | |
parent | 1a093beb7f69e6911f34cb12d71502aa7a05982e (diff) |
merge
Diffstat (limited to 'indra/llcommon/lltracerecording.cpp')
-rw-r--r-- | indra/llcommon/lltracerecording.cpp | 173 |
1 files changed, 126 insertions, 47 deletions
diff --git a/indra/llcommon/lltracerecording.cpp b/indra/llcommon/lltracerecording.cpp index 2150a44f12..42d97ce314 100644 --- a/indra/llcommon/lltracerecording.cpp +++ b/indra/llcommon/lltracerecording.cpp @@ -242,9 +242,7 @@ F64 Recording::getSum( const TraceType<EventAccumulator>& stat ) F64 Recording::getPerSec( const TraceType<CountAccumulator>& stat ) { F64 sum = mBuffers->mCounts[stat.getIndex()].getSum(); - return (sum != 0.0) - ? (sum / mElapsedSeconds.value()) - : 0.0; + return sum / mElapsedSeconds.value(); } U32 Recording::getSampleCount( const TraceType<CountAccumulator>& stat ) @@ -252,6 +250,11 @@ U32 Recording::getSampleCount( const TraceType<CountAccumulator>& stat ) return mBuffers->mCounts[stat.getIndex()].getSampleCount(); } +bool Recording::hasValue(const TraceType<SampleAccumulator>& stat) +{ + return mBuffers->mSamples[stat.getIndex()].hasValue(); +} + F64 Recording::getMin( const TraceType<SampleAccumulator>& stat ) { return mBuffers->mSamples[stat.getIndex()].getMin(); @@ -282,6 +285,11 @@ U32 Recording::getSampleCount( const TraceType<SampleAccumulator>& stat ) return mBuffers->mSamples[stat.getIndex()].getSampleCount(); } +bool Recording::hasValue(const TraceType<EventAccumulator>& stat) +{ + return mBuffers->mEvents[stat.getIndex()].hasValue(); +} + F64 Recording::getMin( const TraceType<EventAccumulator>& stat ) { return mBuffers->mEvents[stat.getIndex()].getMin(); @@ -512,61 +520,98 @@ void PeriodicRecording::handleSplitTo(PeriodicRecording& other) getCurRecording().splitTo(other.getCurRecording()); } - -F64 PeriodicRecording::getPeriodMean( const TraceType<EventAccumulator>& stat, size_t num_periods /*= U32_MAX*/ ) +F64 PeriodicRecording::getPeriodMin( const TraceType<EventAccumulator>& stat, size_t num_periods /*= U32_MAX*/ ) { size_t total_periods = mRecordingPeriods.size(); num_periods = llmin(num_periods, isStarted() ? total_periods - 1 : total_periods); - F64 mean = 0; - if (num_periods <= 0) { return mean; } - - S32 total_sample_count = 0; - + bool has_value = false; + F64 min_val = std::numeric_limits<F64>::max(); for (S32 i = 1; i <= num_periods; i++) { - S32 index = (mCurPeriod + total_periods - i) % total_periods; - if (mRecordingPeriods[index].getDuration() > 0.f) + Recording& recording = getPrevRecording(i); + if (recording.hasValue(stat)) { - S32 period_sample_count = mRecordingPeriods[index].getSampleCount(stat); - mean += mRecordingPeriods[index].getMean(stat) * period_sample_count; - total_sample_count += period_sample_count; + min_val = llmin(min_val, recording.getMin(stat)); + has_value = true; } } - if (total_sample_count) + return has_value + ? min_val + : NaN; +} + +F64 PeriodicRecording::getPeriodMax( const TraceType<EventAccumulator>& stat, size_t num_periods /*= U32_MAX*/ ) +{ + size_t total_periods = mRecordingPeriods.size(); + num_periods = llmin(num_periods, isStarted() ? total_periods - 1 : total_periods); + + bool has_value = false; + F64 max_val = std::numeric_limits<F64>::min(); + for (S32 i = 1; i <= num_periods; i++) { - mean = mean / total_sample_count; + Recording& recording = getPrevRecording(i); + if (recording.hasValue(stat)) + { + max_val = llmax(max_val, recording.getMax(stat)); + has_value = true; + } } - return mean; + + return has_value + ? max_val + : NaN; } -F64 PeriodicRecording::getPeriodMin( const TraceType<EventAccumulator>& stat, size_t num_periods /*= U32_MAX*/ ) +// calculates means using aggregates per period +F64 PeriodicRecording::getPeriodMean( const TraceType<EventAccumulator>& stat, size_t num_periods /*= U32_MAX*/ ) { size_t total_periods = mRecordingPeriods.size(); num_periods = llmin(num_periods, isStarted() ? total_periods - 1 : total_periods); - F64 min_val = std::numeric_limits<F64>::max(); + F64 mean = 0; + S32 valid_period_count = 0; + 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)); + Recording& recording = getPrevRecording(i); + if (recording.hasValue(stat)) + { + mean += recording.getMean(stat); + valid_period_count++; + } } - return min_val; + + return valid_period_count + ? mean / (F64)valid_period_count + : NaN; } -F64 PeriodicRecording::getPeriodMax( const TraceType<EventAccumulator>& stat, size_t num_periods /*= U32_MAX*/ ) + +F64 PeriodicRecording::getPeriodStandardDeviation( const TraceType<EventAccumulator>& stat, size_t num_periods /*= U32_MAX*/ ) { size_t total_periods = mRecordingPeriods.size(); num_periods = llmin(num_periods, isStarted() ? total_periods - 1 : total_periods); - F64 max_val = std::numeric_limits<F64>::min(); + F64 period_mean = getPeriodMean(stat, num_periods); + F64 sum_of_squares = 0; + S32 valid_period_count = 0; + 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)); + Recording& recording = getPrevRecording(i); + if (recording.hasValue(stat)) + { + F64 delta = recording.getMean(stat) - period_mean; + sum_of_squares += delta * delta; + valid_period_count++; + } } - return max_val; + + return valid_period_count + ? sqrt((F64)sum_of_squares / (F64)valid_period_count) + : NaN; } F64 PeriodicRecording::getPeriodMin( const TraceType<SampleAccumulator>& stat, size_t num_periods /*= U32_MAX*/ ) @@ -574,13 +619,21 @@ F64 PeriodicRecording::getPeriodMin( const TraceType<SampleAccumulator>& stat, s size_t total_periods = mRecordingPeriods.size(); num_periods = llmin(num_periods, isStarted() ? total_periods - 1 : total_periods); + bool has_value = false; F64 min_val = std::numeric_limits<F64>::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)); + Recording& recording = getPrevRecording(i); + if (recording.hasValue(stat)) + { + min_val = llmin(min_val, recording.getMin(stat)); + has_value = true; + } } - return min_val; + + return has_value + ? min_val + : NaN; } F64 PeriodicRecording::getPeriodMax(const TraceType<SampleAccumulator>& stat, size_t num_periods /*= U32_MAX*/) @@ -588,13 +641,21 @@ F64 PeriodicRecording::getPeriodMax(const TraceType<SampleAccumulator>& stat, si size_t total_periods = mRecordingPeriods.size(); num_periods = llmin(num_periods, isStarted() ? total_periods - 1 : total_periods); + bool has_value = false; F64 max_val = std::numeric_limits<F64>::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)); + Recording& recording = getPrevRecording(i); + if (recording.hasValue(stat)) + { + max_val = llmax(max_val, recording.getMax(stat)); + has_value = true; + } } - return max_val; + + return has_value + ? max_val + : NaN; } @@ -603,30 +664,48 @@ F64 PeriodicRecording::getPeriodMean( const TraceType<SampleAccumulator>& stat, size_t total_periods = mRecordingPeriods.size(); num_periods = llmin(num_periods, isStarted() ? total_periods - 1 : total_periods); - LLUnit<F64, LLUnits::Seconds> total_duration(0.f); - + S32 valid_period_count = 0; 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) + Recording& recording = getPrevRecording(i); + if (recording.hasValue(stat)) { - LLUnit<F64, LLUnits::Seconds> recording_duration = mRecordingPeriods[index].getDuration(); - mean += mRecordingPeriods[index].getMean(stat) * recording_duration.value(); - total_duration += recording_duration; + mean += recording.getMean(stat); + valid_period_count++; } } - if (total_duration.value()) - { - mean = mean / total_duration; - } - return mean; + return valid_period_count + ? mean / F64(valid_period_count) + : NaN; } +F64 PeriodicRecording::getPeriodStandardDeviation( const TraceType<SampleAccumulator>& stat, size_t num_periods /*= U32_MAX*/ ) +{ + size_t total_periods = mRecordingPeriods.size(); + num_periods = llmin(num_periods, isStarted() ? total_periods - 1 : total_periods); + + F64 period_mean = getPeriodMean(stat, num_periods); + S32 valid_period_count = 0; + F64 sum_of_squares = 0; + for (S32 i = 1; i <= num_periods; i++) + { + Recording& recording = getPrevRecording(i); + if (recording.hasValue(stat)) + { + F64 delta = recording.getMean(stat) - period_mean; + sum_of_squares += delta * delta; + valid_period_count++; + } + } + + return valid_period_count + ? sqrt(sum_of_squares / (F64)valid_period_count) + : NaN; +} /////////////////////////////////////////////////////////////////////// // ExtendableRecording |