diff options
| author | Richard Linden <none@none> | 2012-10-01 19:39:04 -0700 |
|---|---|---|
| committer | Richard Linden <none@none> | 2012-10-01 19:39:04 -0700 |
| commit | 14b1b0b2bb6bac5bc688cc4d14c33f1b680dd3b4 (patch) | |
| tree | 74942f4fef955b5a55031650146e745bbc4ccd6f /indra/llcommon/lltracesampler.cpp | |
| parent | b1baf982b1bd41a150233d0a28d3601226924c65 (diff) | |
SH-3275 WIP Run viewer metrics for object update messages
cleaned up API
samplers are now value types with copy-on-write buffers under the hood
removed coupling with LLThread
Diffstat (limited to 'indra/llcommon/lltracesampler.cpp')
| -rw-r--r-- | indra/llcommon/lltracesampler.cpp | 98 |
1 files changed, 81 insertions, 17 deletions
diff --git a/indra/llcommon/lltracesampler.cpp b/indra/llcommon/lltracesampler.cpp index 0cf01d7a3a..17e58b96e2 100644 --- a/indra/llcommon/lltracesampler.cpp +++ b/indra/llcommon/lltracesampler.cpp @@ -26,6 +26,8 @@ #include "linden_common.h" #include "lltracesampler.h" +#include "lltrace.h" +#include "llthread.h" namespace LLTrace { @@ -34,10 +36,14 @@ namespace LLTrace // Sampler /////////////////////////////////////////////////////////////////////// -Sampler::Sampler(ThreadTrace* thread_trace) +Sampler::Sampler() : mElapsedSeconds(0), mIsStarted(false), - mThreadTrace(thread_trace) + mRatesStart(new AccumulatorBuffer<RateAccumulator<F32> >()), + mRates(new AccumulatorBuffer<RateAccumulator<F32> >()), + mMeasurements(new AccumulatorBuffer<MeasurementAccumulator<F32> >()), + mStackTimers(new AccumulatorBuffer<TimerAccumulator>()), + mStackTimersStart(new AccumulatorBuffer<TimerAccumulator>()) { } @@ -53,9 +59,9 @@ void Sampler::start() void Sampler::reset() { - mF32Stats.reset(); - mS32Stats.reset(); - mStackTimers.reset(); + mRates.write()->reset(); + mMeasurements.write()->reset(); + mStackTimers.write()->reset(); mElapsedSeconds = 0.0; mSamplingTimer.reset(); @@ -66,7 +72,7 @@ void Sampler::resume() if (!mIsStarted) { mSamplingTimer.reset(); - getThreadTrace()->activate(this); + LLTrace::get_thread_trace()->activate(this); mIsStarted = true; } } @@ -76,28 +82,86 @@ void Sampler::stop() if (mIsStarted) { mElapsedSeconds += mSamplingTimer.getElapsedTimeF64(); - getThreadTrace()->deactivate(this); + LLTrace::get_thread_trace()->deactivate(this); mIsStarted = false; } } -ThreadTrace* Sampler::getThreadTrace() + +void Sampler::makePrimary() { - return mThreadTrace; + mRates.write()->makePrimary(); + mMeasurements.write()->makePrimary(); + mStackTimers.write()->makePrimary(); } -void Sampler::makePrimary() +bool Sampler::isPrimary() +{ + return mRates->isPrimary(); +} + +void Sampler::mergeSamples( const Sampler& other ) +{ + mRates.write()->mergeSamples(*other.mRates); + mMeasurements.write()->mergeSamples(*other.mMeasurements); + mStackTimers.write()->mergeSamples(*other.mStackTimers); +} + +void Sampler::initDeltas( const Sampler& other ) +{ + mRatesStart.write()->copyFrom(*other.mRates); + mStackTimersStart.write()->copyFrom(*other.mStackTimers); +} + + +void Sampler::mergeDeltas( const Sampler& other ) +{ + mRates.write()->mergeDeltas(*mRatesStart, *other.mRates); + mStackTimers.write()->mergeDeltas(*mStackTimersStart, *other.mStackTimers); + mMeasurements.write()->mergeSamples(*other.mMeasurements); +} + + +F32 Sampler::getSum( Rate<F32>& stat ) { - mF32Stats.makePrimary(); - mS32Stats.makePrimary(); - mStackTimers.makePrimary(); + return stat.getAccumulator(mRates).getSum(); } -void Sampler::mergeFrom( const Sampler* other ) +F32 Sampler::getSum( Measurement<F32>& stat ) { - mF32Stats.mergeFrom(other->mF32Stats); - mS32Stats.mergeFrom(other->mS32Stats); - mStackTimers.mergeFrom(other->mStackTimers); + return stat.getAccumulator(mMeasurements).getSum(); } + +F32 Sampler::getPerSec( Rate<F32>& stat ) +{ + return stat.getAccumulator(mRates).getSum() / mElapsedSeconds; +} + +F32 Sampler::getMin( Measurement<F32>& stat ) +{ + return stat.getAccumulator(mMeasurements).getMin(); +} + +F32 Sampler::getMax( Measurement<F32>& stat ) +{ + return stat.getAccumulator(mMeasurements).getMax(); +} + +F32 Sampler::getMean( Measurement<F32>& stat ) +{ + return stat.getAccumulator(mMeasurements).getMean(); +} + +F32 Sampler::getStandardDeviation( Measurement<F32>& stat ) +{ + return stat.getAccumulator(mMeasurements).getStandardDeviation(); +} + + + + + + + } |
