From 17df8988fec3f2ba991ca9e34ff8148253a2fc04 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Mon, 7 Oct 2013 13:38:03 -0700 Subject: renamed TraceType to StatType added more MemTrackable types optimized memory usage of LLTrace some more --- indra/llcommon/llfasttimer.cpp | 2 +- indra/llcommon/llfasttimer.h | 10 +- indra/llcommon/lltrace.cpp | 4 +- indra/llcommon/lltrace.h | 127 +++++++++++++++---------- indra/llcommon/lltraceaccumulators.cpp | 8 +- indra/llcommon/lltraceaccumulators.h | 18 ++-- indra/llcommon/lltracerecording.cpp | 104 ++++++++++----------- indra/llcommon/lltracerecording.h | 166 ++++++++++++++++----------------- 8 files changed, 233 insertions(+), 206 deletions(-) (limited to 'indra/llcommon') diff --git a/indra/llcommon/llfasttimer.cpp b/indra/llcommon/llfasttimer.cpp index 32ef01b2b6..c948e0ac85 100755 --- a/indra/llcommon/llfasttimer.cpp +++ b/indra/llcommon/llfasttimer.cpp @@ -165,7 +165,7 @@ U64 TimeBlock::countsPerSecond() #endif TimeBlock::TimeBlock(const char* name, TimeBlock* parent) -: TraceType(name) +: StatType(name) {} TimeBlockTreeNode& TimeBlock::getTreeNode() const diff --git a/indra/llcommon/llfasttimer.h b/indra/llcommon/llfasttimer.h index 4eb12907dc..1266d87f08 100755 --- a/indra/llcommon/llfasttimer.h +++ b/indra/llcommon/llfasttimer.h @@ -86,7 +86,7 @@ LL_FORCE_INLINE class BlockTimer timeThisBlock(class TimeBlock& timer) // stores a "named" timer instance to be reused via multiple BlockTimer stack instances class TimeBlock -: public TraceType, +: public StatType, public LLInstanceTracker { public: @@ -102,14 +102,14 @@ public: child_iter endChildren(); std::vector& getChildren(); - TraceType& callCount() + StatType& callCount() { - return static_cast&>(*(TraceType*)this); + return static_cast&>(*(StatType*)this); } - TraceType& selfTime() + StatType& selfTime() { - return static_cast&>(*(TraceType*)this); + return static_cast&>(*(StatType*)this); } static TimeBlock& getRootTimeBlock(); diff --git a/indra/llcommon/lltrace.cpp b/indra/llcommon/lltrace.cpp index 73846ba900..1ad31cacfe 100644 --- a/indra/llcommon/lltrace.cpp +++ b/indra/llcommon/lltrace.cpp @@ -35,7 +35,7 @@ namespace LLTrace MemStatHandle gTraceMemStat("LLTrace"); -TraceBase::TraceBase( const char* name, const char* description ) +StatBase::StatBase( const char* name, const char* description ) : mName(name), mDescription(description ? description : "") { @@ -47,7 +47,7 @@ TraceBase::TraceBase( const char* name, const char* description ) #endif } -const char* TraceBase::getUnitLabel() const +const char* StatBase::getUnitLabel() const { return ""; } diff --git a/indra/llcommon/lltrace.h b/indra/llcommon/lltrace.h index 3dc2e5248f..325112b9b1 100644 --- a/indra/llcommon/lltrace.h +++ b/indra/llcommon/lltrace.h @@ -38,8 +38,6 @@ #include "llpointer.h" #include "llunits.h" -#include - namespace LLTrace { class Recording; @@ -53,11 +51,11 @@ STORAGE_TYPE storage_value(LLUnit val) { return val.val template STORAGE_TYPE storage_value(LLUnitImplicit val) { return val.value(); } -class TraceBase +class StatBase { public: - TraceBase(const char* name, const char* description); - virtual ~TraceBase() {}; + StatBase(const char* name, const char* description); + virtual ~StatBase() {}; virtual const char* getUnitLabel() const; const std::string& getName() const { return mName; } @@ -69,14 +67,14 @@ protected: }; template -class TraceType -: public TraceBase, - public LLInstanceTracker, std::string> +class StatType +: public StatBase, + public LLInstanceTracker, std::string> { public: - TraceType(const char* name, const char* description = NULL) - : LLInstanceTracker, std::string>(name), - TraceBase(name, description), + StatType(const char* name, const char* description = NULL) + : LLInstanceTracker, std::string>(name), + StatBase(name, description), mAccumulatorIndex(AccumulatorBuffer::getDefaultBuffer()->reserveSlot()) {} @@ -95,38 +93,38 @@ protected: template<> -class TraceType -: public TraceType +class StatType +: public StatType { public: - TraceType(const char* name, const char* description = "") - : TraceType(name, description) + StatType(const char* name, const char* description = "") + : StatType(name, description) {} }; template<> -class TraceType - : public TraceType +class StatType + : public StatType { public: - TraceType(const char* name, const char* description = "") - : TraceType(name, description) + StatType(const char* name, const char* description = "") + : StatType(name, description) {} }; template class EventStatHandle -: public TraceType +: public StatType { public: typedef F64 storage_t; - typedef TraceType trace_t; + typedef StatType stat_t; typedef EventStatHandle self_t; EventStatHandle(const char* name, const char* description = NULL) - : trace_t(name, description) + : stat_t(name, description) {} /*virtual*/ const char* getUnitLabel() const { return LLGetUnitLabel::getUnitLabel(); } @@ -142,15 +140,15 @@ void record(EventStatHandle& measurement, VALUE_T value) template class SampleStatHandle -: public TraceType +: public StatType { public: typedef F64 storage_t; - typedef TraceType trace_t; + typedef StatType stat_t; typedef SampleStatHandle self_t; SampleStatHandle(const char* name, const char* description = NULL) - : trace_t(name, description) + : stat_t(name, description) {} /*virtual*/ const char* getUnitLabel() const { return LLGetUnitLabel::getUnitLabel(); } @@ -165,15 +163,15 @@ void sample(SampleStatHandle& measurement, VALUE_T value) template class CountStatHandle -: public TraceType +: public StatType { public: typedef F64 storage_t; - typedef TraceType trace_t; + typedef StatType stat_t; typedef CountStatHandle self_t; CountStatHandle(const char* name, const char* description = NULL) - : trace_t(name, description) + : stat_t(name, description) {} /*virtual*/ const char* getUnitLabel() const { return LLGetUnitLabel::getUnitLabel(); } @@ -187,34 +185,36 @@ void add(CountStatHandle& count, VALUE_T value) } template<> -class TraceType -: public TraceType +class StatType +: public StatType { public: - TraceType(const char* name, const char* description = "") - : TraceType(name, description) + StatType(const char* name, const char* description = "") + : StatType(name, description) {} }; template<> -class TraceType -: public TraceType +class StatType +: public StatType { public: - TraceType(const char* name, const char* description = "") - : TraceType(name, description) + StatType(const char* name, const char* description = "") + : StatType(name, description) {} }; -class MemStatHandle : public TraceType +class MemStatHandle : public StatType { public: - typedef TraceType trace_t; + typedef StatType stat_t; MemStatHandle(const char* name) - : trace_t(name) - {} + : stat_t(name) + { + mName = name; + } void setName(const char* name) { @@ -224,14 +224,14 @@ public: /*virtual*/ const char* getUnitLabel() const { return "KB"; } - TraceType& allocations() + StatType& allocations() { - return static_cast&>(*(TraceType*)this); + return static_cast&>(*(StatType*)this); } - TraceType& deallocations() + StatType& deallocations() { - return static_cast&>(*(TraceType*)this); + return static_cast&>(*(StatType*)this); } }; @@ -324,7 +324,7 @@ inline void claim_alloc(MemStatHandle& measurement, const T& value) { S32 size = MeasureMem::measureFootprint(value); if(size == 0) return; - MemStatAccumulator& accumulator = measurement.getCurrentAccumulator(); + MemAccumulator& accumulator = measurement.getCurrentAccumulator(); accumulator.mSize.sample(accumulator.mSize.hasValue() ? accumulator.mSize.getLastValue() + (F64)size : (F64)size); accumulator.mAllocations.record(size); } @@ -334,18 +334,18 @@ inline void disclaim_alloc(MemStatHandle& measurement, const T& value) { S32 size = MeasureMem::measureFootprint(value); if(size == 0) return; - MemStatAccumulator& accumulator = measurement.getCurrentAccumulator(); + MemAccumulator& accumulator = measurement.getCurrentAccumulator(); accumulator.mSize.sample(accumulator.mSize.hasValue() ? accumulator.mSize.getLastValue() - (F64)size : -(F64)size); accumulator.mDeallocations.add(size); } template -class MemTrackable +class MemTrackableNonVirtual { public: typedef void mem_trackable_tag_t; - MemTrackable(const char* name) + MemTrackableNonVirtual(const char* name) : mMemFootprint(0) { static bool name_initialized = false; @@ -356,7 +356,7 @@ public: } } - virtual ~MemTrackable() + ~MemTrackableNonVirtual() { disclaimMem(mMemFootprint); } @@ -374,12 +374,27 @@ public: return ll_aligned_malloc(ALIGNMENT, size); } + template + static void* aligned_new(size_t size) + { + claim_alloc(sMemStat, size); + return ll_aligned_malloc(CUSTOM_ALIGNMENT, size); + } + void operator delete(void* ptr, size_t size) { disclaim_alloc(sMemStat, size); ll_aligned_free(ALIGNMENT, ptr); } + template + static void aligned_delete(void* ptr, size_t size) + { + disclaim_alloc(sMemStat, size); + ll_aligned_free(CUSTOM_ALIGNMENT, ptr); + } + + void* operator new [](size_t size) { claim_alloc(sMemStat, size); @@ -420,7 +435,19 @@ private: }; template -MemStatHandle MemTrackable::sMemStat(""); +MemStatHandle MemTrackableNonVirtual::sMemStat(typeid(MemTrackableNonVirtual).name()); +template +class MemTrackable : public MemTrackableNonVirtual +{ +public: + MemTrackable(const char* name) + : MemTrackableNonVirtual(name) + {} + + virtual ~MemTrackable() + {} +}; } + #endif // LL_LLTRACE_H diff --git a/indra/llcommon/lltraceaccumulators.cpp b/indra/llcommon/lltraceaccumulators.cpp index c25bb704f5..7d0e63e76a 100644 --- a/indra/llcommon/lltraceaccumulators.cpp +++ b/indra/llcommon/lltraceaccumulators.cpp @@ -45,7 +45,7 @@ AccumulatorBufferGroup::AccumulatorBufferGroup() claim_alloc(gTraceMemStat, mSamples.capacity() * sizeof(SampleAccumulator)); claim_alloc(gTraceMemStat, mEvents.capacity() * sizeof(EventAccumulator)); claim_alloc(gTraceMemStat, mStackTimers.capacity() * sizeof(TimeBlockAccumulator)); - claim_alloc(gTraceMemStat, mMemStats.capacity() * sizeof(MemStatAccumulator)); + claim_alloc(gTraceMemStat, mMemStats.capacity() * sizeof(MemAccumulator)); } AccumulatorBufferGroup::AccumulatorBufferGroup(const AccumulatorBufferGroup& other) @@ -59,7 +59,7 @@ AccumulatorBufferGroup::AccumulatorBufferGroup(const AccumulatorBufferGroup& oth claim_alloc(gTraceMemStat, mSamples.capacity() * sizeof(SampleAccumulator)); claim_alloc(gTraceMemStat, mEvents.capacity() * sizeof(EventAccumulator)); claim_alloc(gTraceMemStat, mStackTimers.capacity() * sizeof(TimeBlockAccumulator)); - claim_alloc(gTraceMemStat, mMemStats.capacity() * sizeof(MemStatAccumulator)); + claim_alloc(gTraceMemStat, mMemStats.capacity() * sizeof(MemAccumulator)); } AccumulatorBufferGroup::~AccumulatorBufferGroup() @@ -68,7 +68,7 @@ AccumulatorBufferGroup::~AccumulatorBufferGroup() disclaim_alloc(gTraceMemStat, mSamples.capacity() * sizeof(SampleAccumulator)); disclaim_alloc(gTraceMemStat, mEvents.capacity() * sizeof(EventAccumulator)); disclaim_alloc(gTraceMemStat, mStackTimers.capacity() * sizeof(TimeBlockAccumulator)); - disclaim_alloc(gTraceMemStat, mMemStats.capacity() * sizeof(MemStatAccumulator)); + disclaim_alloc(gTraceMemStat, mMemStats.capacity() * sizeof(MemAccumulator)); } void AccumulatorBufferGroup::handOffTo(AccumulatorBufferGroup& other) @@ -108,7 +108,7 @@ void AccumulatorBufferGroup::clearCurrent() AccumulatorBuffer::clearCurrent(); AccumulatorBuffer::clearCurrent(); AccumulatorBuffer::clearCurrent(); - AccumulatorBuffer::clearCurrent(); + AccumulatorBuffer::clearCurrent(); } bool AccumulatorBufferGroup::isCurrent() const diff --git a/indra/llcommon/lltraceaccumulators.h b/indra/llcommon/lltraceaccumulators.h index 27c0910665..85873d469a 100644 --- a/indra/llcommon/lltraceaccumulators.h +++ b/indra/llcommon/lltraceaccumulators.h @@ -52,7 +52,7 @@ namespace LLTrace class AccumulatorBuffer : public LLRefCount { typedef AccumulatorBuffer self_t; - static const S32 ACCUMULATOR_BUFFER_SIZE_INCREMENT = 16; + static const S32 DEFAULT_ACCUMULATOR_BUFFER_SIZE = 32; private: struct StaticAllocationMarker { }; @@ -67,7 +67,7 @@ namespace LLTrace : mStorageSize(0), mStorage(NULL) { - resize(other.mStorageSize); + resize(sNextStorageSlot); for (S32 i = 0; i < sNextStorageSlot; i++) { mStorage[i] = other.mStorage[i]; @@ -152,7 +152,7 @@ namespace LLTrace { // don't perform doubling, as this should only happen during startup // want to keep a tight bounds as we will have a lot of these buffers - resize(mStorageSize + ACCUMULATOR_BUFFER_SIZE_INCREMENT); + resize(mStorageSize + mStorageSize / 2); } llassert(mStorage && next_slot < mStorageSize); return next_slot; @@ -207,7 +207,7 @@ namespace LLTrace // so as not to trigger an access violation sDefaultBuffer = new AccumulatorBuffer(StaticAllocationMarker()); sInitialized = true; - sDefaultBuffer->resize(ACCUMULATOR_BUFFER_SIZE_INCREMENT); + sDefaultBuffer->resize(DEFAULT_ACCUMULATOR_BUFFER_SIZE); } return sDefaultBuffer; } @@ -491,9 +491,9 @@ namespace LLTrace U64 mChildTime; }; - struct MemStatAccumulator + struct MemAccumulator { - typedef MemStatAccumulator self_t; + typedef MemAccumulator self_t; // fake classes that allows us to view different facets of underlying statistic struct AllocationFacet @@ -506,7 +506,7 @@ namespace LLTrace typedef F64Bytes value_t; }; - void addSamples(const MemStatAccumulator& other, EBufferAppendType append_type) + void addSamples(const MemAccumulator& other, EBufferAppendType append_type) { mAllocations.addSamples(other.mAllocations, append_type); mDeallocations.addSamples(other.mDeallocations, append_type); @@ -524,7 +524,7 @@ namespace LLTrace } } - void reset(const MemStatAccumulator* other) + void reset(const MemAccumulator* other) { mSize.reset(other ? &other->mSize : NULL); mAllocations.reset(other ? &other->mAllocations : NULL); @@ -561,7 +561,7 @@ namespace LLTrace AccumulatorBuffer mSamples; AccumulatorBuffer mEvents; AccumulatorBuffer mStackTimers; - AccumulatorBuffer mMemStats; + AccumulatorBuffer mMemStats; }; } diff --git a/indra/llcommon/lltracerecording.cpp b/indra/llcommon/lltracerecording.cpp index 06b4351339..87083eee96 100644 --- a/indra/llcommon/lltracerecording.cpp +++ b/indra/llcommon/lltracerecording.cpp @@ -137,26 +137,26 @@ void Recording::appendRecording( Recording& other ) mElapsedSeconds += other.mElapsedSeconds; } -F64Seconds Recording::getSum(const TraceType& stat) +F64Seconds Recording::getSum(const StatType& stat) { const TimeBlockAccumulator& accumulator = mBuffers->mStackTimers[stat.getIndex()]; return F64Seconds((F64)(accumulator.mTotalTimeCounter) / (F64)LLTrace::TimeBlock::countsPerSecond()); } -F64Seconds Recording::getSum(const TraceType& stat) +F64Seconds Recording::getSum(const StatType& stat) { const TimeBlockAccumulator& accumulator = mBuffers->mStackTimers[stat.getIndex()]; return F64Seconds((F64)(accumulator.mSelfTimeCounter) / (F64)LLTrace::TimeBlock::countsPerSecond()); } -S32 Recording::getSum(const TraceType& stat) +S32 Recording::getSum(const StatType& stat) { return mBuffers->mStackTimers[stat.getIndex()].mCalls; } -F64Seconds Recording::getPerSec(const TraceType& stat) +F64Seconds Recording::getPerSec(const StatType& stat) { const TimeBlockAccumulator& accumulator = mBuffers->mStackTimers[stat.getIndex()]; @@ -164,7 +164,7 @@ F64Seconds Recording::getPerSec(const TraceType& stat) / ((F64)LLTrace::TimeBlock::countsPerSecond() * mElapsedSeconds.value())); } -F64Seconds Recording::getPerSec(const TraceType& stat) +F64Seconds Recording::getPerSec(const StatType& stat) { const TimeBlockAccumulator& accumulator = mBuffers->mStackTimers[stat.getIndex()]; @@ -172,158 +172,158 @@ F64Seconds Recording::getPerSec(const TraceType& stat) +F32 Recording::getPerSec(const StatType& stat) { return (F32)mBuffers->mStackTimers[stat.getIndex()].mCalls / mElapsedSeconds.value(); } -bool Recording::hasValue(const TraceType& stat) +bool Recording::hasValue(const StatType& stat) { return mBuffers->mMemStats[stat.getIndex()].mSize.hasValue(); } -F64Kilobytes Recording::getMin(const TraceType& stat) +F64Kilobytes Recording::getMin(const StatType& stat) { return F64Bytes(mBuffers->mMemStats[stat.getIndex()].mSize.getMin()); } -F64Kilobytes Recording::getMean(const TraceType& stat) +F64Kilobytes Recording::getMean(const StatType& stat) { return F64Bytes(mBuffers->mMemStats[stat.getIndex()].mSize.getMean()); } -F64Kilobytes Recording::getMax(const TraceType& stat) +F64Kilobytes Recording::getMax(const StatType& stat) { return F64Bytes(mBuffers->mMemStats[stat.getIndex()].mSize.getMax()); } -F64Kilobytes Recording::getStandardDeviation(const TraceType& stat) +F64Kilobytes Recording::getStandardDeviation(const StatType& stat) { return F64Bytes(mBuffers->mMemStats[stat.getIndex()].mSize.getStandardDeviation()); } -F64Kilobytes Recording::getLastValue(const TraceType& stat) +F64Kilobytes Recording::getLastValue(const StatType& stat) { return F64Bytes(mBuffers->mMemStats[stat.getIndex()].mSize.getLastValue()); } -F64Kilobytes Recording::getSum(const TraceType& stat) +F64Kilobytes Recording::getSum(const StatType& stat) { return F64Bytes(mBuffers->mMemStats[stat.getIndex()].mAllocations.getSum()); } -F64Kilobytes Recording::getPerSec(const TraceType& stat) +F64Kilobytes Recording::getPerSec(const StatType& stat) { return F64Bytes(mBuffers->mMemStats[stat.getIndex()].mAllocations.getSum() / mElapsedSeconds.value()); } -S32 Recording::getSampleCount(const TraceType& stat) +S32 Recording::getSampleCount(const StatType& stat) { return mBuffers->mMemStats[stat.getIndex()].mAllocations.getSampleCount(); } -F64Kilobytes Recording::getSum(const TraceType& stat) +F64Kilobytes Recording::getSum(const StatType& stat) { return F64Bytes(mBuffers->mMemStats[stat.getIndex()].mDeallocations.getSum()); } -F64Kilobytes Recording::getPerSec(const TraceType& stat) +F64Kilobytes Recording::getPerSec(const StatType& stat) { return F64Bytes(mBuffers->mMemStats[stat.getIndex()].mDeallocations.getSum() / mElapsedSeconds.value()); } -S32 Recording::getSampleCount(const TraceType& stat) +S32 Recording::getSampleCount(const StatType& stat) { return mBuffers->mMemStats[stat.getIndex()].mDeallocations.getSampleCount(); } -F64 Recording::getSum( const TraceType& stat ) +F64 Recording::getSum( const StatType& stat ) { return mBuffers->mCounts[stat.getIndex()].getSum(); } -F64 Recording::getSum( const TraceType& stat ) +F64 Recording::getSum( const StatType& stat ) { return (F64)mBuffers->mEvents[stat.getIndex()].getSum(); } -F64 Recording::getPerSec( const TraceType& stat ) +F64 Recording::getPerSec( const StatType& stat ) { F64 sum = mBuffers->mCounts[stat.getIndex()].getSum(); return sum / mElapsedSeconds.value(); } -S32 Recording::getSampleCount( const TraceType& stat ) +S32 Recording::getSampleCount( const StatType& stat ) { return mBuffers->mCounts[stat.getIndex()].getSampleCount(); } -bool Recording::hasValue(const TraceType& stat) +bool Recording::hasValue(const StatType& stat) { return mBuffers->mSamples[stat.getIndex()].hasValue(); } -F64 Recording::getMin( const TraceType& stat ) +F64 Recording::getMin( const StatType& stat ) { return mBuffers->mSamples[stat.getIndex()].getMin(); } -F64 Recording::getMax( const TraceType& stat ) +F64 Recording::getMax( const StatType& stat ) { return mBuffers->mSamples[stat.getIndex()].getMax(); } -F64 Recording::getMean( const TraceType& stat ) +F64 Recording::getMean( const StatType& stat ) { return mBuffers->mSamples[stat.getIndex()].getMean(); } -F64 Recording::getStandardDeviation( const TraceType& stat ) +F64 Recording::getStandardDeviation( const StatType& stat ) { return mBuffers->mSamples[stat.getIndex()].getStandardDeviation(); } -F64 Recording::getLastValue( const TraceType& stat ) +F64 Recording::getLastValue( const StatType& stat ) { return mBuffers->mSamples[stat.getIndex()].getLastValue(); } -S32 Recording::getSampleCount( const TraceType& stat ) +S32 Recording::getSampleCount( const StatType& stat ) { return mBuffers->mSamples[stat.getIndex()].getSampleCount(); } -bool Recording::hasValue(const TraceType& stat) +bool Recording::hasValue(const StatType& stat) { return mBuffers->mEvents[stat.getIndex()].hasValue(); } -F64 Recording::getMin( const TraceType& stat ) +F64 Recording::getMin( const StatType& stat ) { return mBuffers->mEvents[stat.getIndex()].getMin(); } -F64 Recording::getMax( const TraceType& stat ) +F64 Recording::getMax( const StatType& stat ) { return mBuffers->mEvents[stat.getIndex()].getMax(); } -F64 Recording::getMean( const TraceType& stat ) +F64 Recording::getMean( const StatType& stat ) { return mBuffers->mEvents[stat.getIndex()].getMean(); } -F64 Recording::getStandardDeviation( const TraceType& stat ) +F64 Recording::getStandardDeviation( const StatType& stat ) { return mBuffers->mEvents[stat.getIndex()].getStandardDeviation(); } -F64 Recording::getLastValue( const TraceType& stat ) +F64 Recording::getLastValue( const StatType& stat ) { return mBuffers->mEvents[stat.getIndex()].getLastValue(); } -S32 Recording::getSampleCount( const TraceType& stat ) +S32 Recording::getSampleCount( const StatType& stat ) { return mBuffers->mEvents[stat.getIndex()].getSampleCount(); } @@ -534,7 +534,7 @@ void PeriodicRecording::handleSplitTo(PeriodicRecording& other) getCurRecording().splitTo(other.getCurRecording()); } -F64 PeriodicRecording::getPeriodMin( const TraceType& stat, S32 num_periods /*= S32_MAX*/ ) +F64 PeriodicRecording::getPeriodMin( const StatType& stat, S32 num_periods /*= S32_MAX*/ ) { S32 total_periods = mRecordingPeriods.size(); num_periods = llmin(num_periods, isStarted() ? total_periods - 1 : total_periods); @@ -556,7 +556,7 @@ F64 PeriodicRecording::getPeriodMin( const TraceType& stat, S3 : NaN; } -F64 PeriodicRecording::getPeriodMax( const TraceType& stat, S32 num_periods /*= S32_MAX*/ ) +F64 PeriodicRecording::getPeriodMax( const StatType& stat, S32 num_periods /*= S32_MAX*/ ) { S32 total_periods = mRecordingPeriods.size(); num_periods = llmin(num_periods, isStarted() ? total_periods - 1 : total_periods); @@ -579,7 +579,7 @@ F64 PeriodicRecording::getPeriodMax( const TraceType& stat, S3 } // calculates means using aggregates per period -F64 PeriodicRecording::getPeriodMean( const TraceType& stat, S32 num_periods /*= S32_MAX*/ ) +F64 PeriodicRecording::getPeriodMean( const StatType& stat, S32 num_periods /*= S32_MAX*/ ) { S32 total_periods = mRecordingPeriods.size(); num_periods = llmin(num_periods, isStarted() ? total_periods - 1 : total_periods); @@ -603,7 +603,7 @@ F64 PeriodicRecording::getPeriodMean( const TraceType& stat, S } -F64 PeriodicRecording::getPeriodStandardDeviation( const TraceType& stat, S32 num_periods /*= S32_MAX*/ ) +F64 PeriodicRecording::getPeriodStandardDeviation( const StatType& stat, S32 num_periods /*= S32_MAX*/ ) { S32 total_periods = mRecordingPeriods.size(); num_periods = llmin(num_periods, isStarted() ? total_periods - 1 : total_periods); @@ -628,7 +628,7 @@ F64 PeriodicRecording::getPeriodStandardDeviation( const TraceType& stat, S32 num_periods /*= S32_MAX*/ ) +F64 PeriodicRecording::getPeriodMin( const StatType& stat, S32 num_periods /*= S32_MAX*/ ) { S32 total_periods = mRecordingPeriods.size(); num_periods = llmin(num_periods, isStarted() ? total_periods - 1 : total_periods); @@ -650,7 +650,7 @@ F64 PeriodicRecording::getPeriodMin( const TraceType& stat, S : NaN; } -F64 PeriodicRecording::getPeriodMax(const TraceType& stat, S32 num_periods /*= S32_MAX*/) +F64 PeriodicRecording::getPeriodMax(const StatType& stat, S32 num_periods /*= S32_MAX*/) { S32 total_periods = mRecordingPeriods.size(); num_periods = llmin(num_periods, isStarted() ? total_periods - 1 : total_periods); @@ -673,7 +673,7 @@ F64 PeriodicRecording::getPeriodMax(const TraceType& stat, S3 } -F64 PeriodicRecording::getPeriodMean( const TraceType& stat, S32 num_periods /*= S32_MAX*/ ) +F64 PeriodicRecording::getPeriodMean( const StatType& stat, S32 num_periods /*= S32_MAX*/ ) { S32 total_periods = mRecordingPeriods.size(); num_periods = llmin(num_periods, isStarted() ? total_periods - 1 : total_periods); @@ -696,7 +696,7 @@ F64 PeriodicRecording::getPeriodMean( const TraceType& stat, : NaN; } -F64 PeriodicRecording::getPeriodStandardDeviation( const TraceType& stat, S32 num_periods /*= S32_MAX*/ ) +F64 PeriodicRecording::getPeriodStandardDeviation( const StatType& stat, S32 num_periods /*= S32_MAX*/ ) { S32 total_periods = mRecordingPeriods.size(); num_periods = llmin(num_periods, isStarted() ? total_periods - 1 : total_periods); @@ -722,7 +722,7 @@ F64 PeriodicRecording::getPeriodStandardDeviation( const TraceType& stat, S32 num_periods /*= S32_MAX*/ ) +F64Kilobytes PeriodicRecording::getPeriodMin( const StatType& stat, S32 num_periods /*= S32_MAX*/ ) { S32 total_periods = mRecordingPeriods.size(); num_periods = llmin(num_periods, isStarted() ? total_periods - 1 : total_periods); @@ -739,10 +739,10 @@ F64Kilobytes PeriodicRecording::getPeriodMin( const TraceType&>(stat), num_periods); + return getPeriodMin(static_cast&>(stat), num_periods); } -F64Kilobytes PeriodicRecording::getPeriodMax(const TraceType& stat, S32 num_periods /*= S32_MAX*/) +F64Kilobytes PeriodicRecording::getPeriodMax(const StatType& stat, S32 num_periods /*= S32_MAX*/) { S32 total_periods = mRecordingPeriods.size(); num_periods = llmin(num_periods, isStarted() ? total_periods - 1 : total_periods); @@ -759,10 +759,10 @@ F64Kilobytes PeriodicRecording::getPeriodMax(const TraceType F64Kilobytes PeriodicRecording::getPeriodMax(const MemStatHandle& stat, S32 num_periods) { - return getPeriodMax(static_cast&>(stat), num_periods); + return getPeriodMax(static_cast&>(stat), num_periods); } -F64Kilobytes PeriodicRecording::getPeriodMean( const TraceType& stat, S32 num_periods /*= S32_MAX*/ ) +F64Kilobytes PeriodicRecording::getPeriodMean( const StatType& stat, S32 num_periods /*= S32_MAX*/ ) { S32 total_periods = mRecordingPeriods.size(); num_periods = llmin(num_periods, isStarted() ? total_periods - 1 : total_periods); @@ -780,10 +780,10 @@ F64Kilobytes PeriodicRecording::getPeriodMean( const TraceType&>(stat), num_periods); + return getPeriodMean(static_cast&>(stat), num_periods); } -F64Kilobytes PeriodicRecording::getPeriodStandardDeviation( const TraceType& stat, S32 num_periods /*= S32_MAX*/ ) +F64Kilobytes PeriodicRecording::getPeriodStandardDeviation( const StatType& stat, S32 num_periods /*= S32_MAX*/ ) { S32 total_periods = mRecordingPeriods.size(); num_periods = llmin(num_periods, isStarted() ? total_periods - 1 : total_periods); @@ -810,7 +810,7 @@ F64Kilobytes PeriodicRecording::getPeriodStandardDeviation( const TraceType&>(stat), num_periods); + return getPeriodStandardDeviation(static_cast&>(stat), num_periods); } /////////////////////////////////////////////////////////////////////// diff --git a/indra/llcommon/lltracerecording.h b/indra/llcommon/lltracerecording.h index 8bb0b1892f..810f796666 100644 --- a/indra/llcommon/lltracerecording.h +++ b/indra/llcommon/lltracerecording.h @@ -113,7 +113,7 @@ private: namespace LLTrace { template - class TraceType; + class StatType; template class CountStatHandle; @@ -168,135 +168,135 @@ namespace LLTrace void makeUnique() { mBuffers.makeUnique(); } // Timer accessors - F64Seconds getSum(const TraceType& stat); - F64Seconds getSum(const TraceType& stat); - S32 getSum(const TraceType& stat); + F64Seconds getSum(const StatType& stat); + F64Seconds getSum(const StatType& stat); + S32 getSum(const StatType& stat); - F64Seconds getPerSec(const TraceType& stat); - F64Seconds getPerSec(const TraceType& stat); - F32 getPerSec(const TraceType& stat); + F64Seconds getPerSec(const StatType& stat); + F64Seconds getPerSec(const StatType& stat); + F32 getPerSec(const StatType& stat); // Memory accessors - bool hasValue(const TraceType& stat); + bool hasValue(const StatType& stat); - F64Kilobytes getMin(const TraceType& stat); - F64Kilobytes getMean(const TraceType& stat); - F64Kilobytes getMax(const TraceType& stat); - F64Kilobytes getStandardDeviation(const TraceType& stat); - F64Kilobytes getLastValue(const TraceType& stat); + F64Kilobytes getMin(const StatType& stat); + F64Kilobytes getMean(const StatType& stat); + F64Kilobytes getMax(const StatType& stat); + F64Kilobytes getStandardDeviation(const StatType& stat); + F64Kilobytes getLastValue(const StatType& stat); - F64Kilobytes getSum(const TraceType& stat); - F64Kilobytes getPerSec(const TraceType& stat); - S32 getSampleCount(const TraceType& stat); + F64Kilobytes getSum(const StatType& stat); + F64Kilobytes getPerSec(const StatType& stat); + S32 getSampleCount(const StatType& stat); - F64Kilobytes getSum(const TraceType& stat); - F64Kilobytes getPerSec(const TraceType& stat); - S32 getSampleCount(const TraceType& stat); + F64Kilobytes getSum(const StatType& stat); + F64Kilobytes getPerSec(const StatType& stat); + S32 getSampleCount(const StatType& stat); // CountStatHandle accessors - F64 getSum(const TraceType& stat); + F64 getSum(const StatType& stat); template typename RelatedTypes::sum_t getSum(const CountStatHandle& stat) { - return (typename RelatedTypes::sum_t)getSum(static_cast&> (stat)); + return (typename RelatedTypes::sum_t)getSum(static_cast&> (stat)); } - F64 getPerSec(const TraceType& stat); + F64 getPerSec(const StatType& stat); template typename RelatedTypes::fractional_t getPerSec(const CountStatHandle& stat) { - return (typename RelatedTypes::fractional_t)getPerSec(static_cast&> (stat)); + return (typename RelatedTypes::fractional_t)getPerSec(static_cast&> (stat)); } - S32 getSampleCount(const TraceType& stat); + S32 getSampleCount(const StatType& stat); // SampleStatHandle accessors - bool hasValue(const TraceType& stat); + bool hasValue(const StatType& stat); - F64 getMin(const TraceType& stat); + F64 getMin(const StatType& stat); template T getMin(const SampleStatHandle& stat) { - return (T)getMin(static_cast&> (stat)); + return (T)getMin(static_cast&> (stat)); } - F64 getMax(const TraceType& stat); + F64 getMax(const StatType& stat); template T getMax(const SampleStatHandle& stat) { - return (T)getMax(static_cast&> (stat)); + return (T)getMax(static_cast&> (stat)); } - F64 getMean(const TraceType& stat); + F64 getMean(const StatType& stat); template typename RelatedTypes::fractional_t getMean(SampleStatHandle& stat) { - return (typename RelatedTypes::fractional_t)getMean(static_cast&> (stat)); + return (typename RelatedTypes::fractional_t)getMean(static_cast&> (stat)); } - F64 getStandardDeviation(const TraceType& stat); + F64 getStandardDeviation(const StatType& stat); template typename RelatedTypes::fractional_t getStandardDeviation(const SampleStatHandle& stat) { - return (typename RelatedTypes::fractional_t)getStandardDeviation(static_cast&> (stat)); + return (typename RelatedTypes::fractional_t)getStandardDeviation(static_cast&> (stat)); } - F64 getLastValue(const TraceType& stat); + F64 getLastValue(const StatType& stat); template T getLastValue(const SampleStatHandle& stat) { - return (T)getLastValue(static_cast&> (stat)); + return (T)getLastValue(static_cast&> (stat)); } - S32 getSampleCount(const TraceType& stat); + S32 getSampleCount(const StatType& stat); // EventStatHandle accessors - bool hasValue(const TraceType& stat); + bool hasValue(const StatType& stat); - F64 getSum(const TraceType& stat); + F64 getSum(const StatType& stat); template typename RelatedTypes::sum_t getSum(const EventStatHandle& stat) { - return (typename RelatedTypes::sum_t)getSum(static_cast&> (stat)); + return (typename RelatedTypes::sum_t)getSum(static_cast&> (stat)); } - F64 getMin(const TraceType& stat); + F64 getMin(const StatType& stat); template T getMin(const EventStatHandle& stat) { - return (T)getMin(static_cast&> (stat)); + return (T)getMin(static_cast&> (stat)); } - F64 getMax(const TraceType& stat); + F64 getMax(const StatType& stat); template T getMax(const EventStatHandle& stat) { - return (T)getMax(static_cast&> (stat)); + return (T)getMax(static_cast&> (stat)); } - F64 getMean(const TraceType& stat); + F64 getMean(const StatType& stat); template typename RelatedTypes::fractional_t getMean(EventStatHandle& stat) { - return (typename RelatedTypes::fractional_t)getMean(static_cast&> (stat)); + return (typename RelatedTypes::fractional_t)getMean(static_cast&> (stat)); } - F64 getStandardDeviation(const TraceType& stat); + F64 getStandardDeviation(const StatType& stat); template typename RelatedTypes::fractional_t getStandardDeviation(const EventStatHandle& stat) { - return (typename RelatedTypes::fractional_t)getStandardDeviation(static_cast&> (stat)); + return (typename RelatedTypes::fractional_t)getStandardDeviation(static_cast&> (stat)); } - F64 getLastValue(const TraceType& stat); + F64 getLastValue(const StatType& stat); template T getLastValue(const EventStatHandle& stat) { - return (T)getLastValue(static_cast&> (stat)); + return (T)getLastValue(static_cast&> (stat)); } - S32 getSampleCount(const TraceType& stat); + S32 getSampleCount(const StatType& stat); F64Seconds getDuration() const { return mElapsedSeconds; } @@ -342,7 +342,7 @@ namespace LLTrace Recording snapshotCurRecording() const; template - S32 getSampleCount(const TraceType& stat, S32 num_periods = S32_MAX) + S32 getSampleCount(const StatType& stat, S32 num_periods = S32_MAX) { S32 total_periods = mNumPeriods; num_periods = llmin(num_periods, isStarted() ? total_periods - 1 : total_periods); @@ -362,7 +362,7 @@ namespace LLTrace // catch all for stats that have a defined sum template - typename T::value_t getPeriodMin(const TraceType& stat, S32 num_periods = S32_MAX) + typename T::value_t getPeriodMin(const StatType& stat, S32 num_periods = S32_MAX) { S32 total_periods = mNumPeriods; num_periods = llmin(num_periods, isStarted() ? total_periods - 1 : total_periods); @@ -379,28 +379,28 @@ namespace LLTrace template T getPeriodMin(const CountStatHandle& stat, S32 num_periods = S32_MAX) { - return T(getPeriodMin(static_cast&>(stat), num_periods)); + return T(getPeriodMin(static_cast&>(stat), num_periods)); } - F64 getPeriodMin(const TraceType& stat, S32 num_periods = S32_MAX); + F64 getPeriodMin(const StatType& stat, S32 num_periods = S32_MAX); template T getPeriodMin(const SampleStatHandle& stat, S32 num_periods = S32_MAX) { - return T(getPeriodMin(static_cast&>(stat), num_periods)); + return T(getPeriodMin(static_cast&>(stat), num_periods)); } - F64 getPeriodMin(const TraceType& stat, S32 num_periods = S32_MAX); + F64 getPeriodMin(const StatType& stat, S32 num_periods = S32_MAX); template T getPeriodMin(const EventStatHandle& stat, S32 num_periods = S32_MAX) { - return T(getPeriodMin(static_cast&>(stat), num_periods)); + return T(getPeriodMin(static_cast&>(stat), num_periods)); } - F64Kilobytes getPeriodMin(const TraceType& stat, S32 num_periods = S32_MAX); + F64Kilobytes getPeriodMin(const StatType& stat, S32 num_periods = S32_MAX); F64Kilobytes getPeriodMin(const MemStatHandle& stat, S32 num_periods = S32_MAX); template - typename RelatedTypes::fractional_t getPeriodMinPerSec(const TraceType& stat, S32 num_periods = S32_MAX) + typename RelatedTypes::fractional_t getPeriodMinPerSec(const StatType& stat, S32 num_periods = S32_MAX) { S32 total_periods = mNumPeriods; num_periods = llmin(num_periods, isStarted() ? total_periods - 1 : total_periods); @@ -417,7 +417,7 @@ namespace LLTrace template typename RelatedTypes::fractional_t getPeriodMinPerSec(const CountStatHandle& stat, S32 num_periods = S32_MAX) { - return typename RelatedTypes::fractional_t(getPeriodMinPerSec(static_cast&>(stat), num_periods)); + return typename RelatedTypes::fractional_t(getPeriodMinPerSec(static_cast&>(stat), num_periods)); } // @@ -426,7 +426,7 @@ namespace LLTrace // catch all for stats that have a defined sum template - typename T::value_t getPeriodMax(const TraceType& stat, S32 num_periods = S32_MAX) + typename T::value_t getPeriodMax(const StatType& stat, S32 num_periods = S32_MAX) { S32 total_periods = mNumPeriods; num_periods = llmin(num_periods, isStarted() ? total_periods - 1 : total_periods); @@ -443,28 +443,28 @@ namespace LLTrace template T getPeriodMax(const CountStatHandle& stat, S32 num_periods = S32_MAX) { - return T(getPeriodMax(static_cast&>(stat), num_periods)); + return T(getPeriodMax(static_cast&>(stat), num_periods)); } - F64 getPeriodMax(const TraceType& stat, S32 num_periods = S32_MAX); + F64 getPeriodMax(const StatType& stat, S32 num_periods = S32_MAX); template T getPeriodMax(const SampleStatHandle& stat, S32 num_periods = S32_MAX) { - return T(getPeriodMax(static_cast&>(stat), num_periods)); + return T(getPeriodMax(static_cast&>(stat), num_periods)); } - F64 getPeriodMax(const TraceType& stat, S32 num_periods = S32_MAX); + F64 getPeriodMax(const StatType& stat, S32 num_periods = S32_MAX); template T getPeriodMax(const EventStatHandle& stat, S32 num_periods = S32_MAX) { - return T(getPeriodMax(static_cast&>(stat), num_periods)); + return T(getPeriodMax(static_cast&>(stat), num_periods)); } - F64Kilobytes getPeriodMax(const TraceType& stat, S32 num_periods = S32_MAX); + F64Kilobytes getPeriodMax(const StatType& stat, S32 num_periods = S32_MAX); F64Kilobytes getPeriodMax(const MemStatHandle& stat, S32 num_periods = S32_MAX); template - typename RelatedTypes::fractional_t getPeriodMaxPerSec(const TraceType& stat, S32 num_periods = S32_MAX) + typename RelatedTypes::fractional_t getPeriodMaxPerSec(const StatType& stat, S32 num_periods = S32_MAX) { S32 total_periods = mNumPeriods; num_periods = llmin(num_periods, isStarted() ? total_periods - 1 : total_periods); @@ -481,7 +481,7 @@ namespace LLTrace template typename RelatedTypes::fractional_t getPeriodMaxPerSec(const CountStatHandle& stat, S32 num_periods = S32_MAX) { - return typename RelatedTypes::fractional_t(getPeriodMaxPerSec(static_cast&>(stat), num_periods)); + return typename RelatedTypes::fractional_t(getPeriodMaxPerSec(static_cast&>(stat), num_periods)); } // @@ -490,7 +490,7 @@ namespace LLTrace // catch all for stats that have a defined sum template - typename RelatedTypes::fractional_t getPeriodMean(const TraceType& stat, S32 num_periods = S32_MAX) + typename RelatedTypes::fractional_t getPeriodMean(const StatType& stat, S32 num_periods = S32_MAX) { S32 total_periods = mNumPeriods; num_periods = llmin(num_periods, isStarted() ? total_periods - 1 : total_periods); @@ -513,27 +513,27 @@ namespace LLTrace template typename RelatedTypes::fractional_t getPeriodMean(const CountStatHandle& stat, S32 num_periods = S32_MAX) { - return typename RelatedTypes::fractional_t(getPeriodMean(static_cast&>(stat), num_periods)); + return typename RelatedTypes::fractional_t(getPeriodMean(static_cast&>(stat), num_periods)); } - F64 getPeriodMean(const TraceType& stat, S32 num_periods = S32_MAX); + F64 getPeriodMean(const StatType& stat, S32 num_periods = S32_MAX); template typename RelatedTypes::fractional_t getPeriodMean(const SampleStatHandle& stat, S32 num_periods = S32_MAX) { - return typename RelatedTypes::fractional_t(getPeriodMean(static_cast&>(stat), num_periods)); + return typename RelatedTypes::fractional_t(getPeriodMean(static_cast&>(stat), num_periods)); } - F64 getPeriodMean(const TraceType& stat, S32 num_periods = S32_MAX); + F64 getPeriodMean(const StatType& stat, S32 num_periods = S32_MAX); template typename RelatedTypes::fractional_t getPeriodMean(const EventStatHandle& stat, S32 num_periods = S32_MAX) { - return typename RelatedTypes::fractional_t(getPeriodMean(static_cast&>(stat), num_periods)); + return typename RelatedTypes::fractional_t(getPeriodMean(static_cast&>(stat), num_periods)); } - F64Kilobytes getPeriodMean(const TraceType& stat, S32 num_periods = S32_MAX); + F64Kilobytes getPeriodMean(const StatType& stat, S32 num_periods = S32_MAX); F64Kilobytes getPeriodMean(const MemStatHandle& stat, S32 num_periods = S32_MAX); template - typename RelatedTypes::fractional_t getPeriodMeanPerSec(const TraceType& stat, S32 num_periods = S32_MAX) + typename RelatedTypes::fractional_t getPeriodMeanPerSec(const StatType& stat, S32 num_periods = S32_MAX) { S32 total_periods = mNumPeriods; num_periods = llmin(num_periods, isStarted() ? total_periods - 1 : total_periods); @@ -557,29 +557,29 @@ namespace LLTrace template typename RelatedTypes::fractional_t getPeriodMeanPerSec(const CountStatHandle& stat, S32 num_periods = S32_MAX) { - return typename RelatedTypes::fractional_t(getPeriodMeanPerSec(static_cast&>(stat), num_periods)); + return typename RelatedTypes::fractional_t(getPeriodMeanPerSec(static_cast&>(stat), num_periods)); } // // PERIODIC STANDARD DEVIATION // - F64 getPeriodStandardDeviation(const TraceType& stat, S32 num_periods = S32_MAX); + F64 getPeriodStandardDeviation(const StatType& stat, S32 num_periods = S32_MAX); template typename RelatedTypes::fractional_t getPeriodStandardDeviation(const SampleStatHandle& stat, S32 num_periods = S32_MAX) { - return typename RelatedTypes::fractional_t(getPeriodStandardDeviation(static_cast&>(stat), num_periods)); + return typename RelatedTypes::fractional_t(getPeriodStandardDeviation(static_cast&>(stat), num_periods)); } - F64 getPeriodStandardDeviation(const TraceType& stat, S32 num_periods = S32_MAX); + F64 getPeriodStandardDeviation(const StatType& stat, S32 num_periods = S32_MAX); template typename RelatedTypes::fractional_t getPeriodStandardDeviation(const EventStatHandle& stat, S32 num_periods = S32_MAX) { - return typename RelatedTypes::fractional_t(getPeriodStandardDeviation(static_cast&>(stat), num_periods)); + return typename RelatedTypes::fractional_t(getPeriodStandardDeviation(static_cast&>(stat), num_periods)); } - F64Kilobytes getPeriodStandardDeviation(const TraceType& stat, S32 num_periods = S32_MAX); + F64Kilobytes getPeriodStandardDeviation(const StatType& stat, S32 num_periods = S32_MAX); F64Kilobytes getPeriodStandardDeviation(const MemStatHandle& stat, S32 num_periods = S32_MAX); private: -- cgit v1.2.3