summaryrefslogtreecommitdiff
path: root/indra/llcommon
diff options
context:
space:
mode:
Diffstat (limited to 'indra/llcommon')
-rw-r--r--indra/llcommon/lltrace.h36
-rw-r--r--indra/llcommon/lltracerecording.h16
2 files changed, 27 insertions, 25 deletions
diff --git a/indra/llcommon/lltrace.h b/indra/llcommon/lltrace.h
index 71bf1e53e4..a574be02da 100644
--- a/indra/llcommon/lltrace.h
+++ b/indra/llcommon/lltrace.h
@@ -86,20 +86,17 @@ private:
AccumulatorBuffer(StaticAllocationMarker m)
: mStorageSize(0),
- mStorage(NULL),
- mNextStorageSlot(0)
- {
- }
+ mStorage(NULL)
+ {}
public:
AccumulatorBuffer(const AccumulatorBuffer& other = *getDefaultBuffer())
: mStorageSize(0),
- mStorage(NULL),
- mNextStorageSlot(other.mNextStorageSlot)
+ mStorage(NULL)
{
resize(other.mStorageSize);
- for (S32 i = 0; i < mNextStorageSlot; i++)
+ for (S32 i = 0; i < sNextStorageSlot; i++)
{
mStorage[i] = other.mStorage[i];
}
@@ -126,9 +123,8 @@ public:
void addSamples(const AccumulatorBuffer<ACCUMULATOR>& other)
{
- llassert(mNextStorageSlot == other.mNextStorageSlot);
-
- for (size_t i = 0; i < mNextStorageSlot; i++)
+ llassert(mStorageSize >= sNextStorageSlot && other.mStorageSize > sNextStorageSlot);
+ for (size_t i = 0; i < sNextStorageSlot; i++)
{
mStorage[i].addSamples(other.mStorage[i]);
}
@@ -136,7 +132,8 @@ public:
void copyFrom(const AccumulatorBuffer<ACCUMULATOR>& other)
{
- for (size_t i = 0; i < mNextStorageSlot; i++)
+ llassert(mStorageSize >= sNextStorageSlot && other.mStorageSize > sNextStorageSlot);
+ for (size_t i = 0; i < sNextStorageSlot; i++)
{
mStorage[i] = other.mStorage[i];
}
@@ -144,7 +141,8 @@ public:
void reset(const AccumulatorBuffer<ACCUMULATOR>* other = NULL)
{
- for (size_t i = 0; i < mNextStorageSlot; i++)
+ llassert(mStorageSize >= sNextStorageSlot);
+ for (size_t i = 0; i < sNextStorageSlot; i++)
{
mStorage[i].reset(other ? &other->mStorage[i] : NULL);
}
@@ -172,7 +170,7 @@ public:
{
llerrs << "Attempting to declare trace object after program initialization. Trace objects should be statically initialized." << llendl;
}
- size_t next_slot = mNextStorageSlot++;
+ size_t next_slot = sNextStorageSlot++;
if (next_slot >= mStorageSize)
{
resize(mStorageSize + (mStorageSize >> 2));
@@ -208,7 +206,7 @@ public:
size_t size() const
{
- return mNextStorageSlot;
+ return sNextStorageSlot;
}
static self_t* getDefaultBuffer()
@@ -226,11 +224,15 @@ public:
}
private:
- ACCUMULATOR* mStorage;
- size_t mStorageSize;
- size_t mNextStorageSlot;
+ ACCUMULATOR* mStorage;
+ size_t mStorageSize;
+ static size_t sNextStorageSlot;
};
+template<typename ACCUMULATOR> size_t AccumulatorBuffer<ACCUMULATOR>::sNextStorageSlot = 0;
+
+
+
//TODO: replace with decltype when C++11 is enabled
template<typename T>
struct MeanValueType
diff --git a/indra/llcommon/lltracerecording.h b/indra/llcommon/lltracerecording.h
index a6fb07ac15..68f437a231 100644
--- a/indra/llcommon/lltracerecording.h
+++ b/indra/llcommon/lltracerecording.h
@@ -305,7 +305,7 @@ namespace LLTrace
U32 num_periods = mRecordingPeriods.size();
for (S32 i = 0; i < num_periods; i++)
{
- min_val = llmin(min_val, mRecordingPeriods[i].getSum(stat));
+ min_val = llmin(min_val, mRecordingPeriods[(mCurPeriod + i) % num_periods].getSum(stat));
}
return min_val;
}
@@ -317,7 +317,7 @@ namespace LLTrace
U32 num_periods = mRecordingPeriods.size();
for (S32 i = 0; i < num_periods; i++)
{
- min_val = llmin(min_val, mRecordingPeriods[i].getPerSec(stat));
+ min_val = llmin(min_val, mRecordingPeriods[(mCurPeriod + i) % num_periods].getPerSec(stat));
}
return min_val;
}
@@ -329,7 +329,7 @@ namespace LLTrace
U32 num_periods = mRecordingPeriods.size();
for (S32 i = 0; i < num_periods; i++)
{
- max_val = llmax(max_val, mRecordingPeriods[i].getSum(stat));
+ max_val = llmax(max_val, mRecordingPeriods[(mCurPeriod + i) % num_periods].getSum(stat));
}
return max_val;
}
@@ -339,9 +339,9 @@ namespace LLTrace
{
F64 max_val = (std::numeric_limits<F64>::min)();
U32 num_periods = mRecordingPeriods.size();
- for (S32 i = 0; i < num_periods; i++)
+ for (S32 i = 1; i < num_periods; i++)
{
- max_val = llmax(max_val, mRecordingPeriods[i].getPerSec(stat));
+ max_val = llmax(max_val, mRecordingPeriods[(mCurPeriod + i) % num_periods].getPerSec(stat));
}
return max_val;
}
@@ -353,9 +353,9 @@ namespace LLTrace
U32 num_periods = mRecordingPeriods.size();
for (S32 i = 0; i < num_periods; i++)
{
- if (mRecordingPeriods[i].getDuration() > 0.f)
+ if (mRecordingPeriods[(mCurPeriod + i) % num_periods].getDuration() > 0.f)
{
- mean += mRecordingPeriods[i].getSum(stat);
+ mean += mRecordingPeriods[(mCurPeriod + i) % num_periods].getSum(stat);
}
}
mean /= num_periods;
@@ -371,7 +371,7 @@ namespace LLTrace
{
if (mRecordingPeriods[i].getDuration() > 0.f)
{
- mean += mRecordingPeriods[i].getPerSec(stat);
+ mean += mRecordingPeriods[(mCurPeriod + i) % num_periods].getPerSec(stat);
}
}
mean /= num_periods;