From 93aca485ba08a82a6bd3a2fc31deca18af0d1478 Mon Sep 17 00:00:00 2001
From: Richard Linden <none@none>
Date: Tue, 27 Nov 2012 20:17:37 -0800
Subject: [PATCH] SH-3406 WIP convert fast timers to lltrace system fixed
 precision of fast timer counts

---
 indra/llcommon/llfasttimer.cpp | 10 +++++-----
 indra/newview/llappviewer.cpp  |  4 +---
 2 files changed, 6 insertions(+), 8 deletions(-)

diff --git a/indra/llcommon/llfasttimer.cpp b/indra/llcommon/llfasttimer.cpp
index e1549b4bff1..9701a41dc5c 100644
--- a/indra/llcommon/llfasttimer.cpp
+++ b/indra/llcommon/llfasttimer.cpp
@@ -317,7 +317,7 @@ void BlockTimer::buildHierarchy()
 //static
 void BlockTimer::accumulateTimings()
 {
-	U32 cur_time = getCPUClockCount32();
+	U64 cur_time = getCPUClockCount64();
 
 	// walk up stack of active timers and accumulate current time while leaving timing structures active
 	Time* cur_timer = sCurTimerData->mCurTimer;
@@ -389,7 +389,7 @@ void BlockTimer::resetFrame()
 		}
 		call_count++;
 
-		F64 iclock_freq = 1000.0 / countsPerSecond(); // good place to calculate clock frequency
+		F64 iclock_freq = 1000.0 / get_clock_count(); // good place to calculate clock frequency
 
 		F64 total_time = 0;
 		LLSD sd;
@@ -442,7 +442,7 @@ void BlockTimer::reset()
 
 	// walk up stack of active timers and reset start times to current time
 	// effectively zeroing out any accumulated time
-	U32 cur_time = getCPUClockCount32();
+	U64 cur_time = getCPUClockCount64();
 
 	// root defined by parent pointing to self
 	CurTimerData* cur_data = sCurTimerData.get();
@@ -510,7 +510,7 @@ std::vector<BlockTimer*>& BlockTimer::getChildren()
 //static
 void BlockTimer::nextFrame()
 {
-	BlockTimer::countsPerSecond(); // good place to calculate clock frequency
+	get_clock_count(); // good place to calculate clock frequency
 	U64 frame_time = BlockTimer::getCPUClockCount64();
 	if ((frame_time - sLastFrameTime) >> 8 > 0xffffffff)
 	{
@@ -534,7 +534,7 @@ void Time::dumpCurTimes()
 	// accumulate timings, etc.
 	BlockTimer::processTimes();
 	
-	F64 clock_freq = (F64)BlockTimer::countsPerSecond();
+	F64 clock_freq = (F64)get_clock_count();
 	F64 iclock_freq = 1000.0 / clock_freq; // clock_ticks -> milliseconds
 
 	// walk over timers in depth order and output timings
diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp
index 547eb2fefe7..1ecbc00257d 100644
--- a/indra/newview/llappviewer.cpp
+++ b/indra/newview/llappviewer.cpp
@@ -1341,6 +1341,7 @@ bool LLAppViewer::mainLoop()
 					gGLActive = FALSE;
 				}
 
+				LLTrace::get_frame_recording().nextPeriod();
 			}
 
 			pingMainloopTimeout("Main:Sleep");
@@ -4307,9 +4308,6 @@ void LLAppViewer::idle()
 		update_statistics();
 	}
 
-	LLTrace::get_frame_recording().nextPeriod();
-
-
 	////////////////////////////////////////
 	//
 	// Handle the regular UI idle callbacks as well as
-- 
GitLab