diff options
author | Christian Goetze (CG) <cg@lindenlab.com> | 2010-08-02 16:59:20 -0700 |
---|---|---|
committer | Christian Goetze (CG) <cg@lindenlab.com> | 2010-08-02 16:59:20 -0700 |
commit | 6a1fefac22b62c45542208928918e9616e85977c (patch) | |
tree | c85c576b93754ec67ac5e93884b2fd26af192325 /indra/newview/llviewerstats.h | |
parent | f423a69864c40f760c1c7e64a2e544fd1dba77fb (diff) | |
parent | 15247f086989a43881d79c1ee5416bb00721eb68 (diff) |
Redo the same merge as in changeset "2026f824953f", but this time with feeeeling.
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]; |