diff options
author | Vadim Savchuk <vsavchuk@productengine.com> | 2010-07-14 14:43:53 +0300 |
---|---|---|
committer | Vadim Savchuk <vsavchuk@productengine.com> | 2010-07-14 14:43:53 +0300 |
commit | 1f2dcfd866390be1a3a1b1f9406bca861d32c4b4 (patch) | |
tree | 2406da619100b2aef6a70e8b346245999dfc8266 /indra/newview/llviewerstats.h | |
parent | 84a6b197600d3f6c2dc35c8372ace004b290b2c8 (diff) | |
parent | 37fc4e42dd173d92abb31be83dbd04fa3b7b70fa (diff) |
Merge from default branch
--HG--
branch : product-engine
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..5202b8a36f 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.0; + 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]; |