summaryrefslogtreecommitdiff
path: root/indra/llcommon
diff options
context:
space:
mode:
Diffstat (limited to 'indra/llcommon')
-rw-r--r--indra/llcommon/lltrace.h96
-rw-r--r--indra/llcommon/lltracerecording.cpp268
-rw-r--r--indra/llcommon/lltracerecording.h209
-rw-r--r--indra/llcommon/lltracethreadrecorder.cpp7
4 files changed, 236 insertions, 344 deletions
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<typename T>
class EventAccumulator
{
public:
- typedef T value_t;
+ typedef F64 value_t;
typedef F64 mean_t;
- typedef EventAccumulator<T> self_t;
EventAccumulator()
: mSum(0),
- mMin((std::numeric_limits<T>::max)()),
- mMax((std::numeric_limits<T>::min)()),
+ mMin((std::numeric_limits<F64>::max)()),
+ mMax((std::numeric_limits<F64>::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<T>::max();
- mMax = std::numeric_limits<T>::min();
+ mMin = std::numeric_limits<F64>::max();
+ mMax = std::numeric_limits<F64>::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<typename T>
class SampleAccumulator
{
public:
- typedef T value_t;
+ typedef F64 value_t;
typedef F64 mean_t;
- typedef SampleAccumulator<T> self_t;
SampleAccumulator()
: mSum(0),
- mMin((std::numeric_limits<T>::max)()),
- mMax((std::numeric_limits<T>::min)()),
+ mMin((std::numeric_limits<F64>::max)()),
+ mMax((std::numeric_limits<F64>::min)()),
mMean(0),
mVarianceSum(0),
mLastSampleTimeStamp(LLTimer::getTotalSeconds()),
@@ -409,7 +405,7 @@ public:
mHasValue(false)
{}
- void sample(T value)
+ void sample(F64 value)
{
LLUnitImplicit<LLUnits::Seconds, F64> time_stamp = LLTimer::getTotalSeconds();
LLUnitImplicit<LLUnits::Seconds, F64> 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<T>::max();
- mMax = std::numeric_limits<T>::min();
+ mMin = std::numeric_limits<F64>::max();
+ mMax = std::numeric_limits<F64>::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<typename T>
class CountAccumulator
{
public:
- typedef CountAccumulator<T> 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<T>& 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 <typename T = F64>
class EventStatHandle
-: public TraceType<EventAccumulator<typename LLUnits::HighestPrecisionType<T>::type_t> >
+: public TraceType<EventAccumulator>
{
public:
typedef typename LLUnits::HighestPrecisionType<T>::type_t storage_t;
- typedef TraceType<EventAccumulator<typename LLUnits::HighestPrecisionType<T>::type_t> > trace_t;
+ typedef TraceType<EventAccumulator> trace_t;
EventStatHandle(const char* name, const char* description = NULL)
: trace_t(name, description)
@@ -679,11 +673,11 @@ void record(EventStatHandle<T>& measurement, VALUE_T value)
template <typename T = F64>
class SampleStatHandle
-: public TraceType<SampleAccumulator<typename LLUnits::HighestPrecisionType<T>::type_t> >
+: public TraceType<SampleAccumulator>
{
public:
- typedef typename LLUnits::HighestPrecisionType<T>::type_t storage_t;
- typedef TraceType<SampleAccumulator<typename LLUnits::HighestPrecisionType<T>::type_t> > trace_t;
+ typedef F64 storage_t;
+ typedef TraceType<SampleAccumulator> trace_t;
SampleStatHandle(const char* name, const char* description = NULL)
: trace_t(name, description)
@@ -699,11 +693,11 @@ void sample(SampleStatHandle<T>& measurement, VALUE_T value)
template <typename T = F64>
class CountStatHandle
-: public TraceType<CountAccumulator<typename LLUnits::HighestPrecisionType<T>::type_t> >
+: public TraceType<CountAccumulator>
{
public:
typedef typename LLUnits::HighestPrecisionType<T>::type_t storage_t;
- typedef TraceType<CountAccumulator<typename LLUnits::HighestPrecisionType<T>::type_t> > trace_t;
+ typedef TraceType<CountAccumulator> 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<LLUnits::Bytes, F32> Recording::getPerSec(const TraceType<MemStatAccumula
}
-F64 Recording::getSum( const TraceType<CountAccumulator<F64> >& stat )
-{
- update();
- return mBuffers->mCountsFloat[stat.getIndex()].getSum();
-}
-
-S64 Recording::getSum( const TraceType<CountAccumulator<S64> >& stat )
+F64 Recording::getSum( const TraceType<CountAccumulator>& stat )
{
update();
return mBuffers->mCounts[stat.getIndex()].getSum();
}
-F64 Recording::getSum( const TraceType<EventAccumulator<F64> >& stat )
+F64 Recording::getSum( const TraceType<EventAccumulator>& stat )
{
update();
- return (F64)mBuffers->mEventsFloat[stat.getIndex()].getSum();
+ return (F64)mBuffers->mEvents[stat.getIndex()].getSum();
}
-S64 Recording::getSum( const TraceType<EventAccumulator<S64> >& stat )
+F64 Recording::getPerSec( const TraceType<CountAccumulator>& stat )
{
update();
- return (S64)mBuffers->mEvents[stat.getIndex()].getSum();
-}
-
-
-
-F64 Recording::getPerSec( const TraceType<CountAccumulator<F64> >& 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<CountAccumulator<S64> >& stat )
-{
- S64 sum = mBuffers->mCounts[stat.getIndex()].getSum();
- return (sum != 0)
- ? ((F64)sum / mElapsedSeconds)
- : 0.0;
-}
-
-U32 Recording::getSampleCount( const TraceType<CountAccumulator<F64> >& stat )
-{
- update();
- return mBuffers->mCountsFloat[stat.getIndex()].getSampleCount();
-}
-
-U32 Recording::getSampleCount( const TraceType<CountAccumulator<S64> >& stat )
+U32 Recording::getSampleCount( const TraceType<CountAccumulator>& stat )
{
update();
return mBuffers->mCounts[stat.getIndex()].getSampleCount();
}
-F64 Recording::getMin( const TraceType<SampleAccumulator<F64> >& stat )
-{
- update();
- return mBuffers->mSamplesFloat[stat.getIndex()].getMin();
-}
-
-S64 Recording::getMin( const TraceType<SampleAccumulator<S64> >& stat )
+F64 Recording::getMin( const TraceType<SampleAccumulator>& stat )
{
update();
return mBuffers->mSamples[stat.getIndex()].getMin();
}
-F64 Recording::getMax( const TraceType<SampleAccumulator<F64> >& stat )
-{
- update();
- return mBuffers->mSamplesFloat[stat.getIndex()].getMax();
-}
-
-S64 Recording::getMax( const TraceType<SampleAccumulator<S64> >& stat )
+F64 Recording::getMax( const TraceType<SampleAccumulator>& stat )
{
update();
return mBuffers->mSamples[stat.getIndex()].getMax();
}
-F64 Recording::getMean( const TraceType<SampleAccumulator<F64> >& stat )
-{
- update();
- return mBuffers->mSamplesFloat[stat.getIndex()].getMean();
-}
-
-F64 Recording::getMean( const TraceType<SampleAccumulator<S64> >& stat )
+F64 Recording::getMean( const TraceType<SampleAccumulator>& stat )
{
update();
return mBuffers->mSamples[stat.getIndex()].getMean();
}
-F64 Recording::getStandardDeviation( const TraceType<SampleAccumulator<F64> >& stat )
-{
- update();
- return mBuffers->mSamplesFloat[stat.getIndex()].getStandardDeviation();
-}
-
-F64 Recording::getStandardDeviation( const TraceType<SampleAccumulator<S64> >& stat )
+F64 Recording::getStandardDeviation( const TraceType<SampleAccumulator>& stat )
{
update();
return mBuffers->mSamples[stat.getIndex()].getStandardDeviation();
}
-F64 Recording::getLastValue( const TraceType<SampleAccumulator<F64> >& stat )
-{
- update();
- return mBuffers->mSamplesFloat[stat.getIndex()].getLastValue();
-}
-
-S64 Recording::getLastValue( const TraceType<SampleAccumulator<S64> >& stat )
+F64 Recording::getLastValue( const TraceType<SampleAccumulator>& stat )
{
update();
return mBuffers->mSamples[stat.getIndex()].getLastValue();
}
-U32 Recording::getSampleCount( const TraceType<SampleAccumulator<F64> >& stat )
-{
- update();
- return mBuffers->mSamplesFloat[stat.getIndex()].getSampleCount();
-}
-
-U32 Recording::getSampleCount( const TraceType<SampleAccumulator<S64> >& stat )
+U32 Recording::getSampleCount( const TraceType<SampleAccumulator>& stat )
{
update();
return mBuffers->mSamples[stat.getIndex()].getSampleCount();
}
-F64 Recording::getMin( const TraceType<EventAccumulator<F64> >& stat )
-{
- update();
- return mBuffers->mEventsFloat[stat.getIndex()].getMin();
-}
-
-S64 Recording::getMin( const TraceType<EventAccumulator<S64> >& stat )
+F64 Recording::getMin( const TraceType<EventAccumulator>& stat )
{
update();
return mBuffers->mEvents[stat.getIndex()].getMin();
}
-F64 Recording::getMax( const TraceType<EventAccumulator<F64> >& stat )
-{
- update();
- return mBuffers->mEventsFloat[stat.getIndex()].getMax();
-}
-
-S64 Recording::getMax( const TraceType<EventAccumulator<S64> >& stat )
+F64 Recording::getMax( const TraceType<EventAccumulator>& stat )
{
update();
return mBuffers->mEvents[stat.getIndex()].getMax();
}
-F64 Recording::getMean( const TraceType<EventAccumulator<F64> >& stat )
-{
- update();
- return mBuffers->mEventsFloat[stat.getIndex()].getMean();
-}
-
-F64 Recording::getMean( const TraceType<EventAccumulator<S64> >& stat )
+F64 Recording::getMean( const TraceType<EventAccumulator>& stat )
{
update();
return mBuffers->mEvents[stat.getIndex()].getMean();
}
-F64 Recording::getStandardDeviation( const TraceType<EventAccumulator<F64> >& stat )
-{
- update();
- return mBuffers->mEventsFloat[stat.getIndex()].getStandardDeviation();
-}
-
-F64 Recording::getStandardDeviation( const TraceType<EventAccumulator<S64> >& stat )
+F64 Recording::getStandardDeviation( const TraceType<EventAccumulator>& stat )
{
update();
return mBuffers->mEvents[stat.getIndex()].getStandardDeviation();
}
-F64 Recording::getLastValue( const TraceType<EventAccumulator<F64> >& stat )
-{
- update();
- return mBuffers->mEventsFloat[stat.getIndex()].getLastValue();
-}
-
-S64 Recording::getLastValue( const TraceType<EventAccumulator<S64> >& stat )
+F64 Recording::getLastValue( const TraceType<EventAccumulator>& stat )
{
update();
return mBuffers->mEvents[stat.getIndex()].getLastValue();
}
-U32 Recording::getSampleCount( const TraceType<EventAccumulator<F64> >& stat )
-{
- update();
- return mBuffers->mEventsFloat[stat.getIndex()].getSampleCount();
-}
-
-U32 Recording::getSampleCount( const TraceType<EventAccumulator<S64> >& stat )
+U32 Recording::getSampleCount( const TraceType<EventAccumulator>& 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<EventAccumulator>& 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<EventAccumulator>& 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<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));
+ }
+ return min_val;
+}
+
+F64 PeriodicRecording::getPeriodMax( const TraceType<EventAccumulator>& 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<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));
+ }
+ return max_val;
+}
+
+F64 PeriodicRecording::getPeriodMin( const TraceType<SampleAccumulator>& 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<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));
+ }
+ return min_val;
+}
+
+F64 PeriodicRecording::getPeriodMax(const TraceType<SampleAccumulator>& 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<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));
+ }
+ return max_val;
+}
+
+
+F64 PeriodicRecording::getPeriodMean( const TraceType<SampleAccumulator>& stat, size_t num_periods /*= U32_MAX*/ )
+{
+ size_t total_periods = mRecordingPeriods.size();
+ num_periods = llmin(num_periods, total_periods);
+
+ LLUnit<LLUnits::Seconds, F64> 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<LLUnits::Seconds, F64> 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<CountAccumulator<F64> > mCountsFloat;
- AccumulatorBuffer<CountAccumulator<S64> > mCounts;
- AccumulatorBuffer<SampleAccumulator<F64> > mSamplesFloat;
- AccumulatorBuffer<SampleAccumulator<S64> > mSamples;
- AccumulatorBuffer<EventAccumulator<F64> > mEventsFloat;
- AccumulatorBuffer<EventAccumulator<S64> > mEvents;
+ AccumulatorBuffer<CountAccumulator> mCounts;
+ AccumulatorBuffer<SampleAccumulator> mSamples;
+ AccumulatorBuffer<EventAccumulator> mEvents;
AccumulatorBuffer<TimeBlockAccumulator> mStackTimers;
AccumulatorBuffer<MemStatAccumulator> mMemStats;
};
@@ -164,121 +161,105 @@ namespace LLTrace
LLUnit<LLUnits::Bytes, F32> getPerSec(const TraceType<MemStatAccumulator>& stat);
// CountStatHandle accessors
- F64 getSum(const TraceType<CountAccumulator<F64> >& stat);
- S64 getSum(const TraceType<CountAccumulator<S64> >& stat);
+ F64 getSum(const TraceType<CountAccumulator>& stat);
template <typename T>
T getSum(const CountStatHandle<T>& stat)
{
- return (T)getSum(static_cast<const TraceType<CountAccumulator<typename LLUnits::HighestPrecisionType<T>::type_t> >&> (stat));
+ return (T)getSum(static_cast<const TraceType<CountAccumulator>&> (stat));
}
- F64 getPerSec(const TraceType<CountAccumulator<F64> >& stat);
- F64 getPerSec(const TraceType<CountAccumulator<S64> >& stat);
+ F64 getPerSec(const TraceType<CountAccumulator>& stat);
template <typename T>
T getPerSec(const CountStatHandle<T>& stat)
{
- return (T)getPerSec(static_cast<const TraceType<CountAccumulator<typename LLUnits::HighestPrecisionType<T>::type_t> >&> (stat));
+ return (T)getPerSec(static_cast<const TraceType<CountAccumulator>&> (stat));
}
- U32 getSampleCount(const TraceType<CountAccumulator<F64> >& stat);
- U32 getSampleCount(const TraceType<CountAccumulator<S64> >& stat);
+ U32 getSampleCount(const TraceType<CountAccumulator>& stat);
// SampleStatHandle accessors
- F64 getMin(const TraceType<SampleAccumulator<F64> >& stat);
- S64 getMin(const TraceType<SampleAccumulator<S64> >& stat);
+ F64 getMin(const TraceType<SampleAccumulator>& stat);
template <typename T>
T getMin(const SampleStatHandle<T>& stat)
{
- return (T)getMin(static_cast<const TraceType<SampleAccumulator<typename LLUnits::HighestPrecisionType<T>::type_t> >&> (stat));
+ return (T)getMin(static_cast<const TraceType<SampleAccumulator>&> (stat));
}
- F64 getMax(const TraceType<SampleAccumulator<F64> >& stat);
- S64 getMax(const TraceType<SampleAccumulator<S64> >& stat);
+ F64 getMax(const TraceType<SampleAccumulator>& stat);
template <typename T>
T getMax(const SampleStatHandle<T>& stat)
{
- return (T)getMax(static_cast<const TraceType<SampleAccumulator<typename LLUnits::HighestPrecisionType<T>::type_t> >&> (stat));
+ return (T)getMax(static_cast<const TraceType<SampleAccumulator>&> (stat));
}
- F64 getMean(const TraceType<SampleAccumulator<F64> >& stat);
- F64 getMean(const TraceType<SampleAccumulator<S64> >& stat);
+ F64 getMean(const TraceType<SampleAccumulator>& stat);
template <typename T>
T getMean(SampleStatHandle<T>& stat)
{
- return (T)getMean(static_cast<const TraceType<SampleAccumulator<typename LLUnits::HighestPrecisionType<T>::type_t> >&> (stat));
+ return (T)getMean(static_cast<const TraceType<SampleAccumulator>&> (stat));
}
- F64 getStandardDeviation(const TraceType<SampleAccumulator<F64> >& stat);
- F64 getStandardDeviation(const TraceType<SampleAccumulator<S64> >& stat);
+ F64 getStandardDeviation(const TraceType<SampleAccumulator>& stat);
template <typename T>
T getStandardDeviation(const SampleStatHandle<T>& stat)
{
- return (T)getStandardDeviation(static_cast<const TraceType<SampleAccumulator<typename LLUnits::HighestPrecisionType<T>::type_t> >&> (stat));
+ return (T)getStandardDeviation(static_cast<const TraceType<SampleAccumulator>&> (stat));
}
- F64 getLastValue(const TraceType<SampleAccumulator<F64> >& stat);
- S64 getLastValue(const TraceType<SampleAccumulator<S64> >& stat);
+ F64 getLastValue(const TraceType<SampleAccumulator>& stat);
template <typename T>
T getLastValue(const SampleStatHandle<T>& stat)
{
- return (T)getLastValue(static_cast<const TraceType<SampleAccumulator<typename LLUnits::HighestPrecisionType<T>::type_t> >&> (stat));
+ return (T)getLastValue(static_cast<const TraceType<SampleAccumulator>&> (stat));
}
- U32 getSampleCount(const TraceType<SampleAccumulator<F64> >& stat);
- U32 getSampleCount(const TraceType<SampleAccumulator<S64> >& stat);
+ U32 getSampleCount(const TraceType<SampleAccumulator>& stat);
// EventStatHandle accessors
- F64 getSum(const TraceType<EventAccumulator<F64> >& stat);
- S64 getSum(const TraceType<EventAccumulator<S64> >& stat);
+ F64 getSum(const TraceType<EventAccumulator>& stat);
template <typename T>
T getSum(const EventStatHandle<T>& stat)
{
- return (T)getSum(static_cast<const TraceType<EventAccumulator<typename LLUnits::HighestPrecisionType<T>::type_t> >&> (stat));
+ return (T)getSum(static_cast<const TraceType<EventAccumulator>&> (stat));
}
- F64 getMin(const TraceType<EventAccumulator<F64> >& stat);
- S64 getMin(const TraceType<EventAccumulator<S64> >& stat);
+ F64 getMin(const TraceType<EventAccumulator>& stat);
template <typename T>
T getMin(const EventStatHandle<T>& stat)
{
- return (T)getMin(static_cast<const TraceType<EventAccumulator<typename LLUnits::HighestPrecisionType<T>::type_t> >&> (stat));
+ return (T)getMin(static_cast<const TraceType<EventAccumulator>&> (stat));
}
- F64 getMax(const TraceType<EventAccumulator<F64> >& stat);
- S64 getMax(const TraceType<EventAccumulator<S64> >& stat);
+ F64 getMax(const TraceType<EventAccumulator>& stat);
template <typename T>
T getMax(const EventStatHandle<T>& stat)
{
- return (T)getMax(static_cast<const TraceType<EventAccumulator<typename LLUnits::HighestPrecisionType<T>::type_t> >&> (stat));
+ return (T)getMax(static_cast<const TraceType<EventAccumulator>&> (stat));
}
- F64 getMean(const TraceType<EventAccumulator<F64> >& stat);
- F64 getMean(const TraceType<EventAccumulator<S64> >& stat);
+ F64 getMean(const TraceType<EventAccumulator>& stat);
template <typename T>
T getMean(EventStatHandle<T>& stat)
{
- return (T)getMean(static_cast<const TraceType<EventAccumulator<typename LLUnits::HighestPrecisionType<T>::type_t> >&> (stat));
+ return (T)getMean(static_cast<const TraceType<EventAccumulator>&> (stat));
}
- F64 getStandardDeviation(const TraceType<EventAccumulator<F64> >& stat);
- F64 getStandardDeviation(const TraceType<EventAccumulator<S64> >& stat);
+ F64 getStandardDeviation(const TraceType<EventAccumulator>& stat);
template <typename T>
T getStandardDeviation(const EventStatHandle<T>& stat)
{
- return (T)getStandardDeviation(static_cast<const TraceType<EventAccumulator<typename LLUnits::HighestPrecisionType<T>::type_t> >&> (stat));
+ return (T)getStandardDeviation(static_cast<const TraceType<EventAccumulator>&> (stat));
}
- F64 getLastValue(const TraceType<EventAccumulator<F64> >& stat);
- S64 getLastValue(const TraceType<EventAccumulator<S64> >& stat);
+ F64 getLastValue(const TraceType<EventAccumulator>& stat);
template <typename T>
T getLastValue(const EventStatHandle<T>& stat)
{
- return (T)getLastValue(static_cast<const TraceType<EventAccumulator<typename LLUnits::HighestPrecisionType<T>::type_t> >&> (stat));
+ return (T)getLastValue(static_cast<const TraceType<EventAccumulator>&> (stat));
}
- U32 getSampleCount(const TraceType<EventAccumulator<F64> >& stat);
- U32 getSampleCount(const TraceType<EventAccumulator<S64> >& stat);
+ U32 getSampleCount(const TraceType<EventAccumulator>& stat);
LLUnit<LLUnits::Seconds, F64> getDuration() const { return LLUnit<LLUnits::Seconds, F64>(mElapsedSeconds); }
@@ -335,34 +316,18 @@ namespace LLTrace
return min_val;
}
- template <typename T>
- T getPeriodMin(const TraceType<SampleAccumulator<T> >& stat, size_t num_periods = U32_MAX)
+ F64 getPeriodMin(const TraceType<SampleAccumulator>& stat, size_t num_periods = U32_MAX);
+ template<typename T>
+ T getPeriodMin(const SampleStatHandle<T>& 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<T>::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<const TraceType<SampleAccumulator>&>(stat), num_periods));
}
-
- template <typename T>
- T getPeriodMin(const TraceType<EventAccumulator<T> >& 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<T>::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<EventAccumulator>& stat, size_t num_periods = U32_MAX);
+ template<typename T>
+ T getPeriodMin(const EventStatHandle<T>& stat, size_t num_periods = U32_MAX)
+ {
+ return T(getPeriodMin(static_cast<const TraceType<EventAccumulator>&>(stat), num_periods));
}
template <typename T>
@@ -396,34 +361,18 @@ namespace LLTrace
return max_val;
}
- template <typename T>
- T getPeriodMax(const TraceType<SampleAccumulator<T> >& stat, size_t num_periods = U32_MAX)
+ F64 getPeriodMax(const TraceType<SampleAccumulator>& stat, size_t num_periods = U32_MAX);
+ template<typename T>
+ T getPeriodMax(const SampleStatHandle<T>& 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<T>::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<const TraceType<SampleAccumulator>&>(stat), num_periods));
}
- template <typename T>
- T getPeriodMax(const TraceType<EventAccumulator<T> >& stat, size_t num_periods = U32_MAX)
+ F64 getPeriodMax(const TraceType<EventAccumulator>& stat, size_t num_periods = U32_MAX);
+ template<typename T>
+ T getPeriodMax(const EventStatHandle<T>& 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<T>::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<const TraceType<EventAccumulator>&>(stat), num_periods));
}
template <typename T>
@@ -463,62 +412,18 @@ namespace LLTrace
return mean;
}
- template <typename T>
- typename SampleAccumulator<T>::mean_t getPeriodMean(const TraceType<SampleAccumulator<T> >& stat, size_t num_periods = U32_MAX)
+ F64 getPeriodMean(const TraceType<SampleAccumulator>& stat, size_t num_periods = U32_MAX);
+ template<typename T>
+ T getPeriodMean(const SampleStatHandle<T>& stat, size_t num_periods = U32_MAX)
{
- size_t total_periods = mRecordingPeriods.size();
- num_periods = llmin(num_periods, total_periods);
-
- LLUnit<LLUnits::Seconds, F64> total_duration = 0.f;
-
- typename SampleAccumulator<T>::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<LLUnits::Seconds, F64> 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<const TraceType<SampleAccumulator>&>(stat), num_periods));
}
- template <typename T>
- typename EventAccumulator<T>::mean_t getPeriodMean(const TraceType<EventAccumulator<T> >& stat, size_t num_periods = U32_MAX)
+ F64 getPeriodMean(const TraceType<EventAccumulator>& stat, size_t num_periods = U32_MAX);
+ template<typename T>
+ T getPeriodMean(const EventStatHandle<T>& stat, size_t num_periods = U32_MAX)
{
- size_t total_periods = mRecordingPeriods.size();
- num_periods = llmin(num_periods, total_periods);
-
- typename EventAccumulator<T>::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<const TraceType<EventAccumulator>&>(stat), num_periods));
}
template <typename T>
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<CountAccumulator<F64> > gCountsFloat;
-AccumulatorBuffer<EventAccumulator<F64> > gMeasurementsFloat;
-AccumulatorBuffer<CountAccumulator<S64> > gCounts;
-AccumulatorBuffer<EventAccumulator<S64> > gMeasurements;
-AccumulatorBuffer<TimeBlockAccumulator> gStackTimers;
-AccumulatorBuffer<MemStatAccumulator> gMemStats;
-
void ThreadRecorder::deactivate( Recording* recording )
{
active_recording_list_t::reverse_iterator it = bringUpToDate(recording);