diff options
author | Richard Linden <none@none> | 2012-11-07 15:32:12 -0800 |
---|---|---|
committer | Richard Linden <none@none> | 2012-11-07 15:32:12 -0800 |
commit | ed17c181dd37f56b808838748d289ee7bb5567ec (patch) | |
tree | f942d7b006510efea8b2626fdba41a575079ccdf /indra/llcommon | |
parent | 9d70448a1275b80a829e16b6d08d29919748c823 (diff) |
SH-3499 WIP Ensure asset stats output is correct
further fixes to implicit conversion of unit types
Diffstat (limited to 'indra/llcommon')
-rw-r--r-- | indra/llcommon/lldate.cpp | 11 | ||||
-rw-r--r-- | indra/llcommon/lldate.h | 3 | ||||
-rw-r--r-- | indra/llcommon/lltimer.cpp | 15 | ||||
-rw-r--r-- | indra/llcommon/lltimer.h | 21 | ||||
-rw-r--r-- | indra/llcommon/lltracerecording.cpp | 19 | ||||
-rw-r--r-- | indra/llcommon/lltracerecording.h | 18 | ||||
-rw-r--r-- | indra/llcommon/llunit.h | 141 |
7 files changed, 80 insertions, 148 deletions
diff --git a/indra/llcommon/lldate.cpp b/indra/llcommon/lldate.cpp index 030ef6a3c7..d8b3dfe6c6 100644 --- a/indra/llcommon/lldate.cpp +++ b/indra/llcommon/lldate.cpp @@ -48,18 +48,15 @@ static const F64 LL_APR_USEC_PER_SEC = 1000000.0; LLDate::LLDate() : mSecondsSinceEpoch(DATE_EPOCH) -{ -} +{} LLDate::LLDate(const LLDate& date) : mSecondsSinceEpoch(date.mSecondsSinceEpoch) -{ -} +{} -LLDate::LLDate(F64 seconds_since_epoch) : +LLDate::LLDate(LLUnit::Seconds<F64> seconds_since_epoch) : mSecondsSinceEpoch(seconds_since_epoch) -{ -} +{} LLDate::LLDate(const std::string& iso8601_date) { diff --git a/indra/llcommon/lldate.h b/indra/llcommon/lldate.h index 7ff8b550ad..0500b1dcd8 100644 --- a/indra/llcommon/lldate.h +++ b/indra/llcommon/lldate.h @@ -33,6 +33,7 @@ #include <string> #include "stdtypes.h" +#include "llunit.h" /** * @class LLDate @@ -58,7 +59,7 @@ public: * * @pararm seconds_since_epoch The number of seconds since UTC epoch. */ - LLDate(F64 seconds_since_epoch); + LLDate(LLUnit::Seconds<F64> seconds_since_epoch); /** * @brief Construct a date from a string representation diff --git a/indra/llcommon/lltimer.cpp b/indra/llcommon/lltimer.cpp index 9ebc6de7f4..05f6b789e4 100644 --- a/indra/llcommon/lltimer.cpp +++ b/indra/llcommon/lltimer.cpp @@ -287,14 +287,15 @@ LLTimer::~LLTimer() } // static -U64 LLTimer::getTotalTime() +LLUnit::Microseconds<U64> LLTimer::getTotalTime() { + LLUnit::Seconds<F64> sec = LLUnit::Milliseconds<U32>(2000) + LLUnit::Hours<F32>(1.f / 360.f); // simply call into the implementation function. return totalTime(); } // static -F64 LLTimer::getTotalSeconds() +LLUnit::Seconds<F64> LLTimer::getTotalSeconds() { return U64_to_F64(getTotalTime()) * USEC_TO_SEC_F64; } @@ -343,23 +344,23 @@ U64 getElapsedTimeAndUpdate(U64& lastClockCount) } -F64 LLTimer::getElapsedTimeF64() const +LLUnit::Seconds<F64> LLTimer::getElapsedTimeF64() const { U64 last = mLastClockCount; return (F64)getElapsedTimeAndUpdate(last) * gClockFrequencyInv; } -F32 LLTimer::getElapsedTimeF32() const +LLUnit::Seconds<F32> LLTimer::getElapsedTimeF32() const { return (F32)getElapsedTimeF64(); } -F64 LLTimer::getElapsedTimeAndResetF64() +LLUnit::Seconds<F64> LLTimer::getElapsedTimeAndResetF64() { return (F64)getElapsedTimeAndUpdate(mLastClockCount) * gClockFrequencyInv; } -F32 LLTimer::getElapsedTimeAndResetF32() +LLUnit::Seconds<F32> LLTimer::getElapsedTimeAndResetF32() { return (F32)getElapsedTimeAndResetF64(); } @@ -372,7 +373,7 @@ void LLTimer::setTimerExpirySec(F32 expiration) + (U64)((F32)(expiration * gClockFrequency)); } -F32 LLTimer::getRemainingTimeF32() const +LLUnit::Seconds<F32> LLTimer::getRemainingTimeF32() const { U64 cur_ticks = get_clock_count(); if (cur_ticks > mExpirationTicks) diff --git a/indra/llcommon/lltimer.h b/indra/llcommon/lltimer.h index 513de0605d..e0a880a346 100644 --- a/indra/llcommon/lltimer.h +++ b/indra/llcommon/lltimer.h @@ -37,6 +37,7 @@ #include <string> #include <list> // units conversions +#include "llunit.h" #ifndef USEC_PER_SEC const U32 USEC_PER_SEC = 1000000; #endif @@ -55,7 +56,7 @@ public: protected: U64 mLastClockCount; U64 mExpirationTicks; - BOOL mStarted; + bool mStarted; public: LLTimer(); @@ -66,16 +67,16 @@ public: // Return a high precision number of seconds since the start of // this application instance. - static F64 getElapsedSeconds() + static LLUnit::Seconds<F64> getElapsedSeconds() { return sTimer->getElapsedTimeF64(); } // Return a high precision usec since epoch - static U64 getTotalTime(); + static LLUnit::Microseconds<U64> getTotalTime(); // Return a high precision seconds since epoch - static F64 getTotalSeconds(); + static LLUnit::Seconds<F64> getTotalSeconds(); // MANIPULATORS @@ -86,18 +87,18 @@ public: void setTimerExpirySec(F32 expiration); BOOL checkExpirationAndReset(F32 expiration); BOOL hasExpired() const; - F32 getElapsedTimeAndResetF32(); // Returns elapsed time in seconds with reset - F64 getElapsedTimeAndResetF64(); + LLUnit::Seconds<F32> getElapsedTimeAndResetF32(); // Returns elapsed time in seconds with reset + LLUnit::Seconds<F64> getElapsedTimeAndResetF64(); - F32 getRemainingTimeF32() const; + LLUnit::Seconds<F32> getRemainingTimeF32() const; static BOOL knownBadTimer(); // ACCESSORS - F32 getElapsedTimeF32() const; // Returns elapsed time in seconds - F64 getElapsedTimeF64() const; // Returns elapsed time in seconds + LLUnit::Seconds<F32> getElapsedTimeF32() const; // Returns elapsed time in seconds + LLUnit::Seconds<F64> getElapsedTimeF64() const; // Returns elapsed time in seconds - BOOL getStarted() const { return mStarted; } + bool getStarted() const { return mStarted; } static U64 getCurrentClockCount(); // Returns the raw clockticks diff --git a/indra/llcommon/lltracerecording.cpp b/indra/llcommon/lltracerecording.cpp index 435c49106f..4252ed57dc 100644 --- a/indra/llcommon/lltracerecording.cpp +++ b/indra/llcommon/lltracerecording.cpp @@ -46,6 +46,25 @@ Recording::Recording() mStackTimers(new AccumulatorBuffer<TimerAccumulator>()) {} +Recording::Recording( const Recording& other ) +{ + llassert(other.mCountsFloat.get() != NULL); + mSamplingTimer = other.mSamplingTimer; + mElapsedSeconds = other.mElapsedSeconds; + mCountsFloat = other.mCountsFloat; + mMeasurementsFloat = other.mMeasurementsFloat; + mCounts = other.mCounts; + mMeasurements = other.mMeasurements; + mStackTimers = other.mStackTimers; + + LLStopWatchControlsMixin::initTo(other.getPlayState()); + if (other.isStarted()) + { + handleStart(); + } +} + + Recording::~Recording() {} diff --git a/indra/llcommon/lltracerecording.h b/indra/llcommon/lltracerecording.h index 31901b599c..fc96631ce0 100644 --- a/indra/llcommon/lltracerecording.h +++ b/indra/llcommon/lltracerecording.h @@ -106,23 +106,7 @@ namespace LLTrace public: Recording(); - Recording(const Recording& other) - { - mSamplingTimer = other.mSamplingTimer; - mElapsedSeconds = other.mElapsedSeconds; - mCountsFloat = other.mCountsFloat; - mMeasurementsFloat = other.mMeasurementsFloat; - mCounts = other.mCounts; - mMeasurements = other.mMeasurements; - mStackTimers = other.mStackTimers; - - LLStopWatchControlsMixin::initTo(other.getPlayState()); - if (other.isStarted()) - { - handleStart(); - } - - } + Recording(const Recording& other); ~Recording(); void makePrimary(); diff --git a/indra/llcommon/llunit.h b/indra/llcommon/llunit.h index 98e4de32fa..4519905707 100644 --- a/indra/llcommon/llunit.h +++ b/indra/llcommon/llunit.h @@ -51,6 +51,11 @@ struct LLUnitType : public BASE_UNIT return static_cast<unit_t&>(*this); } + operator storage_t () const + { + return value(); + } + storage_t value() const { return convertToDerived(mBaseValue); @@ -102,6 +107,11 @@ struct LLUnitType<STORAGE_TYPE, T, T> return static_cast<unit_t&>(*this); } + operator storage_t () const + { + return value(); + } + storage_t value() const { return mBaseValue; } template<typename CONVERTED_TYPE> @@ -110,7 +120,6 @@ struct LLUnitType<STORAGE_TYPE, T, T> return CONVERTED_TYPE(*this).value(); } - static storage_t convertToBase(storage_t derived_value) { return (storage_t)derived_value; @@ -150,99 +159,77 @@ protected: storage_t mBaseValue; }; -// -// operator + -// template<typename STORAGE_TYPE, typename BASE_UNIT, typename DERIVED_UNIT> -DERIVED_UNIT operator + (typename LLUnitType<STORAGE_TYPE, BASE_UNIT, DERIVED_UNIT>::storage_t first, LLUnitType<STORAGE_TYPE, BASE_UNIT, DERIVED_UNIT> second) +struct LLUnitTypeWrapper +: public LLUnitType<STORAGE_TYPE, BASE_UNIT, DERIVED_UNIT> { - return DERIVED_UNIT(first + second.value()); -} + typedef LLUnitType<STORAGE_TYPE, BASE_UNIT, DERIVED_UNIT> unit_t; + LLUnitTypeWrapper(const unit_t& other) + : unit_t(other) + {} +}; -template<typename STORAGE_TYPE, typename BASE_UNIT, typename DERIVED_UNIT> -DERIVED_UNIT operator + (LLUnitType<STORAGE_TYPE, BASE_UNIT, DERIVED_UNIT> first, typename LLUnitType<STORAGE_TYPE, BASE_UNIT, DERIVED_UNIT>::storage_t second) -{ - return DERIVED_UNIT(first.value() + second); -} -template<typename STORAGE_TYPE, typename BASE_UNIT, typename DERIVED_UNIT, typename OTHER_DERIVED_UNIT> -DERIVED_UNIT operator + (LLUnitType<STORAGE_TYPE, BASE_UNIT, DERIVED_UNIT> first, LLUnitType<STORAGE_TYPE, BASE_UNIT, OTHER_DERIVED_UNIT> second) +// +// operator + +// +template<typename STORAGE_TYPE, typename BASE_UNIT, typename DERIVED_UNIT, typename STORAGE_TYPE2, typename BASE_UNIT2, typename DERIVED_UNIT2> +DERIVED_UNIT operator + (typename LLUnitType<STORAGE_TYPE, BASE_UNIT, DERIVED_UNIT>::storage_t first, LLUnitType<STORAGE_TYPE2, BASE_UNIT2, DERIVED_UNIT2> second) { - return DERIVED_UNIT(first.value() + second.value()); + return DERIVED_UNIT(first + LLUnitType<STORAGE_TYPE, BASE_UNIT, DERIVED_UNIT>(second).value()); } + // // operator - // -template<typename STORAGE_TYPE, typename BASE_UNIT, typename DERIVED_UNIT> +template<typename STORAGE_TYPE, typename BASE_UNIT, typename DERIVED_UNIT, typename STORAGE_TYPE2, typename BASE_UNIT2, typename DERIVED_UNIT2> DERIVED_UNIT operator - (typename LLUnitType<STORAGE_TYPE, BASE_UNIT, DERIVED_UNIT>::storage_t first, LLUnitType<STORAGE_TYPE, BASE_UNIT, DERIVED_UNIT> second) { - return DERIVED_UNIT(first - second.value()); -} - -template<typename STORAGE_TYPE, typename BASE_UNIT, typename DERIVED_UNIT> -DERIVED_UNIT operator - (LLUnitType<STORAGE_TYPE, BASE_UNIT, DERIVED_UNIT> first, typename LLUnitType<STORAGE_TYPE, BASE_UNIT, DERIVED_UNIT>::storage_t second) -{ - return DERIVED_UNIT(first.value() - second); -} - -template<typename STORAGE_TYPE, typename BASE_UNIT, typename DERIVED_UNIT, typename OTHER_DERIVED_UNIT> -DERIVED_UNIT operator - (LLUnitType<STORAGE_TYPE, BASE_UNIT, DERIVED_UNIT> first, LLUnitType<STORAGE_TYPE, BASE_UNIT, OTHER_DERIVED_UNIT> second) -{ - return DERIVED_UNIT(first.value() - second.value()); + return DERIVED_UNIT(first - LLUnitType<STORAGE_TYPE, BASE_UNIT, DERIVED_UNIT>(second).value()); } // // operator * // template<typename STORAGE_TYPE, typename BASE_UNIT, typename DERIVED_UNIT> -DERIVED_UNIT operator * (typename LLUnitType<STORAGE_TYPE, BASE_UNIT, DERIVED_UNIT>::storage_t first, LLUnitType<STORAGE_TYPE, BASE_UNIT, DERIVED_UNIT> second) +DERIVED_UNIT operator * (STORAGE_TYPE first, LLUnitType<STORAGE_TYPE, BASE_UNIT, DERIVED_UNIT> second) { return DERIVED_UNIT(first * second.value()); } template<typename STORAGE_TYPE, typename BASE_UNIT, typename DERIVED_UNIT> -DERIVED_UNIT operator * (LLUnitType<STORAGE_TYPE, BASE_UNIT, DERIVED_UNIT> first, typename LLUnitType<STORAGE_TYPE, BASE_UNIT, DERIVED_UNIT>::storage_t second) +DERIVED_UNIT operator * (LLUnitType<STORAGE_TYPE, BASE_UNIT, DERIVED_UNIT> first, STORAGE_TYPE second) { return DERIVED_UNIT(first.value() * second); } + // // operator / // template<typename STORAGE_TYPE, typename BASE_UNIT, typename DERIVED_UNIT> -DERIVED_UNIT operator / (typename LLUnitType<STORAGE_TYPE, BASE_UNIT, DERIVED_UNIT>::storage_t first, LLUnitType<STORAGE_TYPE, BASE_UNIT, DERIVED_UNIT> second) +DERIVED_UNIT operator / (STORAGE_TYPE first, LLUnitTypeWrapper<STORAGE_TYPE, BASE_UNIT, DERIVED_UNIT> second) { - return DERIVED_UNIT(first * second.value()); + return DERIVED_UNIT(first / second.value()); } template<typename STORAGE_TYPE, typename BASE_UNIT, typename DERIVED_UNIT> -DERIVED_UNIT operator / (LLUnitType<STORAGE_TYPE, BASE_UNIT, DERIVED_UNIT> first, typename LLUnitType<STORAGE_TYPE, BASE_UNIT, DERIVED_UNIT>::storage_t second) +DERIVED_UNIT operator / (LLUnitTypeWrapper<STORAGE_TYPE, BASE_UNIT, DERIVED_UNIT> first, STORAGE_TYPE second) { - return DERIVED_UNIT(first.value() * second); + return DERIVED_UNIT(first.value() / second); } // // operator < // -template<typename STORAGE_TYPE, typename BASE_UNIT, typename DERIVED_UNIT> +template<typename STORAGE_TYPE, typename BASE_UNIT, typename DERIVED_UNIT, typename STORAGE_TYPE2, typename BASE_UNIT2, typename DERIVED_UNIT2> + bool operator < (typename LLUnitType<STORAGE_TYPE, BASE_UNIT, DERIVED_UNIT>::storage_t first, LLUnitType<STORAGE_TYPE, BASE_UNIT, DERIVED_UNIT> second) { return first < second.value(); } -template<typename STORAGE_TYPE, typename BASE_UNIT, typename DERIVED_UNIT> -bool operator < (LLUnitType<STORAGE_TYPE, BASE_UNIT, DERIVED_UNIT> first, typename LLUnitType<STORAGE_TYPE, BASE_UNIT, DERIVED_UNIT>::storage_t second) -{ - return first.value() < second; -} - -template<typename STORAGE_TYPE, typename BASE_UNIT, typename DERIVED_UNIT, typename OTHER_DERIVED_UNIT> -bool operator < (LLUnitType<STORAGE_TYPE, BASE_UNIT, DERIVED_UNIT> first, LLUnitType<STORAGE_TYPE, BASE_UNIT, OTHER_DERIVED_UNIT> second) -{ - return first.value() < second.value(); -} - // // operator <= // @@ -252,17 +239,6 @@ bool operator <= (typename LLUnitType<STORAGE_TYPE, BASE_UNIT, DERIVED_UNIT>::st return first <= second.value(); } -template<typename STORAGE_TYPE, typename BASE_UNIT, typename DERIVED_UNIT> -bool operator <= (LLUnitType<STORAGE_TYPE, BASE_UNIT, DERIVED_UNIT> first, typename LLUnitType<STORAGE_TYPE, BASE_UNIT, DERIVED_UNIT>::storage_t second) -{ - return first.value() <= second; -} - -template<typename STORAGE_TYPE, typename BASE_UNIT, typename DERIVED_UNIT, typename OTHER_DERIVED_UNIT> -bool operator <= (LLUnitType<STORAGE_TYPE, BASE_UNIT, DERIVED_UNIT> first, LLUnitType<STORAGE_TYPE, BASE_UNIT, OTHER_DERIVED_UNIT> second) -{ - return first.value() <= second.value(); -} // // operator > @@ -273,17 +249,6 @@ bool operator > (typename LLUnitType<STORAGE_TYPE, BASE_UNIT, DERIVED_UNIT>::sto return first > second.value(); } -template<typename STORAGE_TYPE, typename BASE_UNIT, typename DERIVED_UNIT> -bool operator > (LLUnitType<STORAGE_TYPE, BASE_UNIT, DERIVED_UNIT> first, typename LLUnitType<STORAGE_TYPE, BASE_UNIT, DERIVED_UNIT>::storage_t second) -{ - return first.value() > second; -} - -template<typename STORAGE_TYPE, typename BASE_UNIT, typename DERIVED_UNIT, typename OTHER_DERIVED_UNIT> -bool operator > (LLUnitType<STORAGE_TYPE, BASE_UNIT, DERIVED_UNIT> first, LLUnitType<STORAGE_TYPE, BASE_UNIT, OTHER_DERIVED_UNIT> second) -{ - return first.value() > second.value(); -} // // operator >= // @@ -293,18 +258,6 @@ bool operator >= (typename LLUnitType<STORAGE_TYPE, BASE_UNIT, DERIVED_UNIT>::st return first >= second.value(); } -template<typename STORAGE_TYPE, typename BASE_UNIT, typename DERIVED_UNIT> -bool operator >= (LLUnitType<STORAGE_TYPE, BASE_UNIT, DERIVED_UNIT> first, typename LLUnitType<STORAGE_TYPE, BASE_UNIT, DERIVED_UNIT>::storage_t second) -{ - return first.value() >= second; -} - -template<typename STORAGE_TYPE, typename BASE_UNIT, typename DERIVED_UNIT, typename OTHER_DERIVED_UNIT> -bool operator >= (LLUnitType<STORAGE_TYPE, BASE_UNIT, DERIVED_UNIT> first, LLUnitType<STORAGE_TYPE, BASE_UNIT, OTHER_DERIVED_UNIT> second) -{ - return first.value() >= second.value(); -} - // // operator == // @@ -314,18 +267,6 @@ bool operator == (typename LLUnitType<STORAGE_TYPE, BASE_UNIT, DERIVED_UNIT>::st return first == second.value(); } -template<typename STORAGE_TYPE, typename BASE_UNIT, typename DERIVED_UNIT> -bool operator == (LLUnitType<STORAGE_TYPE, BASE_UNIT, DERIVED_UNIT> first, typename LLUnitType<STORAGE_TYPE, BASE_UNIT, DERIVED_UNIT>::storage_t second) -{ - return first.value() == second; -} - -template<typename STORAGE_TYPE, typename BASE_UNIT, typename DERIVED_UNIT, typename OTHER_DERIVED_UNIT> -bool operator == (LLUnitType<STORAGE_TYPE, BASE_UNIT, DERIVED_UNIT> first, LLUnitType<STORAGE_TYPE, BASE_UNIT, OTHER_DERIVED_UNIT> second) -{ - return first.value() == second.value(); -} - // // operator != // @@ -335,18 +276,6 @@ bool operator != (typename LLUnitType<STORAGE_TYPE, BASE_UNIT, DERIVED_UNIT>::st return first != second.value(); } -template<typename STORAGE_TYPE, typename BASE_UNIT, typename DERIVED_UNIT> -bool operator != (LLUnitType<STORAGE_TYPE, BASE_UNIT, DERIVED_UNIT> first, typename LLUnitType<STORAGE_TYPE, BASE_UNIT, DERIVED_UNIT>::storage_t second) -{ - return first.value() != second; -} - -template<typename STORAGE_TYPE, typename BASE_UNIT, typename DERIVED_UNIT, typename OTHER_DERIVED_UNIT> -bool operator != (LLUnitType<STORAGE_TYPE, BASE_UNIT, DERIVED_UNIT> first, LLUnitType<STORAGE_TYPE, BASE_UNIT, OTHER_DERIVED_UNIT> second) -{ - return first.value() != second.value(); -} - #define LL_DECLARE_BASE_UNIT(unit_name) \ template<typename STORAGE> \ struct unit_name : public LLUnitType<STORAGE, unit_name<STORAGE>, unit_name<STORAGE> > \ |