From a52d203a4f1d2988e8ffba16258f3f132f22f56d Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Wed, 17 Oct 2012 20:00:07 -0700 Subject: SH-3405 WIP convert existing stats to lltrace system started conversion of llviewerassetstats removed old, dead LLViewerStats code made units tracing require units declaration clean up of units handling --- indra/llcommon/lltrace.h | 44 +++++++++--------- indra/llcommon/lltracerecording.h | 95 +++++++++++++++++++++++++++++++-------- indra/llcommon/llunit.h | 34 ++++++++++---- 3 files changed, 125 insertions(+), 48 deletions(-) (limited to 'indra/llcommon') diff --git a/indra/llcommon/lltrace.h b/indra/llcommon/lltrace.h index 1c6726605a..2a479b31d7 100644 --- a/indra/llcommon/lltrace.h +++ b/indra/llcommon/lltrace.h @@ -192,10 +192,12 @@ namespace LLTrace template class LL_COMMON_API TraceType + : public LLInstanceTracker, std::string> { public: TraceType(const char* name, const char* description = NULL) - : mName(name), + : LLInstanceTracker(name), + mName(name), mDescription(description ? description : "") { mAccumulatorIndex = AccumulatorBuffer::getDefaultBuffer().reserveSlot(); @@ -355,18 +357,17 @@ namespace LLTrace U32 mNumSamples; }; + typedef TraceType > measurement_common_t; + template class LL_COMMON_API Measurement - : public TraceType >, - public LLInstanceTracker, std::string> + : public TraceType > { public: typedef T storage_t; - typedef T base_unit_t; Measurement(const char* name, const char* description = NULL) - : TraceType(name), - LLInstanceTracker(name) + : TraceType(name, description) {} void sample(T value) @@ -376,37 +377,37 @@ namespace LLTrace }; template - class LL_COMMON_API Measurement - : public Measurement + class LL_COMMON_API Measurement + : public TraceType > { public: typedef typename T::storage_t storage_t; - typedef typename T::base_unit_t base_unit_t; typedef Measurement base_measurement_t; Measurement(const char* name, const char* description = NULL) - : Measurement(name, description) + : TraceType(name, description) {} template void sample(UNIT_T value) { - base_measurement_t::sample(((T)value).value()); + T converted_value; + converted_value.assignFrom(value); + getPrimaryAccumulator().sample(converted_value.value()); } }; + typedef TraceType > count_common_t; + template class LL_COMMON_API Count - : public TraceType >, - public LLInstanceTracker, std::string> + : public TraceType > { public: typedef T storage_t; - typedef T base_unit_t; Count(const char* name, const char* description = NULL) - : TraceType(name), - LLInstanceTracker(name) + : TraceType(name) {} void add(T value) @@ -416,22 +417,23 @@ namespace LLTrace }; template - class LL_COMMON_API Count - : public Count + class LL_COMMON_API Count + : public TraceType > { public: typedef typename T::storage_t storage_t; - typedef typename T::base_unit_t base_unit_t; typedef Count base_count_t; Count(const char* name, const char* description = NULL) - : Count(name) + : TraceType(name) {} template void add(UNIT_T value) { - base_count_t::add(((T)value).value()); + T converted_value; + converted_value.assignFrom(value); + getPrimaryAccumulator().add(converted_value.value()); } }; diff --git a/indra/llcommon/lltracerecording.h b/indra/llcommon/lltracerecording.h index 5e7b0752c6..25f4f5c721 100644 --- a/indra/llcommon/lltracerecording.h +++ b/indra/llcommon/lltracerecording.h @@ -112,64 +112,121 @@ namespace LLTrace void update(); // Count accessors + template + T getSum(const TraceType >& stat) const + { + return (T)stat.getAccumulator(mCounts).getSum(); + } + template - typename Count::base_unit_t getSum(const Count& stat) const + T getSum(const Count& stat) const + { + return (T)stat.getAccumulator(mCounts).getSum(); + } + + template + T getPerSec(const TraceType >& stat) const { - return (typename Count::base_unit_t)stat.getAccumulator(mCounts).getSum(); + return (T)stat.getAccumulator(mCounts).getSum() / mElapsedSeconds; } template - typename Count::base_unit_t getPerSec(const Count& stat) const + T getPerSec(const Count& stat) const { - return (typename Count::base_unit_t)stat.getAccumulator(mCounts).getSum() / mElapsedSeconds; + return (T)stat.getAccumulator(mCounts).getSum() / mElapsedSeconds; } // Measurement accessors + template + T getSum(const TraceType >& stat) const + { + return (T)stat.getAccumulator(mMeasurements).getSum(); + + } + template - typename Measurement::base_unit_t getSum(const Measurement& stat) const + T getSum(const Measurement& stat) const { - return (typename Measurement::base_unit_t)stat.getAccumulator(mMeasurements).getSum(); + return (T)stat.getAccumulator(mMeasurements).getSum(); + + } + template + T getPerSec(const TraceType >& stat) const + { + return (T)stat.getAccumulator(mMeasurements).getSum() / mElapsedSeconds; } template - typename Measurement::base_unit_t getPerSec(const Measurement& stat) const + T getPerSec(const Measurement& stat) const { return (typename Count::base_unit_t)stat.getAccumulator(mMeasurements).getSum() / mElapsedSeconds; } - template - typename Measurement::base_unit_t getMin(const Measurement& stat) const + template + T getMin(const TraceType >& stat) const { - return (typename Measurement::base_unit_t)stat.getAccumulator(mMeasurements).getMin(); + return (T)stat.getAccumulator(mMeasurements).getMin(); } template - typename Measurement::base_unit_t getMax(const Measurement& stat) const + T getMin(const Measurement& stat) const { - return (typename Measurement::base_unit_t)stat.getAccumulator(mMeasurements).getMax(); + return (T)stat.getAccumulator(mMeasurements).getMin(); + } + + + template + T getMax(const TraceType >& stat) const + { + return (T)stat.getAccumulator(mMeasurements).getMax(); } template - typename Measurement::base_unit_t getMean(Measurement& stat) const + T getMax(const Measurement& stat) const + { + return (T)stat.getAccumulator(mMeasurements).getMax(); + } + + template + T getMean(const TraceType >& stat) const { - return (typename Measurement::base_unit_t)stat.getAccumulator(mMeasurements).getMean(); + return (T)stat.getAccumulator(mMeasurements).getMean(); } template - typename Measurement::base_unit_t getStandardDeviation(const Measurement& stat) const + T getMean(Measurement& stat) const + { + return (T)stat.getAccumulator(mMeasurements).getMean(); + } + + template + T getStandardDeviation(const TraceType >& stat) const { - return (typename Measurement::base_unit_t)stat.getAccumulator(mMeasurements).getStandardDeviation(); + return (T)stat.getAccumulator(mMeasurements).getStandardDeviation(); } template - typename Measurement::base_unit_t getLastValue(const Measurement& stat) const + T getStandardDeviation(const Measurement& stat) const { - return (typename Measurement::base_unit_t)stat.getAccumulator(mMeasurements).getLastValue(); + return (T)stat.getAccumulator(mMeasurements).getStandardDeviation(); + } + + template + T getLastValue(const TraceType >& stat) const + { + return (T)stat.getAccumulator(mMeasurements).getLastValue(); } template - U32 getSampleCount(const Measurement& stat) const + T getLastValue(const Measurement& stat) const + { + return (T)stat.getAccumulator(mMeasurements).getLastValue(); + } + + + template + U32 getSampleCount(const TraceType >& stat) const { return stat.getAccumulator(mMeasurements).getSampleCount(); } diff --git a/indra/llcommon/llunit.h b/indra/llcommon/llunit.h index d980989c91..e778383959 100644 --- a/indra/llcommon/llunit.h +++ b/indra/llcommon/llunit.h @@ -36,7 +36,7 @@ struct LLUnitType : public BASE_UNIT typedef DERIVED_UNIT unit_t; typedef typename STORAGE_TYPE storage_t; - typedef void is_unit_t; + typedef void is_unit_tag_t; LLUnitType() {} @@ -57,7 +57,7 @@ struct LLUnitType : public BASE_UNIT } template - storage_t value() const + storage_t as() const { return CONVERTED_TYPE(*this).value(); } @@ -80,8 +80,7 @@ struct LLUnitType { typedef T unit_t; typedef STORAGE_TYPE storage_t; - typedef void is_unit_t; - typedef T base_unit_t; + typedef void is_unit_tag_t; LLUnitType() : mBaseValue() @@ -105,6 +104,13 @@ struct LLUnitType storage_t value() const { return mBaseValue; } + template + storage_t as() const + { + return CONVERTED_TYPE(*this).value(); + } + + static storage_t convertToBase(storage_t derived_value) { return (storage_t)derived_value; @@ -354,10 +360,16 @@ bool operator != (LLUnitType first, LLUni template \ unit_name(LLUnitType, SOURCE_TYPE> source) \ { \ - setBaseValue((storage_t)source.unit_name::unit_t::value()); \ + assignFrom(source); \ } \ \ - }; + template \ + void assignFrom(LLUnitType, SOURCE_TYPE> source) \ + { \ + setBaseValue((storage_t)source.unit_name::unit_t::value()); \ + } \ + \ + }; \ #define LL_DECLARE_DERIVED_UNIT(base_unit, derived_unit, conversion_factor) \ template \ @@ -372,12 +384,18 @@ bool operator != (LLUnitType first, LLUni template \ derived_unit(LLUnitType, SOURCE_TYPE> source) \ { \ - setBaseValue((storage_t)source.base_unit::unit_t::value()); \ + assignFrom(source); \ + } \ + \ + template \ + void assignFrom(LLUnitType, SOURCE_TYPE> source) \ + { \ + setBaseValue((storage_t)source.base_unit::unit_t::value()); \ } \ \ static F32 conversionToBaseFactor() { return (F32)(conversion_factor); } \ \ - }; + }; \ namespace LLUnit { -- cgit v1.2.3