From ca2207bd35c33b13b122f875a5a7d218f94ca3fc Mon Sep 17 00:00:00 2001
From: Richard Linden <none@none>
Date: Sat, 1 Dec 2012 00:17:04 -0800
Subject: [PATCH] SH-3406 WIP convert fast timers to lltrace system fixed scale
 of reported times moved reset calls to happen at same time so we don't show
 partial results

---
 indra/llcommon/llfasttimer.cpp | 6 ++----
 indra/llcommon/lltrace.h       | 3 ++-
 indra/llcommon/llunit.h        | 2 +-
 indra/newview/llappviewer.cpp  | 4 ++--
 4 files changed, 7 insertions(+), 8 deletions(-)

diff --git a/indra/llcommon/llfasttimer.cpp b/indra/llcommon/llfasttimer.cpp
index 1b3498cce3d..19676cc0c6e 100644
--- a/indra/llcommon/llfasttimer.cpp
+++ b/indra/llcommon/llfasttimer.cpp
@@ -144,7 +144,6 @@ U64 BlockTimer::countsPerSecond() // counts per second for the *32-bit* timer
 	//getCPUFrequency returns MHz and sCPUClockFrequency wants to be in Hz
 	static LLUnit<LLUnits::Hertz, U64> sCPUClockFrequency = LLProcessorInfo().getCPUFrequency();
 
-	// we drop the low-order byte in our timers, so report a lower frequency
 #else
 	// If we're not using RDTSC, each fast timer tick is just a performance counter tick.
 	// Not redefining the clock frequency itself (in llprocessor.cpp/calculate_cpu_frequency())
@@ -157,7 +156,7 @@ U64 BlockTimer::countsPerSecond() // counts per second for the *32-bit* timer
 		firstcall = false;
 	}
 #endif
-	return sCPUClockFrequency >> 8;
+	return sCPUClockFrequency;
 }
 #endif
 
@@ -390,8 +389,7 @@ void BlockTimer::resetFrame()
 		static S32 call_count = 0;
 		if (call_count % 100 == 0)
 		{
-			LL_DEBUGS("FastTimers") << "countsPerSecond (32 bit): " << countsPerSecond() << LL_ENDL;
-			LL_DEBUGS("FastTimers") << "get_clock_count (64 bit): " << get_clock_count() << LL_ENDL;
+			LL_DEBUGS("FastTimers") << "countsPerSecond: " << countsPerSecond() << LL_ENDL;
 			LL_DEBUGS("FastTimers") << "LLProcessorInfo().getCPUFrequency() " << LLProcessorInfo().getCPUFrequency() << LL_ENDL;
 			LL_DEBUGS("FastTimers") << "getCPUClockCount32() " << getCPUClockCount32() << LL_ENDL;
 			LL_DEBUGS("FastTimers") << "getCPUClockCount64() " << getCPUClockCount64() << LL_ENDL;
diff --git a/indra/llcommon/lltrace.h b/indra/llcommon/lltrace.h
index ad9f170aaee..3e43a85e808 100644
--- a/indra/llcommon/lltrace.h
+++ b/indra/llcommon/lltrace.h
@@ -223,7 +223,8 @@ namespace LLTrace
 
 		LL_FORCE_INLINE ACCUMULATOR& getPrimaryAccumulator() const
 		{
-			return AccumulatorBuffer<ACCUMULATOR>::getPrimaryStorage()[mAccumulatorIndex];
+			ACCUMULATOR* accumulator_storage = AccumulatorBuffer<ACCUMULATOR>::getPrimaryStorage();
+			return accumulator_storage[mAccumulatorIndex];
 		}
 
 		size_t getIndex() const { return mAccumulatorIndex; }
diff --git a/indra/llcommon/llunit.h b/indra/llcommon/llunit.h
index 53570779fc9..fc1347b59fa 100644
--- a/indra/llcommon/llunit.h
+++ b/indra/llcommon/llunit.h
@@ -71,7 +71,7 @@ template<typename UNIT_TYPE, typename STORAGE_TYPE>
 struct LLUnit
 {
 	typedef LLUnit<UNIT_TYPE, STORAGE_TYPE> self_t;
-	typedef typename STORAGE_TYPE storage_t;
+	typedef STORAGE_TYPE storage_t;
 
 	LLUnit(storage_t value = storage_t())
 	:	mValue(value)
diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp
index fb95c9ec5b2..b9bdb7cd083 100644
--- a/indra/newview/llappviewer.cpp
+++ b/indra/newview/llappviewer.cpp
@@ -1235,6 +1235,8 @@ bool LLAppViewer::mainLoop()
 	{
 		LLFastTimer _(FTM_FRAME);
 		LLTrace::BlockTimer::nextFrame(); 
+		LLTrace::get_frame_recording().nextPeriod();
+
 		LLTrace::getMasterThreadRecorder().pullFromSlaveThreads();
 
 		//clear call stack records
@@ -1352,8 +1354,6 @@ bool LLAppViewer::mainLoop()
 					LLFloaterSnapshot::update(); // take snapshots
 					gGLActive = FALSE;
 				}
-
-				LLTrace::get_frame_recording().nextPeriod();
 			}
 
 			pingMainloopTimeout("Main:Sleep");
-- 
GitLab