From fa91ea69cca32e0dabcfabe18070f57cc4a4cfd0 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Fri, 7 Sep 2012 19:12:41 -0700 Subject: SH-3275 WIP Run viewer metrics for object update messages added buffer merging and copying --- indra/llcommon/lltrace.h | 38 +++++++++++++++++++++++++++++++++----- 1 file changed, 33 insertions(+), 5 deletions(-) (limited to 'indra') diff --git a/indra/llcommon/lltrace.h b/indra/llcommon/lltrace.h index c5bde0330a..6272492945 100644 --- a/indra/llcommon/lltrace.h +++ b/indra/llcommon/lltrace.h @@ -31,7 +31,6 @@ #include "llpreprocessor.h" #include -#include namespace LLTrace { @@ -42,6 +41,35 @@ namespace LLTrace } + template + struct AccumulatorStorage + { + std::vector mStorage; + + ACCUMULATOR& operator[](size_t index) { return mStorage[index]; } + + void mergeFrom(const AccumulatorStorage& other) + { + llassert(mStorage.size() == other.mStorage.size()); + + for (size_t i = 0; i < mStorage.size(); i++) + { + mStorage[i].mergeFrom(other.mStorage[i]); + } + } + + void copyFrom(const AccumulatorStorage& other) + { + mStorage = other.mStorage; + } + + void resize(size_t size) + { + //TODO: get this grow more rapidly (as if with push back) + mStorage.reserve(size); + } + }; + template class Trace { @@ -50,7 +78,7 @@ namespace LLTrace : mName(name) { mStorageIndex = sNextIndex++; - sStorage.reserve(sNextIndex); + sStorage.resize(sNextIndex); } LL_FORCE_INLINE ACCUMULATOR& getAccumulator() @@ -69,8 +97,8 @@ namespace LLTrace ptrdiff_t mStorageIndex; // this needs to be thread local - static std::vector sStorage; - static size_t sNextIndex; + static AccumulatorStorage sStorage; + static size_t sNextIndex; }; template std::vector Trace::sStorage; @@ -81,7 +109,7 @@ namespace LLTrace { public: Accumulator() - : mSum(), + : mSum(), mMin(), mMax(), mNumSamples(0) -- cgit v1.2.3