diff options
author | Richard Linden <none@none> | 2012-11-16 23:02:53 -0800 |
---|---|---|
committer | Richard Linden <none@none> | 2012-11-16 23:02:53 -0800 |
commit | 6db6cb39f41e921e75970d1570a74cf35d353a35 (patch) | |
tree | 141e276bfb93ba8b3b7f3ff12d730f3f3cbf5f22 /indra/llcommon | |
parent | c136b432140f892a56d4996d5ed77e903ff0b32d (diff) |
SH-3406 WIP convert fast timers to lltrace system
got new fast timer code to compile and run
Diffstat (limited to 'indra/llcommon')
-rw-r--r-- | indra/llcommon/llfasttimer.cpp | 13 | ||||
-rw-r--r-- | indra/llcommon/lltrace.cpp | 12 | ||||
-rw-r--r-- | indra/llcommon/lltrace.h | 6 | ||||
-rw-r--r-- | indra/llcommon/lltracethreadrecorder.cpp | 4 |
4 files changed, 31 insertions, 4 deletions
diff --git a/indra/llcommon/llfasttimer.cpp b/indra/llcommon/llfasttimer.cpp index 4ecca12832..e1549b4bff 100644 --- a/indra/llcommon/llfasttimer.cpp +++ b/indra/llcommon/llfasttimer.cpp @@ -336,7 +336,10 @@ void BlockTimer::accumulateTimings() cur_data = &cur_timer->mLastTimerData; cur_data->mChildTime += cumulative_time_delta; - accumulator = cur_data->mTimerData->getPrimaryAccumulator(); + if (cur_data->mTimerData) + { + accumulator = cur_data->mTimerData->getPrimaryAccumulator(); + } cur_timer = cur_timer->mLastTimerData.mCurTimer; } @@ -572,6 +575,14 @@ void Time::writeLog(std::ostream& os) } +LLTrace::TimerAccumulator::TimerAccumulator() : mSelfTimeCounter(0), + mTotalTimeCounter(0), + mCalls(0), + mLastCaller(NULL), + mActiveCount(0), + mMoveUpTree(false) +{} + void LLTrace::TimerAccumulator::addSamples( const LLTrace::TimerAccumulator& other ) { mSelfTimeCounter += other.mSelfTimeCounter; diff --git a/indra/llcommon/lltrace.cpp b/indra/llcommon/lltrace.cpp index 9bf9ae6c8e..e11e39a1a2 100644 --- a/indra/llcommon/lltrace.cpp +++ b/indra/llcommon/lltrace.cpp @@ -30,6 +30,8 @@ #include "lltracethreadrecorder.h" #include "llfasttimer.h" +static bool sInitialized; + namespace LLTrace { @@ -38,15 +40,18 @@ static MasterThreadRecorder* gMasterThreadRecorder = NULL; void init() { gMasterThreadRecorder = new MasterThreadRecorder(); - BlockTimer::sCurTimerData = new CurTimerData(); + sInitialized = true; +} + +bool isInitialized() +{ + return sInitialized; } void cleanup() { delete gMasterThreadRecorder; gMasterThreadRecorder = NULL; - delete BlockTimer::sCurTimerData.get(); - BlockTimer::sCurTimerData = NULL; } MasterThreadRecorder& getMasterThreadRecorder() @@ -62,3 +67,4 @@ LLThreadLocalPointer<ThreadRecorder>& get_thread_recorder() } } + diff --git a/indra/llcommon/lltrace.h b/indra/llcommon/lltrace.h index 61fed6e7b8..61d14569cd 100644 --- a/indra/llcommon/lltrace.h +++ b/indra/llcommon/lltrace.h @@ -67,6 +67,7 @@ namespace LLTrace void init(); void cleanup(); + bool isInitialized(); LLThreadLocalPointer<class ThreadRecorder>& get_thread_recorder(); @@ -162,6 +163,10 @@ namespace LLTrace // NOTE: this is not thread-safe. We assume that slots are reserved in the main thread before any child threads are spawned size_t reserveSlot() { + if (LLTrace::isInitialized()) + { + llerrs << "Attempting to declare trace object after program initialization. Trace objects should be statically initialized." << llendl; + } size_t next_slot = mNextStorageSlot++; if (next_slot >= mStorageSize) { @@ -383,6 +388,7 @@ namespace LLTrace class TimerAccumulator { public: + TimerAccumulator(); void addSamples(const TimerAccumulator& other); void reset(const TimerAccumulator* other); diff --git a/indra/llcommon/lltracethreadrecorder.cpp b/indra/llcommon/lltracethreadrecorder.cpp index 0f111aab59..c2fefe2957 100644 --- a/indra/llcommon/lltracethreadrecorder.cpp +++ b/indra/llcommon/lltracethreadrecorder.cpp @@ -40,6 +40,8 @@ ThreadRecorder::ThreadRecorder() { get_thread_recorder() = this; mFullRecording.start(); + + BlockTimer::sCurTimerData = new CurTimerData(); } ThreadRecorder::ThreadRecorder( const ThreadRecorder& other ) @@ -52,6 +54,8 @@ ThreadRecorder::ThreadRecorder( const ThreadRecorder& other ) ThreadRecorder::~ThreadRecorder() { get_thread_recorder() = NULL; + delete BlockTimer::sCurTimerData.get(); + BlockTimer::sCurTimerData = NULL; } void ThreadRecorder::activate( Recording* recording ) |