SH-3406 WIP convert fast timers to lltrace system

started moving fast timer historical stats over to LLTrace periodic
recording
master
Richard Linden 2012-12-02 23:00:36 -08:00
parent 4f9a5d0554
commit 13e4edf1cd
4 changed files with 31 additions and 14 deletions

View File

@ -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

View File

@ -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<LLUnits::Seconds, F64> Recording::getSum(const TraceType<TimerAccumulator>& stat) const
{
return (F64)(*mStackTimers)[stat.getIndex()].mSelfTimeCounter / (F64)LLTrace::BlockTimer::countsPerSecond();
}
LLUnit<LLUnits::Seconds, F64> Recording::getPerSec(const TraceType<TimerAccumulator>& stat) const
{
return (F64)(*mStackTimers)[stat.getIndex()].mSelfTimeCounter / ((F64)LLTrace::BlockTimer::countsPerSecond() * mElapsedSeconds);
}
F64 Recording::getSum( const TraceType<CountAccumulator<F64> >& stat ) const
{
return (*mCountsFloat)[stat.getIndex()].getSum();

View File

@ -118,6 +118,10 @@ namespace LLTrace
void update();
// Timer accessors
LLUnit<LLUnits::Seconds, F64> getSum(const TraceType<TimerAccumulator>& stat) const;
LLUnit<LLUnits::Seconds, F64> getPerSec(const TraceType<TimerAccumulator>& stat) const;
// Count accessors
F64 getSum(const TraceType<CountAccumulator<F64> >& stat) const;
S64 getSum(const TraceType<CountAccumulator<S64> >& stat) const;
@ -273,18 +277,18 @@ namespace LLTrace
Recording& getTotalRecording();
template <typename T>
typename T getPeriodMin(const TraceType<CountAccumulator<T> >& stat) const
typename T::value_t getPeriodMin(const TraceType<T>& stat) const
{
T min_val = (std::numeric_limits<T>::max)();
typename T::value_t min_val = (std::numeric_limits<typename T::value_t>::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 <typename T>
F64 getPeriodMinPerSec(const TraceType<CountAccumulator<T> >& stat) const
F64 getPeriodMinPerSec(const TraceType<T>& stat) const
{
F64 min_val = (std::numeric_limits<F64>::max)();
for (S32 i = 0; i < mNumPeriods; i++)
@ -295,9 +299,9 @@ namespace LLTrace
}
template <typename T>
T getPeriodMax(const TraceType<CountAccumulator<T> >& stat) const
typename T::value_t getPeriodMax(const TraceType<T>& stat) const
{
T max_val = (std::numeric_limits<T>::min)();
typename T::value_t max_val = (std::numeric_limits<typename T::value_t>::min)();
for (S32 i = 0; i < mNumPeriods; i++)
{
max_val = llmax(max_val, mRecordingPeriods[i].getSum(stat));
@ -306,7 +310,7 @@ namespace LLTrace
}
template <typename T>
F64 getPeriodMaxPerSec(const TraceType<CountAccumulator<T> >& stat) const
F64 getPeriodMaxPerSec(const TraceType<T>& stat) const
{
F64 max_val = (std::numeric_limits<F64>::min)();
for (S32 i = 0; i < mNumPeriods; i++)
@ -317,7 +321,7 @@ namespace LLTrace
}
template <typename T>
F64 getPeriodMean(const TraceType<CountAccumulator<T> >& stat) const
F64 getPeriodMean(const TraceType<T>& stat) const
{
F64 mean = 0.0;
F64 count = 0;
@ -334,7 +338,7 @@ namespace LLTrace
}
template <typename T>
F64 getPeriodMeanPerSec(const TraceType<CountAccumulator<T> >& stat) const
F64 getPeriodMeanPerSec(const TraceType<T>& stat) const
{
F64 mean = 0.0;
F64 count = 0;

View File

@ -294,15 +294,17 @@ static std::string get_tooltip(LLTrace::BlockTimer& timer, S32 history_index = -
{
F64 ms_multiplier = 1000.0 / (F64)LLTrace::BlockTimer::countsPerSecond();
LLTrace::PeriodicRecording& frame_stats = LLTrace::get_frame_recording();
std::string tooltip;
if (history_index < 0)
{
// by default, show average number of call
tooltip = llformat("%s (%d ms, %d calls)", timer.getName().c_str(), (S32)(timer.getCountAverage() * ms_multiplier), (S32)timer.getCallAverage());
tooltip = llformat("%s (%d ms, %d calls)", timer.getName().c_str(), (S32)(frame_stats.getPeriodMean(timer) * ms_multiplier), (S32)timer.getCallAverage());
}
else
{
tooltip = llformat("%s (%d ms, %d calls)", timer.getName().c_str(), (S32)(timer.getHistoricalCount(history_index) * ms_multiplier), (S32)timer.getHistoricalCalls(history_index));
tooltip = llformat("%s (%d ms, %d calls)", timer.getName().c_str(), (S32)(frame_stats.getPrevRecordingPeriod(history_index).getSum(timer) * ms_multiplier), (S32)timer.getHistoricalCalls(history_index));
}
return tooltip;
}