From 13e4edf1cd664864afa585bc83bbe99d4f743326 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Sun, 2 Dec 2012 23:00:36 -0800 Subject: SH-3406 WIP convert fast timers to lltrace system started moving fast timer historical stats over to LLTrace periodic recording --- indra/llcommon/llfasttimer.cpp | 6 +++--- indra/llcommon/lltracerecording.cpp | 11 +++++++++++ indra/llcommon/lltracerecording.h | 22 +++++++++++++--------- 3 files changed, 27 insertions(+), 12 deletions(-) (limited to 'indra/llcommon') diff --git a/indra/llcommon/llfasttimer.cpp b/indra/llcommon/llfasttimer.cpp index 19676cc0c6..e33cb76eff 100644 --- a/indra/llcommon/llfasttimer.cpp +++ b/indra/llcommon/llfasttimer.cpp @@ -133,12 +133,12 @@ void BlockTimer::setLogLock(LLMutex* lock) //static #if (LL_DARWIN || LL_LINUX || LL_SOLARIS) && !(defined(__i386__) || defined(__amd64__)) -U64 BlockTimer::countsPerSecond() // counts per second for the *32-bit* timer +U64 BlockTimer::countsPerSecond() // counts per second for the *64-bit* timer { - return sClockResolution >> 8; + return sClockResolution; } #else // windows or x86-mac or x86-linux or x86-solaris -U64 BlockTimer::countsPerSecond() // counts per second for the *32-bit* timer +U64 BlockTimer::countsPerSecond() // counts per second for the *64-bit* timer { #if LL_FASTTIMER_USE_RDTSC || !LL_WINDOWS //getCPUFrequency returns MHz and sCPUClockFrequency wants to be in Hz diff --git a/indra/llcommon/lltracerecording.cpp b/indra/llcommon/lltracerecording.cpp index e31e36cb27..ff3ae1e553 100644 --- a/indra/llcommon/lltracerecording.cpp +++ b/indra/llcommon/lltracerecording.cpp @@ -26,6 +26,7 @@ #include "linden_common.h" #include "lltrace.h" +#include "llfasttimer.h" #include "lltracerecording.h" #include "lltracethreadrecorder.h" #include "llthread.h" @@ -142,6 +143,16 @@ void Recording::appendRecording( const Recording& other ) mElapsedSeconds += other.mElapsedSeconds; } +LLUnit Recording::getSum(const TraceType& stat) const +{ + return (F64)(*mStackTimers)[stat.getIndex()].mSelfTimeCounter / (F64)LLTrace::BlockTimer::countsPerSecond(); +} + +LLUnit Recording::getPerSec(const TraceType& stat) const +{ + return (F64)(*mStackTimers)[stat.getIndex()].mSelfTimeCounter / ((F64)LLTrace::BlockTimer::countsPerSecond() * mElapsedSeconds); +} + F64 Recording::getSum( const TraceType >& stat ) const { return (*mCountsFloat)[stat.getIndex()].getSum(); diff --git a/indra/llcommon/lltracerecording.h b/indra/llcommon/lltracerecording.h index e5a21a2d38..0adea2663b 100644 --- a/indra/llcommon/lltracerecording.h +++ b/indra/llcommon/lltracerecording.h @@ -118,6 +118,10 @@ namespace LLTrace void update(); + // Timer accessors + LLUnit getSum(const TraceType& stat) const; + LLUnit getPerSec(const TraceType& stat) const; + // Count accessors F64 getSum(const TraceType >& stat) const; S64 getSum(const TraceType >& stat) const; @@ -273,18 +277,18 @@ namespace LLTrace Recording& getTotalRecording(); template - typename T getPeriodMin(const TraceType >& stat) const + typename T::value_t getPeriodMin(const TraceType& stat) const { - T min_val = (std::numeric_limits::max)(); + typename T::value_t min_val = (std::numeric_limits::max)(); for (S32 i = 0; i < mNumPeriods; i++) { min_val = llmin(min_val, mRecordingPeriods[i].getSum(stat)); } - return (T)min_val; + return min_val; } template - F64 getPeriodMinPerSec(const TraceType >& stat) const + F64 getPeriodMinPerSec(const TraceType& stat) const { F64 min_val = (std::numeric_limits::max)(); for (S32 i = 0; i < mNumPeriods; i++) @@ -295,9 +299,9 @@ namespace LLTrace } template - T getPeriodMax(const TraceType >& stat) const + typename T::value_t getPeriodMax(const TraceType& stat) const { - T max_val = (std::numeric_limits::min)(); + typename T::value_t max_val = (std::numeric_limits::min)(); for (S32 i = 0; i < mNumPeriods; i++) { max_val = llmax(max_val, mRecordingPeriods[i].getSum(stat)); @@ -306,7 +310,7 @@ namespace LLTrace } template - F64 getPeriodMaxPerSec(const TraceType >& stat) const + F64 getPeriodMaxPerSec(const TraceType& stat) const { F64 max_val = (std::numeric_limits::min)(); for (S32 i = 0; i < mNumPeriods; i++) @@ -317,7 +321,7 @@ namespace LLTrace } template - F64 getPeriodMean(const TraceType >& stat) const + F64 getPeriodMean(const TraceType& stat) const { F64 mean = 0.0; F64 count = 0; @@ -334,7 +338,7 @@ namespace LLTrace } template - F64 getPeriodMeanPerSec(const TraceType >& stat) const + F64 getPeriodMeanPerSec(const TraceType& stat) const { F64 mean = 0.0; F64 count = 0; -- cgit v1.2.3