summaryrefslogtreecommitdiff
path: root/indra/llcommon
diff options
context:
space:
mode:
Diffstat (limited to 'indra/llcommon')
-rw-r--r--indra/llcommon/lltracerecording.cpp55
-rw-r--r--indra/llcommon/lltracerecording.h51
-rw-r--r--indra/llcommon/llunit.h8
3 files changed, 61 insertions, 53 deletions
diff --git a/indra/llcommon/lltracerecording.cpp b/indra/llcommon/lltracerecording.cpp
index 259f5a7a27..5d74ea32df 100644
--- a/indra/llcommon/lltracerecording.cpp
+++ b/indra/llcommon/lltracerecording.cpp
@@ -355,41 +355,30 @@ U32 Recording::getSampleCount( const TraceType<MeasurementAccumulator<S64> >& st
// PeriodicRecording
///////////////////////////////////////////////////////////////////////
-PeriodicRecording::PeriodicRecording( S32 num_periods, EPlayState state)
-: mNumPeriods(num_periods),
+PeriodicRecording::PeriodicRecording( U32 num_periods, EPlayState state)
+: mAutoResize(num_periods == 0),
mCurPeriod(0),
- mTotalValid(false),
- mRecordingPeriods( new Recording[num_periods])
+ mTotalValid(false)
{
- llassert(mNumPeriods > 0);
- setPlayState(state);
-}
-
-PeriodicRecording::PeriodicRecording(PeriodicRecording& other)
-: mNumPeriods(other.mNumPeriods),
- mCurPeriod(other.mCurPeriod),
- mTotalValid(other.mTotalValid),
- mTotalRecording(other.mTotalRecording)
-{
- mRecordingPeriods = new Recording[mNumPeriods];
- for (S32 i = 0; i < mNumPeriods; i++)
+ if (num_periods)
{
- mRecordingPeriods[i] = other.mRecordingPeriods[i];
+ mRecordingPeriods.resize(num_periods);
}
+ setPlayState(state);
}
-
-PeriodicRecording::~PeriodicRecording()
-{
- delete[] mRecordingPeriods;
-}
-
-
void PeriodicRecording::nextPeriod()
{
EPlayState play_state = getPlayState();
Recording& old_recording = getCurRecordingPeriod();
- mCurPeriod = (mCurPeriod + 1) % mNumPeriods;
+ if (mAutoResize)
+ {
+ mRecordingPeriods.push_back(Recording());
+ }
+ U32 num_periods = mRecordingPeriods.size();
+ mCurPeriod = (num_periods > 0)
+ ? (mCurPeriod + 1) % num_periods
+ : mCurPeriod + 1;
old_recording.splitTo(getCurRecordingPeriod());
switch(play_state)
@@ -412,9 +401,21 @@ Recording& PeriodicRecording::getTotalRecording()
if (!mTotalValid)
{
mTotalRecording.reset();
- for (S32 i = mCurPeriod + 1; i < mCurPeriod + mNumPeriods; i++)
+ U32 num_periods = mRecordingPeriods.size();
+
+ if (num_periods)
+ {
+ for (S32 i = mCurPeriod + 1; i < mCurPeriod + num_periods; i++)
+ {
+ mTotalRecording.appendRecording(mRecordingPeriods[i % num_periods]);
+ }
+ }
+ else
{
- mTotalRecording.appendRecording(mRecordingPeriods[i % mNumPeriods]);
+ for (S32 i = 0; i < mCurPeriod; i++)
+ {
+ mTotalRecording.appendRecording(mRecordingPeriods[i]);
+ }
}
}
mTotalValid = true;
diff --git a/indra/llcommon/lltracerecording.h b/indra/llcommon/lltracerecording.h
index 751ff298ce..3e7ed2b592 100644
--- a/indra/llcommon/lltracerecording.h
+++ b/indra/llcommon/lltracerecording.h
@@ -249,16 +249,15 @@ namespace LLTrace
: public LLStopWatchControlsMixin<PeriodicRecording>
{
public:
- PeriodicRecording(S32 num_periods, EPlayState state = STOPPED);
- PeriodicRecording(PeriodicRecording& recording);
- ~PeriodicRecording();
+ PeriodicRecording(U32 num_periods, EPlayState state = STOPPED);
void nextPeriod();
- S32 getNumPeriods() { return mNumPeriods; }
+ U32 getNumPeriods() { return mRecordingPeriods.size(); }
Recording& getLastRecordingPeriod()
{
- return mRecordingPeriods[(mCurPeriod + mNumPeriods - 1) % mNumPeriods];
+ U32 num_periods = mRecordingPeriods.size();
+ return mRecordingPeriods[(mCurPeriod + num_periods - 1) % num_periods];
}
const Recording& getLastRecordingPeriod() const
@@ -276,16 +275,18 @@ namespace LLTrace
return mRecordingPeriods[mCurPeriod];
}
- Recording& getPrevRecordingPeriod(S32 offset)
+ Recording& getPrevRecordingPeriod(U32 offset)
{
- offset = llclamp(offset, 0, mNumPeriods - 1);
- return mRecordingPeriods[(mCurPeriod + mNumPeriods - offset) % mNumPeriods];
+ U32 num_periods = mRecordingPeriods.size();
+ offset = llclamp(offset, 0u, num_periods - 1);
+ return mRecordingPeriods[(mCurPeriod + num_periods - offset) % num_periods];
}
- const Recording& getPrevRecordingPeriod(S32 offset) const
+ const Recording& getPrevRecordingPeriod(U32 offset) const
{
- offset = llclamp(offset, 0, mNumPeriods - 1);
- return mRecordingPeriods[(mCurPeriod + mNumPeriods - offset) % mNumPeriods];
+ U32 num_periods = mRecordingPeriods.size();
+ offset = llclamp(offset, 0u, num_periods - 1);
+ return mRecordingPeriods[(mCurPeriod + num_periods - offset) % num_periods];
}
Recording snapshotCurRecordingPeriod() const
@@ -301,7 +302,8 @@ namespace LLTrace
typename T::value_t getPeriodMin(const TraceType<T>& stat) const
{
typename T::value_t min_val = (std::numeric_limits<typename T::value_t>::max)();
- for (S32 i = 0; i < mNumPeriods; i++)
+ U32 num_periods = mRecordingPeriods.size();
+ for (S32 i = 0; i < num_periods; i++)
{
min_val = llmin(min_val, mRecordingPeriods[i].getSum(stat));
}
@@ -312,7 +314,8 @@ namespace LLTrace
F64 getPeriodMinPerSec(const TraceType<T>& stat) const
{
F64 min_val = (std::numeric_limits<F64>::max)();
- for (S32 i = 0; i < mNumPeriods; i++)
+ U32 num_periods = mRecordingPeriods.size();
+ for (S32 i = 0; i < num_periods; i++)
{
min_val = llmin(min_val, mRecordingPeriods[i].getPerSec(stat));
}
@@ -323,7 +326,8 @@ namespace LLTrace
typename T::value_t getPeriodMax(const TraceType<T>& stat) const
{
typename T::value_t max_val = (std::numeric_limits<typename T::value_t>::min)();
- for (S32 i = 0; i < mNumPeriods; i++)
+ U32 num_periods = mRecordingPeriods.size();
+ for (S32 i = 0; i < num_periods; i++)
{
max_val = llmax(max_val, mRecordingPeriods[i].getSum(stat));
}
@@ -334,7 +338,8 @@ namespace LLTrace
F64 getPeriodMaxPerSec(const TraceType<T>& stat) const
{
F64 max_val = (std::numeric_limits<F64>::min)();
- for (S32 i = 0; i < mNumPeriods; i++)
+ U32 num_periods = mRecordingPeriods.size();
+ for (S32 i = 0; i < num_periods; i++)
{
max_val = llmax(max_val, mRecordingPeriods[i].getPerSec(stat));
}
@@ -345,14 +350,15 @@ namespace LLTrace
typename MeanValueType<TraceType<T> >::type getPeriodMean(const TraceType<T>& stat) const
{
typename MeanValueType<TraceType<T> >::type mean = 0.0;
- for (S32 i = 0; i < mNumPeriods; i++)
+ U32 num_periods = mRecordingPeriods.size();
+ for (S32 i = 0; i < num_periods; i++)
{
if (mRecordingPeriods[i].getDuration() > 0.f)
{
mean += mRecordingPeriods[i].getSum(stat);
}
}
- mean /= mNumPeriods;
+ mean /= num_periods;
return mean;
}
@@ -360,14 +366,15 @@ namespace LLTrace
typename MeanValueType<TraceType<T> >::type getPeriodMeanPerSec(const TraceType<T>& stat) const
{
typename MeanValueType<TraceType<T> >::type mean = 0.0;
- for (S32 i = 0; i < mNumPeriods; i++)
+ U32 num_periods = mRecordingPeriods.size();
+ for (S32 i = 0; i < num_periods; i++)
{
if (mRecordingPeriods[i].getDuration() > 0.f)
{
mean += mRecordingPeriods[i].getPerSec(stat);
}
}
- mean /= mNumPeriods;
+ mean /= num_periods;
return mean;
}
@@ -382,11 +389,11 @@ namespace LLTrace
/*virtual*/ void splitFrom(PeriodicRecording& other);
private:
- Recording* mRecordingPeriods;
+ std::vector<Recording> mRecordingPeriods;
Recording mTotalRecording;
bool mTotalValid;
- S32 mNumPeriods,
- mCurPeriod;
+ const bool mAutoResize;
+ S32 mCurPeriod;
};
PeriodicRecording& get_frame_recording();
diff --git a/indra/llcommon/llunit.h b/indra/llcommon/llunit.h
index 823550db5d..f86f111b90 100644
--- a/indra/llcommon/llunit.h
+++ b/indra/llcommon/llunit.h
@@ -143,7 +143,7 @@ struct LLUnit
void operator *= (LLUnit<OTHER_UNIT, OTHER_STORAGE> multiplicand)
{
// spurious use of dependent type to stop gcc from triggering the static assertion before instantiating the template
- llstatic_assert_template(OTHER_UNIT, 0, "Multiplication of unit types not supported.");
+ llstatic_assert_template(OTHER_UNIT, false, "Multiplication of unit types not supported.");
}
void operator /= (storage_t divisor)
@@ -155,7 +155,7 @@ struct LLUnit
void operator /= (LLUnit<OTHER_UNIT, OTHER_STORAGE> divisor)
{
// spurious use of dependent type to stop gcc from triggering the static assertion before instantiating the template
- llstatic_assert_template(OTHER_UNIT, 0, "Illegal in-place division of unit types.");
+ llstatic_assert_template(OTHER_UNIT, false, "Illegal in-place division of unit types.");
}
template<typename SOURCE_UNITS, typename SOURCE_STORAGE>
@@ -315,7 +315,7 @@ template<typename UNIT_TYPE1, typename STORAGE_TYPE1, typename UNIT_TYPE2, typen
LLUnit<UNIT_TYPE1, STORAGE_TYPE1> operator * (LLUnit<UNIT_TYPE1, STORAGE_TYPE1>, LLUnit<UNIT_TYPE2, STORAGE_TYPE2>)
{
// spurious use of dependent type to stop gcc from triggering the static assertion before instantiating the template
- llstatic_assert_template(STORAGE_TYPE1, 0, "Multiplication of unit types results in new unit type - not supported.");
+ llstatic_assert_template(STORAGE_TYPE1, false, "Multiplication of unit types results in new unit type - not supported.");
return LLUnit<UNIT_TYPE1, STORAGE_TYPE1>();
}
@@ -335,7 +335,7 @@ template<typename UNIT_TYPE1, typename STORAGE_TYPE1, typename UNIT_TYPE2, typen
LLUnitImplicit<UNIT_TYPE1, STORAGE_TYPE1> operator * (LLUnitImplicit<UNIT_TYPE1, STORAGE_TYPE1>, LLUnitImplicit<UNIT_TYPE2, STORAGE_TYPE2>)
{
// spurious use of dependent type to stop gcc from triggering the static assertion before instantiating the template
- llstatic_assert_template(STORAGE_TYPE1, 0, "Multiplication of unit types results in new unit type - not supported.");
+ llstatic_assert_template(STORAGE_TYPE1, false, "Multiplication of unit types results in new unit type - not supported.");
return LLUnitImplicit<UNIT_TYPE1, STORAGE_TYPE1>();
}