diff options
author | Christian Goetze (CG) <cg@lindenlab.com> | 2010-08-02 22:05:56 -0700 |
---|---|---|
committer | Christian Goetze (CG) <cg@lindenlab.com> | 2010-08-02 22:05:56 -0700 |
commit | d10b9a7f37bec670342136eeea2c8c2604fdfeef (patch) | |
tree | a6380a0442d103faed76f1a1c7e5eb03d0f3f6ae /indra/newview/llviewerstats.h | |
parent | a39b31abf87d93fb41212e952cc3ad1d8c91b5ef (diff) | |
parent | b3b8ef25e192f5713c9d5ca47289499b17ff07d1 (diff) |
Pulled from "dessie/viewer-release"
Diffstat (limited to 'indra/newview/llviewerstats.h')
-rw-r--r-- | indra/newview/llviewerstats.h | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/indra/newview/llviewerstats.h b/indra/newview/llviewerstats.h index 13d73000d2..694eeaf097 100644 --- a/indra/newview/llviewerstats.h +++ b/indra/newview/llviewerstats.h @@ -197,6 +197,61 @@ public: void addToMessage(LLSD &body) const; + struct StatsAccumulator + { + S32 mCount; + F32 mSum; + F32 mSumOfSquares; + U32 mCountOfNextUpdatesToIgnore; + + inline void push( F32 val ) + { + if ( mCountOfNextUpdatesToIgnore > 0 ) + { + mCountOfNextUpdatesToIgnore--; + return; + } + + mCount++; + mSum += val; + mSumOfSquares += val * val; + } + + inline F32 getMean() const + { + return (mCount == 0) ? 0.f : ((F32)mSum)/mCount; + } + + inline F32 getStdDev() const + { + const F32 mean = getMean(); + return (mCount == 0) ? 0.f : sqrt( mSumOfSquares/mCount - (mean * mean) ); + } + + inline U32 getCount() const + { + return mCount; + } + + inline void reset() + { + mCount = 0; + mSum = mSumOfSquares = 0.f; + mCountOfNextUpdatesToIgnore = 0; + } + + inline LLSD getData() const + { + LLSD data; + data["mean"] = getMean(); + data["std_dev"] = getStdDev(); + data["count"] = (S32)mCount; + return data; + } + }; + + StatsAccumulator mAgentPositionSnaps; + private: F64 mStats[ST_COUNT]; |