SH-3406 WIP convert fast timers to lltrace system

cleaning up build
moved most includes of windows.h to llwin32headers.h to disable min/max macros, etc
streamlined Time class and consolidated functionality in BlockTimer class
llfasttimer is no longer included via llstring.h, so had to add it manually in several places
master
Richard Linden 2012-11-14 23:52:27 -08:00
parent 67ec47e6da
commit 9d77e030d9
67 changed files with 390 additions and 319 deletions

View File

@ -30,6 +30,8 @@
#include "stdtypes.h" // from llcommon
#include <list>
#include "llstreamingaudio.h"
class LLAudioStreamManagerFMOD;

View File

@ -32,6 +32,7 @@
#include "llcharacter.h"
#include "llstring.h"
#include "llfasttimer.h"
#define SKEL_HEADER "Linden Skeleton 1.0"

View File

@ -31,6 +31,7 @@
// Header Files
//-----------------------------------------------------------------------------
#include <string>
#include <list>
#include "linked_lists.h"
#include "v3math.h"

View File

@ -28,8 +28,9 @@
// Header Files
//-----------------------------------------------------------------------------
#include "linden_common.h"
#include "llmotioncontroller.h"
#include "llfasttimer.h"
#include "llkeyframemotion.h"
#include "llmath.h"
#include "lltimer.h"

View File

@ -32,16 +32,6 @@
#if LL_LINUX || LL_SOLARIS
#include <sys/param.h> // Need PATH_MAX in APR headers...
#endif
#if LL_WINDOWS
// Limit Windows API to small and manageable set.
// If you get undefined symbols, find the appropriate
// Windows header file and include that in your .cpp file.
#define WIN32_LEAN_AND_MEAN
#include <winsock2.h>
#include <windows.h>
#undef min
#undef max
#endif
#include <boost/noncopyable.hpp>
@ -340,7 +330,7 @@ public:
LLThreadLocalPointer(const LLThreadLocalPointer<T>& other)
: LLThreadLocalPointerBase(other)
: LLThreadLocalPointerBase(other)
{
set(other.get());
}

View File

@ -39,6 +39,7 @@
#include "lltimer.h"
#include "llstring.h"
#include "llfasttimer.h"
static const F64 DATE_EPOCH = 0.0;

View File

@ -58,22 +58,22 @@ namespace LLTrace
//////////////////////////////////////////////////////////////////////////////
// statics
S32 Time::sCurFrameIndex = -1;
S32 Time::sLastFrameIndex = -1;
U64 Time::sLastFrameTime = Time::getCPUClockCount64();
bool Time::sPauseHistory = 0;
bool Time::sResetHistory = 0;
LLThreadLocalPointer<Time::CurTimerData> Time::sCurTimerData;
bool Time::sLog = FALSE;
std::string Time::sLogName = "";
bool Time::sMetricLog = FALSE;
S32 BlockTimer::sCurFrameIndex = -1;
S32 BlockTimer::sLastFrameIndex = -1;
U64 BlockTimer::sLastFrameTime = BlockTimer::getCPUClockCount64();
bool BlockTimer::sPauseHistory = 0;
bool BlockTimer::sResetHistory = 0;
LLThreadLocalPointer<CurTimerData> BlockTimer::sCurTimerData;
bool BlockTimer::sLog = false;
std::string BlockTimer::sLogName = "";
bool BlockTimer::sMetricLog = false;
static LLMutex* sLogLock = NULL;
static std::queue<LLSD> sLogQueue;
#if LL_LINUX || LL_SOLARIS
U64 Time::sClockResolution = 1000000000; // Nanosecond resolution
U64 BlockTimer::sClockResolution = 1000000000; // Nanosecond resolution
#else
U64 Time::sClockResolution = 1000000; // Microsecond resolution
U64 BlockTimer::sClockResolution = 1000000; // Microsecond resolution
#endif
// FIXME: move these declarations to the relevant modules
@ -114,15 +114,22 @@ BlockTimer& BlockTimer::getRootTimer()
return root_timer;
}
void BlockTimer::pushLog(LLSD log)
{
LLMutexLock lock(sLogLock);
sLogQueue.push(log);
}
//static
#if (LL_DARWIN || LL_LINUX || LL_SOLARIS) && !(defined(__i386__) || defined(__amd64__))
U64 Time::countsPerSecond() // counts per second for the *32-bit* timer
U64 BlockTimer::countsPerSecond() // counts per second for the *32-bit* timer
{
return sClockResolution >> 8;
}
#else // windows or x86-mac or x86-linux or x86-solaris
U64 Time::countsPerSecond() // counts per second for the *32-bit* timer
U64 BlockTimer::countsPerSecond() // counts per second for the *32-bit* timer
{
#if LL_FASTTIMER_USE_RDTSC || !LL_WINDOWS
//getCPUFrequency returns MHz and sCPUClockFrequency wants to be in Hz
@ -225,7 +232,7 @@ S32 BlockTimer::getDepth()
// static
void BlockTimer::processTimes()
{
if (Time::getCurFrameIndex() < 0) return;
if (getCurFrameIndex() < 0) return;
buildHierarchy();
accumulateTimings();
@ -243,7 +250,7 @@ struct SortTimerByName
//static
void BlockTimer::buildHierarchy()
{
if (Time::getCurFrameIndex() < 0 ) return;
if (getCurFrameIndex() < 0 ) return;
// set up initial tree
{
@ -254,11 +261,11 @@ void BlockTimer::buildHierarchy()
// bootstrap tree construction by attaching to last timer to be on stack
// when this timer was called
if (timer.mLastCaller && timer.mParent == &BlockTimer::getRootTimer())
if (timer.getPrimaryAccumulator().mLastCaller && timer.mParent == &BlockTimer::getRootTimer())
{
timer.setParent(timer.mLastCaller);
timer.setParent(timer.getPrimaryAccumulator().mLastCaller);
// no need to push up tree on first use, flag can be set spuriously
timer.mMoveUpTree = false;
timer.getPrimaryAccumulator().mMoveUpTree = false;
}
}
}
@ -274,14 +281,14 @@ void BlockTimer::buildHierarchy()
// skip root timer
if (timerp == &BlockTimer::getRootTimer()) continue;
if (timerp->mMoveUpTree)
if (timerp->getPrimaryAccumulator().mMoveUpTree)
{
// since ancestors have already been visited, reparenting won't affect tree traversal
// since ancestors have already been visited, re-parenting won't affect tree traversal
//step up tree, bringing our descendants with us
LL_DEBUGS("FastTimers") << "Moving " << timerp->getName() << " from child of " << timerp->getParent()->getName() <<
" to child of " << timerp->getParent()->getParent()->getName() << LL_ENDL;
timerp->setParent(timerp->getParent()->getParent());
timerp->mMoveUpTree = false;
timerp->getPrimaryAccumulator().mMoveUpTree = false;
// don't bubble up any ancestors until descendants are done bubbling up
it.skipAncestors();
@ -308,21 +315,23 @@ void BlockTimer::accumulateTimings()
U32 cur_time = getCPUClockCount32();
// walk up stack of active timers and accumulate current time while leaving timing structures active
Time* cur_timer = sCurTimerData.mCurTimer;
Time* cur_timer = sCurTimerData->mCurTimer;
// root defined by parent pointing to self
CurTimerData* cur_data = &sCurTimerData;
CurTimerData* cur_data = sCurTimerData.get();
TimerAccumulator& accumulator = sCurTimerData->mTimerData->getPrimaryAccumulator();
while(cur_timer && cur_timer->mLastTimerData.mCurTimer != cur_timer)
{
U32 cumulative_time_delta = cur_time - cur_timer->mStartTime;
U32 self_time_delta = cumulative_time_delta - cur_data->mChildTime;
cur_data->mChildTime = 0;
cur_data->mTimerData->mSelfTimeCounter += self_time_delta;
cur_data->mTimerData->mTotalTimeCounter += cumulative_time_delta;
accumulator.mSelfTimeCounter += self_time_delta;
accumulator.mTotalTimeCounter += cumulative_time_delta;
cur_timer->mStartTime = cur_time;
cur_data = &cur_timer->mLastTimerData;
cur_data->mChildTime += cumulative_time_delta;
accumulator = cur_data->mTimerData->getPrimaryAccumulator();
cur_timer = cur_timer->mLastTimerData.mCurTimer;
}
@ -333,13 +342,14 @@ void BlockTimer::accumulateTimings()
++it)
{
BlockTimer* timerp = (*it);
timerp->mTreeTimeCounter = timerp->mSelfTimeCounter;
TimerAccumulator& accumulator = timerp->getPrimaryAccumulator();
timerp->mTreeTimeCounter = accumulator.mSelfTimeCounter;
for (child_const_iter child_it = timerp->beginChildren(); child_it != timerp->endChildren(); ++child_it)
{
timerp->mTreeTimeCounter += (*child_it)->mTreeTimeCounter;
}
S32 cur_frame = sCurFrameIndex;
S32 cur_frame = getCurFrameIndex();
if (cur_frame >= 0)
{
// update timer history
@ -347,8 +357,8 @@ void BlockTimer::accumulateTimings()
timerp->mCountHistory[hidx] = timerp->mTreeTimeCounter;
timerp->mCountAverage = ((U64)timerp->mCountAverage * cur_frame + timerp->mTreeTimeCounter) / (cur_frame+1);
timerp->mCallHistory[hidx] = timerp->mCalls;
timerp->mCallAverage = ((U64)timerp->mCallAverage * cur_frame + timerp->mCalls) / (cur_frame+1);
timerp->mCallHistory[hidx] = accumulator.mCalls;
timerp->mCallAverage = ((U64)timerp->mCallAverage * cur_frame + accumulator.mCalls) / (cur_frame+1);
}
}
}
@ -377,15 +387,19 @@ void BlockTimer::resetFrame()
LLSD sd;
{
for (instance_iter it = beginInstances(), end_it = endInstances(); it != end_it; ++it)
for (LLInstanceTracker<BlockTimer>::instance_iter it = LLInstanceTracker<BlockTimer>::beginInstances(),
end_it = LLInstanceTracker<BlockTimer>::endInstances();
it != end_it;
++it)
{
BlockTimer& timer = *it;
sd[timer.getName()]["Time"] = (LLSD::Real) (timer.mSelfTimeCounter*iclock_freq);
sd[timer.getName()]["Calls"] = (LLSD::Integer) timer.mCalls;
TimerAccumulator& accumulator = timer.getPrimaryAccumulator();
sd[timer.getName()]["Time"] = (LLSD::Real) (accumulator.mSelfTimeCounter*iclock_freq);
sd[timer.getName()]["Calls"] = (LLSD::Integer) accumulator.mCalls;
// computing total time here because getting the root timer's getCountHistory
// doesn't work correctly on the first frame
total_time = total_time + timer.mSelfTimeCounter * iclock_freq;
total_time = total_time + accumulator.mSelfTimeCounter * iclock_freq;
}
}
@ -399,13 +413,17 @@ void BlockTimer::resetFrame()
}
// reset for next frame
for (instance_iter it = beginInstances(), end_it = endInstances(); it != end_it; ++it)
for (LLInstanceTracker<BlockTimer>::instance_iter it = LLInstanceTracker<BlockTimer>::beginInstances(),
end_it = LLInstanceTracker<BlockTimer>::endInstances();
it != end_it;
++it)
{
BlockTimer& timer = *it;
timer.mSelfTimeCounter = 0;
timer.mCalls = 0;
timer.mLastCaller = NULL;
timer.mMoveUpTree = false;
TimerAccumulator& accumulator = timer.getPrimaryAccumulator();
accumulator.mSelfTimeCounter = 0;
accumulator.mCalls = 0;
accumulator.mLastCaller = NULL;
accumulator.mMoveUpTree = false;
}
}
@ -419,7 +437,7 @@ void BlockTimer::reset()
U32 cur_time = getCPUClockCount32();
// root defined by parent pointing to self
CurTimerData* cur_data = &sCurTimerData;
CurTimerData* cur_data = sCurTimerData.get();
Time* cur_timer = cur_data->mCurTimer;
while(cur_timer && cur_timer->mLastTimerData.mCurTimer != cur_timer)
{
@ -432,7 +450,10 @@ void BlockTimer::reset()
// reset all history
{
for (instance_iter it = beginInstances(), end_it = endInstances(); it != end_it; ++it)
for (LLInstanceTracker<BlockTimer>::instance_iter it = LLInstanceTracker<BlockTimer>::beginInstances(),
end_it = LLInstanceTracker<BlockTimer>::endInstances();
it != end_it;
++it)
{
BlockTimer& timer = *it;
if (&timer != &BlockTimer::getRootTimer())
@ -453,13 +474,13 @@ void BlockTimer::reset()
U32 BlockTimer::getHistoricalCount(S32 history_index) const
{
S32 history_idx = (getLastFrameIndex() + history_index) % BlockTimer::HISTORY_NUM;
S32 history_idx = (getLastFrameIndex() + history_index) % HISTORY_NUM;
return mCountHistory[history_idx];
}
U32 BlockTimer::getHistoricalCalls(S32 history_index ) const
{
S32 history_idx = (getLastFrameIndex() + history_index) % BlockTimer::HISTORY_NUM;
S32 history_idx = (getLastFrameIndex() + history_index) % HISTORY_NUM;
return mCallHistory[history_idx];
}
@ -479,10 +500,10 @@ std::vector<BlockTimer*>& BlockTimer::getChildren()
}
//static
void Time::nextFrame()
void BlockTimer::nextFrame()
{
countsPerSecond(); // good place to calculate clock frequency
U64 frame_time = getCPUClockCount64();
BlockTimer::countsPerSecond(); // good place to calculate clock frequency
U64 frame_time = BlockTimer::getCPUClockCount64();
if ((frame_time - sLastFrameTime) >> 8 > 0xffffffff)
{
llinfos << "Slow frame, fast timers inaccurate" << llendl;
@ -505,7 +526,7 @@ void Time::dumpCurTimes()
// accumulate timings, etc.
BlockTimer::processTimes();
F64 clock_freq = (F64)countsPerSecond();
F64 clock_freq = (F64)BlockTimer::countsPerSecond();
F64 iclock_freq = 1000.0 / clock_freq; // clock_ticks -> milliseconds
// walk over timers in depth order and output timings
@ -533,13 +554,6 @@ void Time::dumpCurTimes()
}
}
//static
void Time::reset()
{
BlockTimer::reset();
}
//static
void Time::writeLog(std::ostream& os)
{

View File

@ -28,61 +28,78 @@
#define LL_FASTTIMER_H
#include "llinstancetracker.h"
#include "lltrace.h"
#define FAST_TIMER_ON 1
#define LL_FASTTIMER_USE_RDTSC 1
class LLMutex;
#include "lltrace.h"
#define LL_FASTTIMER_USE_RDTSC 1
namespace LLTrace
{
struct CurTimerData
{
class Time* mCurTimer;
class BlockTimer* mTimerData;
U64 mChildTime;
};
class Time
{
public:
friend class BlockTimer;
typedef Time self_t;
typedef class BlockTimer DeclareTimer;
public:
Time(BlockTimer& timer);
~Time();
public:
static bool sLog;
static bool sMetricLog;
static std::string sLogName;
static bool sPauseHistory;
static bool sResetHistory;
// call this once a frame to reset timers
static void nextFrame();
// dumps current cumulative frame stats to log
// call nextFrame() to reset timers
static void dumpCurTimes();
// call this to reset timer hierarchy, averages, etc.
static void reset();
static U64 countsPerSecond();
static S32 getLastFrameIndex() { return sLastFrameIndex; }
static S32 getCurFrameIndex() { return sCurFrameIndex; }
static void writeLog(std::ostream& os);
struct CurTimerData
{
Time* mCurTimer;
BlockTimer* mTimerData;
U64 mChildTime;
};
static LLThreadLocalPointer<CurTimerData> sCurTimerData;
private:
U64 mStartTime;
CurTimerData mLastTimerData;
};
// stores a "named" timer instance to be reused via multiple Time stack instances
class BlockTimer
: public TraceType<TimerAccumulator>,
public LLInstanceTracker<BlockTimer>
{
public:
BlockTimer(const char* name, bool open = false, BlockTimer* parent = &getRootTimer());
~BlockTimer();
enum { HISTORY_NUM = 300 };
BlockTimer* getParent() const { return mParent; }
void setParent(BlockTimer* parent);
S32 getDepth();
typedef std::vector<BlockTimer*>::const_iterator child_const_iter;
child_const_iter beginChildren();
child_const_iter endChildren();
std::vector<BlockTimer*>& getChildren();
void setCollapsed(bool collapsed) { mCollapsed = collapsed; }
bool getCollapsed() const { return mCollapsed; }
U32 getCountAverage() const { return mCountAverage; }
U32 getCallAverage() const { return mCallAverage; }
U32 getHistoricalCount(S32 history_index = 0) const;
U32 getHistoricalCalls(S32 history_index = 0) const;
static BlockTimer& getRootTimer();
static void pushLog(LLSD sd);
friend class Time;
//////////////////////////////////////////////////////////////////////////////
//
@ -106,14 +123,14 @@ private:
//#undef _interlockedbittestandset
//#undef _interlockedbittestandreset
//inline U32 Time::getCPUClockCount32()
//inline U32 BlockTimer::getCPUClockCount32()
//{
// U64 time_stamp = __rdtsc();
// return (U32)(time_stamp >> 8);
//}
//
//// return full timer value, *not* shifted by 8 bits
//inline U64 Time::getCPUClockCount64()
//inline U64 BlockTimer::getCPUClockCount64()
//{
// return __rdtsc();
//}
@ -220,64 +237,7 @@ private:
#endif
static U64 sClockResolution;
static S32 sCurFrameIndex;
static S32 sLastFrameIndex;
static U64 sLastFrameTime;
U64 mStartTime;
Time::CurTimerData mLastTimerData;
};
struct TimerAccumulator
{
void addSamples(const TimerAccumulator& other);
void reset(const TimerAccumulator* other);
//
// members
//
U64 mSelfTimeCounter,
mTotalTimeCounter;
U32 mCalls;
BlockTimer* mLastCaller; // used to bootstrap tree construction
U16 mActiveCount; // number of timers with this ID active on stack
bool mMoveUpTree; // needs to be moved up the tree of timers at the end of frame
};
// stores a "named" timer instance to be reused via multiple Time stack instances
class BlockTimer
: public TraceType<TimerAccumulator>,
public LLInstanceTracker<BlockTimer>
{
public:
BlockTimer(const char* name, bool open = false, BlockTimer* parent = &getRootTimer());
~BlockTimer();
enum { HISTORY_NUM = 300 };
BlockTimer* getParent() const { return mParent; }
void setParent(BlockTimer* parent);
S32 getDepth();
typedef std::vector<BlockTimer*>::const_iterator child_const_iter;
child_const_iter beginChildren();
child_const_iter endChildren();
std::vector<BlockTimer*>& getChildren();
void setCollapsed(bool collapsed) { mCollapsed = collapsed; }
bool getCollapsed() const { return mCollapsed; }
U32 getCountAverage() const { return mCountAverage; }
U32 getCallAverage() const { return mCallAverage; }
U32 getHistoricalCount(S32 history_index = 0) const;
U32 getHistoricalCalls(S32 history_index = 0) const;
static BlockTimer& getRootTimer();
private:
friend class Time;
static U64 countsPerSecond();
// recursive call to gather total time from children
static void accumulateTimings();
@ -289,6 +249,12 @@ private:
static void buildHierarchy();
static void resetFrame();
static void reset();
// call this once a frame to reset timers
static void nextFrame();
static S32 getLastFrameIndex() { return sLastFrameIndex; }
static S32 getCurFrameIndex() { return sCurFrameIndex; }
// sum of recorded self time and tree time of all children timers (might not match actual recorded time of children if topology is incomplete
U32 mTreeTimeCounter;
@ -304,12 +270,25 @@ private:
std::vector<BlockTimer*> mChildren;
bool mCollapsed; // don't show children
bool mNeedsSorting; // sort children whenever child added
// statics
static std::string sLogName;
static bool sMetricLog;
static bool sLog;
static LLThreadLocalPointer<CurTimerData> sCurTimerData;
static U64 sClockResolution;
static S32 sCurFrameIndex;
static S32 sLastFrameIndex;
static U64 sLastFrameTime;
static bool sPauseHistory;
static bool sResetHistory;
};
LL_FORCE_INLINE Time::Time(BlockTimer& timer)
{
#if FAST_TIMER_ON
mStartTime = getCPUClockCount64();
mStartTime = BlockTimer::getCPUClockCount64();
TimerAccumulator& accumulator = timer.getPrimaryAccumulator();
accumulator.mActiveCount++;
@ -317,7 +296,7 @@ LL_FORCE_INLINE Time::Time(BlockTimer& timer)
// keep current parent as long as it is active when we are
accumulator.mMoveUpTree |= (timer.mParent->getPrimaryAccumulator().mActiveCount == 0);
CurTimerData* cur_timer_data = Time::sCurTimerData.get();
CurTimerData* cur_timer_data = BlockTimer::sCurTimerData.get();
// store top of stack
mLastTimerData = *cur_timer_data;
// push new information
@ -330,8 +309,8 @@ LL_FORCE_INLINE Time::Time(BlockTimer& timer)
LL_FORCE_INLINE Time::~Time()
{
#if FAST_TIMER_ON
U64 total_time = getCPUClockCount64() - mStartTime;
CurTimerData* cur_timer_data = Time::sCurTimerData.get();
U64 total_time = BlockTimer::getCPUClockCount64() - mStartTime;
CurTimerData* cur_timer_data = BlockTimer::sCurTimerData.get();
TimerAccumulator& accumulator = cur_timer_data->mTimerData->getPrimaryAccumulator();
accumulator.mSelfTimeCounter += total_time - cur_timer_data->mChildTime;
accumulator.mTotalTimeCounter += total_time;
@ -344,7 +323,7 @@ LL_FORCE_INLINE Time::~Time()
// we are only tracking self time, so subtract our total time delta from parents
mLastTimerData.mChildTime += total_time;
*sCurTimerData = mLastTimerData;
*BlockTimer::sCurTimerData = mLastTimerData;
#endif
}

View File

@ -28,7 +28,7 @@
*/
#if LL_WINDOWS
#include <windows.h>
#include "llwin32headerslean.h"
#include <stdlib.h> // Windows errno
#else
#include <errno.h>

View File

@ -33,7 +33,7 @@
#include <ctype.h>
#ifdef WIN32
#include <windows.h>
#include "llwin32headers.h"
#include <winnt.h>
#endif

View File

@ -28,6 +28,7 @@
#include "linden_common.h"
#include "llinitparam.h"
#include "llformat.h"
namespace LLInitParam

View File

@ -29,6 +29,7 @@
#define LL_LLPARAM_H
#include <vector>
#include <list>
#include <boost/function.hpp>
#include <boost/type_traits/is_convertible.hpp>
#include <boost/unordered_map.hpp>

View File

@ -32,7 +32,6 @@
//#endif
#if defined(LL_WINDOWS)
//# include <windows.h>
# include <psapi.h>
#elif defined(LL_DARWIN)
# include <sys/types.h>

View File

@ -31,6 +31,7 @@
#include "llsdserialize.h"
#include "lltreeiterators.h"
#include "llmetricperformancetester.h"
#include "llfasttimer.h"
//----------------------------------------------------------------------------------------------
// LLMetricPerformanceTesterBasic : static methods and testers management
@ -90,7 +91,7 @@ LLMetricPerformanceTesterBasic* LLMetricPerformanceTesterBasic::getTester(std::s
// Return TRUE if this metric is requested or if the general default "catch all" metric is requested
BOOL LLMetricPerformanceTesterBasic::isMetricLogRequested(std::string name)
{
return (LLFastTimer::sMetricLog && ((LLFastTimer::sLogName == name) || (LLFastTimer::sLogName == DEFAULT_METRIC_NAME)));
return (LLTrace::BlockTimer::sMetricLog && ((LLTrace::BlockTimer::sLogName == name) || (LLTrace::BlockTimer::sLogName == DEFAULT_METRIC_NAME)));
}
/*static*/
@ -193,8 +194,7 @@ void LLMetricPerformanceTesterBasic::preOutputTestResults(LLSD* sd)
void LLMetricPerformanceTesterBasic::postOutputTestResults(LLSD* sd)
{
LLMutexLock lock(LLFastTimer::sLogLock);
LLFastTimer::sLogQueue.push((*sd));
LLTrace::BlockTimer::pushLog(*sd);
}
void LLMetricPerformanceTesterBasic::outputTestResults()

View File

@ -28,6 +28,7 @@
#define LLMORTICIAN_H
#include "stdtypes.h"
#include <list>
class LL_COMMON_API LLMortician
{

View File

@ -38,8 +38,7 @@
#include <stdexcept>
#if LL_WINDOWS
#define WIN32_LEAN_AND_MEAN
#include <windows.h> // HANDLE (eye roll)
#include "llwin32headerslean.h" // for HANDLE
#elif LL_LINUX
#if defined(Status)
#undef Status

View File

@ -32,9 +32,7 @@
//#include <memory>
#if LL_WINDOWS
# define WIN32_LEAN_AND_MEAN
# include <winsock2.h>
# include <windows.h>
# include "llwin32headerslean.h"
# define _interlockedbittestandset _renamed_interlockedbittestandset
# define _interlockedbittestandreset _renamed_interlockedbittestandreset
# include <intrin.h>

View File

@ -30,6 +30,7 @@
#include "llinitparam.h"
#include "boost/function.hpp"
#include "llfasttimer.h"
struct LL_COMMON_API LLParamSDParserUtilities
{

View File

@ -32,7 +32,7 @@
#include <iostream>
#include <sstream>
#include "windows.h"
#include "llwin32headerslean.h"
#include "Dbghelp.h"
typedef USHORT NTAPI RtlCaptureStackBackTrace_Function(

View File

@ -28,11 +28,10 @@
#include "llstring.h"
#include "llerror.h"
#include "llfasttimer.h"
#if LL_WINDOWS
#define WIN32_LEAN_AND_MEAN
#include <winsock2.h>
#include <windows.h>
#include "llwin32headerslean.h"
#include <winnls.h> // for WideCharToMultiByte
#endif

View File

@ -31,8 +31,9 @@
#include <cstdio>
#include <locale>
#include <iomanip>
#include <algorithm>
#include "llsd.h"
#include "llfasttimer.h"
#include "llformat.h"
#if LL_LINUX || LL_SOLARIS
#include <wctype.h>

View File

@ -42,6 +42,7 @@
#include "llprocessor.h"
#include "llerrorcontrol.h"
#include "llevents.h"
#include "llformat.h"
#include "lltimer.h"
#include "llsdserialize.h"
#include "llsdutil.h"
@ -58,9 +59,7 @@
using namespace llsd;
#if LL_WINDOWS
# define WIN32_LEAN_AND_MEAN
# include <winsock2.h>
# include <windows.h>
# include "llwin32headerslean.h"
# include <psapi.h> // GetPerformanceInfo() et al.
#elif LL_DARWIN
# include <errno.h>

View File

@ -31,11 +31,9 @@
#include "u64.h"
#if LL_WINDOWS
# define WIN32_LEAN_AND_MEAN
# include <winsock2.h>
# include <windows.h>
# include "llwin32headerslean.h"
#elif LL_LINUX || LL_SOLARIS || LL_DARWIN
# include <errno.h>
# include <errno.h>
# include <sys/time.h>
#else
# error "architecture not supported"

View File

@ -38,15 +38,15 @@ static MasterThreadRecorder* gMasterThreadRecorder = NULL;
void init()
{
gMasterThreadRecorder = new MasterThreadRecorder();
Time::sCurTimerData = new Time::CurTimerData();
BlockTimer::sCurTimerData = new CurTimerData();
}
void cleanup()
{
delete gMasterThreadRecorder;
gMasterThreadRecorder = NULL;
delete Time::sCurTimerData.get();
Time::sCurTimerData = NULL;
delete BlockTimer::sCurTimerData.get();
BlockTimer::sCurTimerData = NULL;
}
MasterThreadRecorder& getMasterThreadRecorder()

View File

@ -235,8 +235,8 @@ namespace LLTrace
MeasurementAccumulator()
: mSum(0),
mMin(std::numeric_limits<T>::max()),
mMax(std::numeric_limits<T>::min()),
mMin((std::numeric_limits<T>::max)()),
mMax((std::numeric_limits<T>::min)()),
mMean(0),
mVarianceSum(0),
mNumSamples(0),
@ -380,6 +380,24 @@ namespace LLTrace
U32 mNumSamples;
};
class TimerAccumulator
{
public:
void addSamples(const TimerAccumulator& other);
void reset(const TimerAccumulator* other);
//
// members
//
U64 mSelfTimeCounter,
mTotalTimeCounter;
U32 mCalls;
class BlockTimer* mLastCaller; // used to bootstrap tree construction
U16 mActiveCount; // number of timers with this ID active on stack
bool mMoveUpTree; // needs to be moved up the tree of timers at the end of frame
};
template <typename T = F64>
class Measurement
: public TraceType<MeasurementAccumulator<typename LLUnits::HighestPrecisionType<T>::type_t> >

View File

@ -273,7 +273,7 @@ namespace LLTrace
template <typename T>
typename T getPeriodMin(const TraceType<CountAccumulator<T> >& stat) const
{
T min_val = std::numeric_limits<T>::max();
T min_val = (std::numeric_limits<T>::max)();
for (S32 i = 0; i < mNumPeriods; i++)
{
min_val = llmin(min_val, mRecordingPeriods[i].getSum(stat));
@ -284,7 +284,7 @@ namespace LLTrace
template <typename T>
F64 getPeriodMinPerSec(const TraceType<CountAccumulator<T> >& stat) const
{
F64 min_val = std::numeric_limits<F64>::max();
F64 min_val = (std::numeric_limits<F64>::max)();
for (S32 i = 0; i < mNumPeriods; i++)
{
min_val = llmin(min_val, mRecordingPeriods[i].getPerSec(stat));
@ -295,7 +295,7 @@ namespace LLTrace
template <typename T>
T getPeriodMax(const TraceType<CountAccumulator<T> >& stat) const
{
T max_val = std::numeric_limits<T>::min();
T max_val = (std::numeric_limits<T>::min)();
for (S32 i = 0; i < mNumPeriods; i++)
{
max_val = llmax(max_val, mRecordingPeriods[i].getSum(stat));
@ -306,7 +306,7 @@ namespace LLTrace
template <typename T>
F64 getPeriodMaxPerSec(const TraceType<CountAccumulator<T> >& stat) const
{
F64 max_val = std::numeric_limits<F64>::min();
F64 max_val = (std::numeric_limits<F64>::min)();
for (S32 i = 0; i < mNumPeriods; i++)
{
max_val = llmax(max_val, mRecordingPeriods[i].getPerSec(stat));

View File

@ -26,6 +26,7 @@
#include "linden_common.h"
#include "lltracethreadrecorder.h"
#include "llfasttimer.h"
namespace LLTrace
{

View File

@ -33,18 +33,12 @@
namespace LLUnits
{
template<typename T, typename IS_UNIT = void>
template<typename T>
struct HighestPrecisionType
{
typedef T type_t;
};
template<typename T>
struct HighestPrecisionType<T, typename T::is_unit_tag_t>
{
typedef typename HighestPrecisionType<typename T::storage_t>::type_t type_t;
};
template<> struct HighestPrecisionType<F32> { typedef F64 type_t; };
template<> struct HighestPrecisionType<S32> { typedef S64 type_t; };
template<> struct HighestPrecisionType<U32> { typedef S64 type_t; };
@ -78,7 +72,6 @@ struct LLUnit
{
typedef LLUnit<UNIT_TYPE, STORAGE_TYPE> self_t;
typedef typename STORAGE_TYPE storage_t;
typedef void is_unit_tag_t;
LLUnit(storage_t value = storage_t())
: mValue(value)

View File

@ -27,9 +27,7 @@
// We can't use WIN32_LEAN_AND_MEAN here, needs lots of includes.
#if LL_WINDOWS
#undef WIN32_LEAN_AND_MEAN
#include <winsock2.h>
#include <windows.h>
#include "llwin32headers.h"
// ugh, this is ugly. We need to straighten out our linking for this library
#pragma comment(lib, "IPHLPAPI.lib")
#include <iphlpapi.h>

View File

@ -0,0 +1,38 @@
/**
* @file llwindows.h
* @brief sanitized include of windows header files
*
* $LicenseInfo:firstyear=2001&license=viewerlgpl$
* Second Life Viewer Source Code
* Copyright (C) 2010, Linden Research, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation;
* version 2.1 of the License only.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
* $/LicenseInfo$
*/
#ifndef LL_LLWINDOWS_H
#define LL_LLWINDOWS_H
#ifdef LL_WINDOWS
#define NOMINMAX
#undef WIN32_LEAN_AND_MEAN
#include <winsock2.h>
#include <windows.h>
#undef NOMINMAX
#endif
#endif

View File

@ -0,0 +1,37 @@
/**
* @file llwindows.h
* @brief sanitized include of windows header files
*
* $LicenseInfo:firstyear=2001&license=viewerlgpl$
* Second Life Viewer Source Code
* Copyright (C) 2010, Linden Research, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation;
* version 2.1 of the License only.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
* $/LicenseInfo$
*/
#ifndef LL_LLWINDOWS_H
#define LL_LLWINDOWS_H
#ifdef LL_WINDOWS
#define NOMINMAX
#define WIN32_LEAN_AND_MEAN
#include <winsock2.h>
#include <windows.h>
#endif
#endif

View File

@ -27,6 +27,7 @@
#define LL_LLECONOMY_H
#include "llsingleton.h"
#include <list>
class LLMessageSystem;
class LLVector3;

View File

@ -28,6 +28,7 @@
#include "llinventory.h"
#include "lldbstrings.h"
#include "llfasttimer.h"
#include "llinventorydefines.h"
#include "llxorcipher.h"
#include "llsd.h"

View File

@ -80,6 +80,7 @@
#include "llbuffer.h"
#include "llbufferstream.h"
#include "llfasttimer.h"
#include "llmemorystream.h"
#include "llsd.h"
#include "llsdserialize.h"

View File

@ -33,6 +33,7 @@
#include "llapr.h"
#include "llbuffer.h"
#include "llbufferstream.h"
#include "llfasttimer.h"
#include "llhttpnode.h"
#include "lliopipe.h"
#include "lliosocket.h"

View File

@ -32,6 +32,7 @@
#include "llapr.h"
#include "llbuffer.h"
#include "llfasttimer.h"
#include "llhost.h"
#include "llpumpio.h"

View File

@ -39,6 +39,7 @@
#include "lliopipe.h"
#include "apr_pools.h"
#include "llwin32headerslean.h"
#include "apr_network_io.h"
#include "llchainio.h"

View File

@ -28,6 +28,7 @@
#include "linden_common.h"
#include "llioutil.h"
#include "llfasttimer.h"
/**
* LLIOFlush

View File

@ -29,12 +29,7 @@
#include "llmail.h"
// APR on Windows needs full windows headers
#ifdef LL_WINDOWS
# undef WIN32_LEAN_AND_MEAN
# include <winsock2.h>
# include <windows.h>
#endif
#include "llwin32headers.h"
#include <string>
#include <sstream>

View File

@ -34,6 +34,7 @@
#include "apr_poll.h"
#include "llapr.h"
#include "llfasttimer.h"
#include "llstl.h"
// These should not be enabled in production, but they can be

View File

@ -30,6 +30,7 @@
#include "llsdrpcclient.h"
#include "llbufferstream.h"
#include "llfasttimer.h"
#include "llfiltersd2xmlrpc.h"
#include "llpumpio.h"
#include "llsd.h"

View File

@ -31,6 +31,7 @@
#include "llbuffer.h"
#include "llbufferstream.h"
#include "llfasttimer.h"
#include "llpumpio.h"
#include "llsdserialize.h"
#include "llstl.h"

View File

@ -33,6 +33,7 @@
#include <openssl/x509_vfy.h>
#include <openssl/ssl.h>
#include "llcurl.h"
#include "llfasttimer.h"
#include "llioutil.h"
#include "llproxy.h"
#include "llpumpio.h"

View File

@ -32,9 +32,7 @@
#include <stdexcept>
#if LL_WINDOWS
#define WIN32_LEAN_AND_MEAN
#include <winsock2.h>
#include <windows.h>
#include "llwin32headerslean.h"
#else
#include <sys/types.h>
#include <sys/socket.h>

View File

@ -29,6 +29,7 @@
#ifndef LL_LLPLUGINPROCESSCHILD_H
#define LL_LLPLUGINPROCESSCHILD_H
#include <queue>
#include "llpluginmessage.h"
#include "llpluginmessagepipe.h"
#include "llplugininstance.h"

View File

@ -29,6 +29,8 @@
#ifndef LL_LLPLUGINPROCESSPARENT_H
#define LL_LLPLUGINPROCESSPARENT_H
#include <queue>
#include "llapr.h"
#include "llprocess.h"
#include "llpluginmessage.h"

View File

@ -27,6 +27,7 @@
*/
#include "linden_common.h"
#include <list>
#include "../test/lltut.h"
#include "../llplugincookiestore.h"

View File

@ -29,6 +29,7 @@
#include "llfontgl.h"
// Linden library includes
#include "llfasttimer.h"
#include "llfontfreetype.h"
#include "llfontbitmapcache.h"
#include "llfontregistry.h"

View File

@ -540,11 +540,7 @@ extern PFNGLBINDBUFFERRANGEPROC glBindBufferRange;
// LL_WINDOWS
// windows gl headers depend on things like APIENTRY, so include windows.
#define WIN32_LEAN_AND_MEAN
#include <winsock2.h>
#include <windows.h>
#undef min
#undef max
#include "llwin32headerslean.h"
//----------------------------------------------------------------------------
#include <GL/gl.h>

View File

@ -32,6 +32,7 @@
#include "llimagegl.h"
#include "llerror.h"
#include "llfasttimer.h"
#include "llimage.h"
#include "llmath.h"

View File

@ -26,7 +26,7 @@
#include "linden_common.h"
#include <boost/static_assert.hpp>
#include "llfasttimer.h"
#include "llsys.h"
#include "llvertexbuffer.h"
// #include "llrender.h"

View File

@ -30,6 +30,7 @@
#include "llrect.h"
#include "llsd.h"
#include <list>
#include <boost/function.hpp>
//*******************************************************

View File

@ -100,10 +100,10 @@ private:
BOOL mDisplayHistory;
BOOL mDisplayMean; // If true, display mean, if false, display current value
LLTrace::TraceType<CountAccumulator<F64> >* mCountFloatp;
LLTrace::TraceType<CountAccumulator<S64> >* mCountIntp;
LLTrace::TraceType<MeasurementAccumulator<F64> >* mMeasurementFloatp;
LLTrace::TraceType<MeasurementAccumulator<S64> >* mMeasurementIntp;
LLTrace::TraceType<LLTrace::CountAccumulator<F64> >* mCountFloatp;
LLTrace::TraceType<LLTrace::CountAccumulator<S64> >* mCountIntp;
LLTrace::TraceType<LLTrace::MeasurementAccumulator<F64> >* mMeasurementFloatp;
LLTrace::TraceType<LLTrace::MeasurementAccumulator<S64> >* mMeasurementIntp;
LLFrameTimer mUpdateTimer;
LLUIString mLabel;

View File

@ -57,10 +57,10 @@ public:
struct StatParams : public LLInitParam::ChoiceBlock<StatParams>
{
Alternative<LLTrace::TraceType<CountAccumulator<F64> >* > count_stat_float;
Alternative<LLTrace::TraceType<CountAccumulator<S64> >* > count_stat_int;
Alternative<LLTrace::TraceType<MeasurementAccumulator<F64> >* > measurement_stat_float;
Alternative<LLTrace::TraceType<MeasurementAccumulator<S64> >* > measurement_stat_int;
Alternative<LLTrace::TraceType<LLTrace::CountAccumulator<F64> >* > count_stat_float;
Alternative<LLTrace::TraceType<LLTrace::CountAccumulator<S64> >* > count_stat_int;
Alternative<LLTrace::TraceType<LLTrace::MeasurementAccumulator<F64> >* > measurement_stat_float;
Alternative<LLTrace::TraceType<LLTrace::MeasurementAccumulator<S64> >* > measurement_stat_int;
};
struct Params : public LLInitParam::Block<Params, LLView::Params>
@ -105,8 +105,8 @@ public:
/*virtual*/ void setValue(const LLSD& value);
private:
LLTrace::count_common_float_t* mNewStatFloatp;
LLTrace::count_common_int_t* mNewStatIntp;
LLTrace::TraceType<LLTrace::CountAccumulator<F64> >* mNewStatFloatp;
LLTrace::TraceType<LLTrace::CountAccumulator<S64> >* mNewStatIntp;
BOOL mPerSec;

View File

@ -26,6 +26,8 @@
#include "linden_common.h"
#include "lluistring.h"
#include "llfasttimer.h"
#include "llsd.h"
#include "lltrans.h"

View File

@ -29,7 +29,7 @@
#include "llxuiparser.h"
#include "llxmlnode.h"
#include "llfasttimer.h"
#ifdef LL_STANDALONE
#include <expat.h>
#else

View File

@ -36,7 +36,7 @@
#if LL_WINDOWS //For windows platform.
#include <windows.h>
#include "llwin32headerslean.h"
namespace {
inline DWORD getpid() {

View File

@ -32,6 +32,7 @@
#include "llthread.h"
#include "llvfs.h"
#include "lltimer.h"
#include "llfasttimer.h"
const S32 LLVFile::READ = 0x00000001;
const S32 LLVFile::WRITE = 0x00000002;

View File

@ -28,6 +28,7 @@
#define LL_LLKEYBOARD_H
#include <map>
#include <boost/function.hpp>
#include "string_table.h"
#include "lltimer.h"

View File

@ -28,10 +28,7 @@
#include "linden_common.h"
#define WIN32_LEAN_AND_MEAN
#include <winsock2.h>
#include <windows.h>
#include "llwin32headerslean.h"
#include "llkeyboardwin32.h"
#include "llwindowcallbacks.h"

View File

@ -31,6 +31,7 @@
#include "llcoord.h"
#include "llstring.h"
#include "llcursortypes.h"
#include "llinstancetracker.h"
#include "llsd.h"
class LLSplashScreen;

View File

@ -38,6 +38,7 @@
// Linden library includes
#include "llerror.h"
#include "llfasttimer.h"
#include "llgl.h"
#include "llstring.h"
#include "lldir.h"

View File

@ -28,9 +28,7 @@
#define LL_LLWINDOWWIN32_H
// Limit Windows API to small and manageable set.
#define WIN32_LEAN_AND_MEAN
#include <winsock2.h>
#include <windows.h>
#include "llwin32headerslean.h"
#include "llwindow.h"
#include "llwindowcallbacks.h"

View File

@ -679,7 +679,7 @@ bool LLAppViewer::init()
// into the log files during normal startup until AFTER
// we run the "program crashed last time" error handler below.
//
LLFastTimer::reset();
LLTrace::BlockTimer::reset();
// initialize SSE options
LLVector4a::initClass();
@ -1222,7 +1222,7 @@ bool LLAppViewer::mainLoop()
while (!LLApp::isExiting())
{
LLFastTimer _(FTM_FRAME);
LLFastTimer::nextFrame();
LLTrace::BlockTimer::nextFrame();
LLTrace::getMasterThreadRecorder().pullFromSlaveThreads();
//clear call stack records
@ -1552,9 +1552,9 @@ bool LLAppViewer::cleanup()
if (LLFastTimerView::sAnalyzePerformance)
{
llinfos << "Analyzing performance" << llendl;
std::string baseline_name = LLFastTimer::sLogName + "_baseline.slp";
std::string current_name = LLFastTimer::sLogName + ".slp";
std::string report_name = LLFastTimer::sLogName + "_report.csv";
std::string baseline_name = LLTrace::BlockTimer::sLogName + "_baseline.slp";
std::string current_name = LLTrace::BlockTimer::sLogName + ".slp";
std::string report_name = LLTrace::BlockTimer::sLogName + "_report.csv";
LLFastTimerView::doAnalysis(
gDirUtilp->getExpandedFilename(LL_PATH_LOGS, baseline_name),
@ -1900,9 +1900,9 @@ bool LLAppViewer::cleanup()
{
llinfos << "Analyzing performance" << llendl;
std::string baseline_name = LLFastTimer::sLogName + "_baseline.slp";
std::string current_name = LLFastTimer::sLogName + ".slp";
std::string report_name = LLFastTimer::sLogName + "_report.csv";
std::string baseline_name = LLTrace::BlockTimer::sLogName + "_baseline.slp";
std::string current_name = LLTrace::BlockTimer::sLogName + ".slp";
std::string report_name = LLTrace::BlockTimer::sLogName + "_report.csv";
LLFastTimerView::doAnalysis(
gDirUtilp->getExpandedFilename(LL_PATH_LOGS, baseline_name),
@ -2031,10 +2031,10 @@ bool LLAppViewer::initThreads()
enable_threads && true,
app_metrics_qa_mode);
if (LLFastTimer::sLog || LLFastTimer::sMetricLog)
if (LLTrace::BlockTimer::sLog || LLTrace::BlockTimer::sMetricLog)
{
LLFastTimer::sLogLock = new LLMutex(NULL);
mFastTimerLogThread = new LLFastTimerLogThread(LLFastTimer::sLogName);
LLTrace::BlockTimer::sLogLock = new LLMutex(NULL);
mFastTimerLogThread = new LLFastTimerLogThread(LLTrace::BlockTimer::sLogName);
mFastTimerLogThread->start();
}
@ -2445,13 +2445,13 @@ bool LLAppViewer::initConfiguration()
if (clp.hasOption("logperformance"))
{
LLFastTimer::sLog = TRUE;
LLFastTimer::sLogName = std::string("performance");
LLTrace::BlockTimer::sLog = true;
LLTrace::BlockTimer::sLogName = std::string("performance");
}
if (clp.hasOption("logmetrics"))
{
LLFastTimer::sMetricLog = TRUE ;
LLTrace::BlockTimer::sMetricLog = true ;
// '--logmetrics' can be specified with a named test metric argument so the data gathering is done only on that test
// In the absence of argument, every metric is gathered (makes for a rather slow run and hard to decipher report...)
std::string test_name = clp.getOption("logmetrics")[0];
@ -2459,11 +2459,11 @@ bool LLAppViewer::initConfiguration()
if (test_name == "")
{
llwarns << "No '--logmetrics' argument given, will output all metrics to " << DEFAULT_METRIC_NAME << llendl;
LLFastTimer::sLogName = DEFAULT_METRIC_NAME;
LLTrace::BlockTimer::sLogName = DEFAULT_METRIC_NAME;
}
else
{
LLFastTimer::sLogName = test_name;
LLTrace::BlockTimer::sLogName = test_name;
}
}

View File

@ -61,17 +61,17 @@ static const S32 LINE_GRAPH_HEIGHT = 240;
static S32 FTV_NUM_TIMERS;
const S32 FTV_MAX_DEPTH = 8;
std::vector<LLFastTimer::DeclareTimer*> ft_display_idx; // line of table entry for display purposes (for collapse)
std::vector<LLTrace::BlockTimer*> ft_display_idx; // line of table entry for display purposes (for collapse)
typedef LLTreeDFSIter<LLFastTimer::DeclareTimer, LLFastTimer::DeclareTimer::child_const_iter> timer_tree_iterator_t;
typedef LLTreeDFSIter<LLTrace::BlockTimer, LLTrace::BlockTimer::child_const_iter> timer_tree_iterator_t;
BOOL LLFastTimerView::sAnalyzePerformance = FALSE;
static timer_tree_iterator_t begin_timer_tree(LLFastTimer::DeclareTimer& id)
static timer_tree_iterator_t begin_timer_tree(LLTrace::BlockTimer& id)
{
return timer_tree_iterator_t(&id,
boost::bind(boost::mem_fn(&LLFastTimer::DeclareTimer::beginChildren), _1),
boost::bind(boost::mem_fn(&LLFastTimer::DeclareTimer::endChildren), _1));
boost::bind(boost::mem_fn(&LLTrace::BlockTimer::beginChildren), _1),
boost::bind(boost::mem_fn(&LLTrace::BlockTimer::endChildren), _1));
}
static timer_tree_iterator_t end_timer_tree()
@ -92,18 +92,18 @@ LLFastTimerView::LLFastTimerView(const LLSD& key)
mScrollIndex = 0;
mHoverID = NULL;
mHoverBarIndex = -1;
FTV_NUM_TIMERS = LLFastTimer::DeclareTimer::instanceCount();
FTV_NUM_TIMERS = LLTrace::BlockTimer::instanceCount();
mPrintStats = -1;
}
void LLFastTimerView::onPause()
{
LLFastTimer::sPauseHistory = !LLFastTimer::sPauseHistory;
LLTrace::BlockTimer::sPauseHistory = !LLTrace::BlockTimer::sPauseHistory;
// reset scroll to bottom when unpausing
if (!LLFastTimer::sPauseHistory)
if (!LLTrace::BlockTimer::sPauseHistory)
{
mScrollIndex = 0;
LLFastTimer::sResetHistory = true;
LLTrace::BlockTimer::sResetHistory = true;
getChild<LLButton>("pause_btn")->setLabel(getString("pause"));
}
else
@ -139,13 +139,13 @@ BOOL LLFastTimerView::handleRightMouseDown(S32 x, S32 y, MASK mask)
{
S32 bar_idx = MAX_VISIBLE_HISTORY - ((y - mBarRect.mBottom) * (MAX_VISIBLE_HISTORY + 2) / mBarRect.getHeight());
bar_idx = llclamp(bar_idx, 0, MAX_VISIBLE_HISTORY);
mPrintStats = LLFastTimer::DeclareTimer::HISTORY_NUM - mScrollIndex - bar_idx;
mPrintStats = LLTrace::BlockTimer::HISTORY_NUM - mScrollIndex - bar_idx;
return TRUE;
}
return LLFloater::handleRightMouseDown(x, y, mask);
}
LLFastTimer::DeclareTimer* LLFastTimerView::getLegendID(S32 y)
LLTrace::BlockTimer* LLFastTimerView::getLegendID(S32 y)
{
S32 idx = (getRect().getHeight() - y) / (LLFontGL::getFontMonospace()->getLineHeight()+2) - 5;
@ -172,7 +172,7 @@ BOOL LLFastTimerView::handleMouseDown(S32 x, S32 y, MASK mask)
{
if (x < mBarRect.mLeft)
{
LLFastTimer::DeclareTimer* idp = getLegendID(y);
LLTrace::BlockTimer* idp = getLegendID(y);
if (idp)
{
idp->setCollapsed(!idp->getCollapsed());
@ -208,16 +208,7 @@ BOOL LLFastTimerView::handleMouseDown(S32 x, S32 y, MASK mask)
gFocusMgr.setMouseCapture(this);
return TRUE;
}
//else
//{
// // pause/unpause
// LLFastTimer::sPauseHistory = !LLFastTimer::sPauseHistory;
// // reset scroll to bottom when unpausing
// if (!LLFastTimer::sPauseHistory)
// {
// mScrollIndex = 0;
// }
//}
return LLFloater::handleMouseDown(x, y, mask);
}
@ -235,14 +226,14 @@ BOOL LLFastTimerView::handleHover(S32 x, S32 y, MASK mask)
if (hasMouseCapture())
{
F32 lerp = llclamp(1.f - (F32) (x - mGraphRect.mLeft) / (F32) mGraphRect.getWidth(), 0.f, 1.f);
mScrollIndex = llround( lerp * (F32)(LLFastTimer::DeclareTimer::HISTORY_NUM - MAX_VISIBLE_HISTORY));
mScrollIndex = llclamp( mScrollIndex, 0, LLFastTimer::getLastFrameIndex());
mScrollIndex = llround( lerp * (F32)(LLTrace::BlockTimer::HISTORY_NUM - MAX_VISIBLE_HISTORY));
mScrollIndex = llclamp( mScrollIndex, 0, LLTrace::BlockTimer::getLastFrameIndex());
return TRUE;
}
mHoverTimer = NULL;
mHoverID = NULL;
if(LLFastTimer::sPauseHistory && mBarRect.pointInRect(x, y))
if(LLTrace::BlockTimer::sPauseHistory && mBarRect.pointInRect(x, y))
{
mHoverBarIndex = llmin(LLFastTimer::getCurFrameIndex() - 1,
MAX_VISIBLE_HISTORY - ((y - mBarRect.mBottom) * (MAX_VISIBLE_HISTORY + 2) / mBarRect.getHeight()));
@ -288,7 +279,7 @@ BOOL LLFastTimerView::handleHover(S32 x, S32 y, MASK mask)
}
else if (x < mBarRect.mLeft)
{
LLFastTimer::DeclareTimer* timer_id = getLegendID(y);
LLTrace::BlockTimer* timer_id = getLegendID(y);
if (timer_id)
{
mHoverID = timer_id;
@ -299,7 +290,7 @@ BOOL LLFastTimerView::handleHover(S32 x, S32 y, MASK mask)
}
static std::string get_tooltip(LLFastTimer::DeclareTimer& timer, S32 history_index = -1)
static std::string get_tooltip(LLTrace::BlockTimer& timer, S32 history_index = -1)
{
F64 ms_multiplier = 1000.0 / (F64)LLFastTimer::countsPerSecond();
@ -318,7 +309,7 @@ static std::string get_tooltip(LLFastTimer::DeclareTimer& timer, S32 history_ind
BOOL LLFastTimerView::handleToolTip(S32 x, S32 y, MASK mask)
{
if(LLFastTimer::sPauseHistory && mBarRect.pointInRect(x, y))
if(LLTrace::BlockTimer::sPauseHistory && mBarRect.pointInRect(x, y))
{
// tooltips for timer bars
if (mHoverTimer)
@ -326,7 +317,7 @@ BOOL LLFastTimerView::handleToolTip(S32 x, S32 y, MASK mask)
LLRect screen_rect;
localRectToScreen(mToolTipRect, &screen_rect);
std::string tooltip = get_tooltip(*mHoverTimer, LLFastTimer::DeclareTimer::HISTORY_NUM - mScrollIndex - mHoverBarIndex);
std::string tooltip = get_tooltip(*mHoverTimer, LLTrace::BlockTimer::HISTORY_NUM - mScrollIndex - mHoverBarIndex);
LLToolTipMgr::instance().show(LLToolTip::Params()
.message(tooltip)
@ -341,7 +332,7 @@ BOOL LLFastTimerView::handleToolTip(S32 x, S32 y, MASK mask)
// tooltips for timer legend
if (x < mBarRect.mLeft)
{
LLFastTimer::DeclareTimer* idp = getLegendID(y);
LLTrace::BlockTimer* idp = getLegendID(y);
if (idp)
{
LLToolTipMgr::instance().show(get_tooltip(*idp));
@ -356,16 +347,16 @@ BOOL LLFastTimerView::handleToolTip(S32 x, S32 y, MASK mask)
BOOL LLFastTimerView::handleScrollWheel(S32 x, S32 y, S32 clicks)
{
LLFastTimer::sPauseHistory = TRUE;
LLTrace::BlockTimer::sPauseHistory = TRUE;
mScrollIndex = llclamp( mScrollIndex + clicks,
0,
llmin(LLFastTimer::getLastFrameIndex(), (S32)LLFastTimer::DeclareTimer::HISTORY_NUM - MAX_VISIBLE_HISTORY));
llmin(LLTrace::BlockTimer::getLastFrameIndex(), (S32)LLTrace::BlockTimer::HISTORY_NUM - MAX_VISIBLE_HISTORY));
return TRUE;
}
static LLFastTimer::DeclareTimer FTM_RENDER_TIMER("Timers", true);
static LLTrace::BlockTimer FTM_RENDER_TIMER("Timers", true);
static std::map<LLFastTimer::DeclareTimer*, LLColor4> sTimerColors;
static std::map<LLTrace::BlockTimer*, LLColor4> sTimerColors;
void LLFastTimerView::draw()
{
@ -429,7 +420,7 @@ void LLFastTimerView::draw()
y -= (texth + 2);
}
S32 histmax = llmin(LLFastTimer::getLastFrameIndex()+1, MAX_VISIBLE_HISTORY);
S32 histmax = llmin(LLTrace::BlockTimer::getLastFrameIndex()+1, MAX_VISIBLE_HISTORY);
// Draw the legend
xleft = margin;
@ -445,7 +436,7 @@ void LLFastTimerView::draw()
it != timer_tree_iterator_t();
++it)
{
LLFastTimer::DeclareTimer* idp = (*it);
LLTrace::BlockTimer* idp = (*it);
const F32 HUE_INCREMENT = 0.23f;
hue = fmodf(hue + HUE_INCREMENT, 1.f);
@ -465,12 +456,12 @@ void LLFastTimerView::draw()
LLLocalClipRect clip(LLRect(margin, y, LEGEND_WIDTH, margin));
S32 cur_line = 0;
ft_display_idx.clear();
std::map<LLFastTimer::DeclareTimer*, S32> display_line;
std::map<LLTrace::BlockTimer*, S32> display_line;
for (timer_tree_iterator_t it = begin_timer_tree(getFrameTimer());
it != timer_tree_iterator_t();
++it)
{
LLFastTimer::DeclareTimer* idp = (*it);
LLTrace::BlockTimer* idp = (*it);
display_line[idp] = cur_line;
ft_display_idx.push_back(idp);
cur_line++;
@ -490,7 +481,7 @@ void LLFastTimerView::draw()
S32 calls = 0;
if (mHoverBarIndex > 0 && mHoverID)
{
S32 hidx = LLFastTimer::DeclareTimer::HISTORY_NUM - mScrollIndex - mHoverBarIndex;
S32 hidx = LLTrace::BlockTimer::HISTORY_NUM - mScrollIndex - mHoverBarIndex;
U64 ticks = idp->getHistoricalCount(hidx);
ms = (F32)((F64)ticks * iclock_freq);
calls = (S32)idp->getHistoricalCalls(hidx);
@ -528,7 +519,7 @@ void LLFastTimerView::draw()
x += dx;
BOOL is_child_of_hover_item = (idp == mHoverID);
LLFastTimer::DeclareTimer* next_parent = idp->getParent();
LLTrace::BlockTimer* next_parent = idp->getParent();
while(!is_child_of_hover_item && next_parent)
{
is_child_of_hover_item = (mHoverID == next_parent);
@ -570,18 +561,18 @@ void LLFastTimerView::draw()
barw = width - xleft - margin;
// Draw the history bars
if (LLFastTimer::getLastFrameIndex() >= 0)
if (LLTrace::BlockTimer::getLastFrameIndex() >= 0)
{
LLLocalClipRect clip(LLRect(xleft, ytop, getRect().getWidth() - margin, margin));
U64 totalticks;
if (!LLFastTimer::sPauseHistory)
if (!LLTrace::BlockTimer::sPauseHistory)
{
U64 ticks = getFrameTimer().getHistoricalCount(mScrollIndex);
if (LLFastTimer::getCurFrameIndex() >= 10)
if (LLTrace::BlockTimer::getCurFrameIndex() >= 10)
{
U64 framec = LLFastTimer::getCurFrameIndex();
U64 framec = LLTrace::BlockTimer::getCurFrameIndex();
U64 avg = (U64)mAvgCountTotal;
mAvgCountTotal = (avg*framec + ticks) / (framec + 1);
if (ticks > mMaxCountTotal)
@ -592,14 +583,14 @@ void LLFastTimerView::draw()
if (ticks < mAvgCountTotal/100 || ticks > mAvgCountTotal*100)
{
LLFastTimer::sResetHistory = true;
LLTrace::BlockTimer::sResetHistory = true;
}
if (LLFastTimer::getCurFrameIndex() < 10 || LLFastTimer::sResetHistory)
if (LLTrace::BlockTimer::getCurFrameIndex() < 10 || LLTrace::BlockTimer::sResetHistory)
{
mAvgCountTotal = ticks;
mMaxCountTotal = ticks;
LLFastTimer::sResetHistory = false;
LLTrace::BlockTimer::sResetHistory = false;
}
}
@ -706,7 +697,7 @@ void LLFastTimerView::draw()
S32 tidx;
if (j >= 0)
{
tidx = LLFastTimer::DeclareTimer::HISTORY_NUM - j - 1 - mScrollIndex;
tidx = LLTrace::BlockTimer::HISTORY_NUM - j - 1 - mScrollIndex;
}
else
{
@ -720,14 +711,14 @@ void LLFastTimerView::draw()
std::vector<S32> deltax;
xpos.push_back(xleft);
LLFastTimer::DeclareTimer* prev_id = NULL;
LLTrace::BlockTimer* prev_id = NULL;
S32 i = 0;
for(timer_tree_iterator_t it = begin_timer_tree(getFrameTimer());
it != end_timer_tree();
++it, ++i)
{
LLFastTimer::DeclareTimer* idp = (*it);
LLTrace::BlockTimer* idp = (*it);
F32 frac = tidx == -1
? (F32)idp->getCountAverage() / (F32)totalticks
: (F32)idp->getHistoricalCount(tidx) / (F32)totalticks;
@ -754,7 +745,7 @@ void LLFastTimerView::draw()
{
U64 sublevelticks = 0;
for (LLFastTimer::DeclareTimer::child_const_iter it = prev_id->beginChildren();
for (LLTrace::BlockTimer::child_const_iter it = prev_id->beginChildren();
it != prev_id->endChildren();
++it)
{
@ -796,7 +787,7 @@ void LLFastTimerView::draw()
S32 scale_offset = 0;
BOOL is_child_of_hover_item = (idp == mHoverID);
LLFastTimer::DeclareTimer* next_parent = idp->getParent();
LLTrace::BlockTimer* next_parent = idp->getParent();
while(!is_child_of_hover_item && next_parent)
{
is_child_of_hover_item = (mHoverID == next_parent);
@ -861,10 +852,10 @@ void LLFastTimerView::draw()
//highlight visible range
{
S32 first_frame = LLFastTimer::DeclareTimer::HISTORY_NUM - mScrollIndex;
S32 first_frame = LLTrace::BlockTimer::HISTORY_NUM - mScrollIndex;
S32 last_frame = first_frame - MAX_VISIBLE_HISTORY;
F32 frame_delta = ((F32) (mGraphRect.getWidth()))/(LLFastTimer::DeclareTimer::HISTORY_NUM-1);
F32 frame_delta = ((F32) (mGraphRect.getWidth()))/(LLTrace::BlockTimer::HISTORY_NUM-1);
F32 right = (F32) mGraphRect.mLeft + frame_delta*first_frame;
F32 left = (F32) mGraphRect.mLeft + frame_delta*last_frame;
@ -891,7 +882,7 @@ void LLFastTimerView::draw()
it != end_timer_tree();
++it)
{
LLFastTimer::DeclareTimer* idp = (*it);
LLTrace::BlockTimer* idp = (*it);
//fatten highlighted timer
if (mHoverID == idp)
@ -915,8 +906,8 @@ void LLFastTimerView::draw()
gGL.color4f(col[0], col[1], col[2], alpha);
gGL.begin(LLRender::TRIANGLE_STRIP);
for (U32 j = llmax(0, LLFastTimer::DeclareTimer::HISTORY_NUM - LLFastTimer::getLastFrameIndex());
j < LLFastTimer::DeclareTimer::HISTORY_NUM;
for (U32 j = llmax(0, LLTrace::BlockTimer::HISTORY_NUM - LLTrace::BlockTimer::getLastFrameIndex());
j < LLTrace::BlockTimer::HISTORY_NUM;
j++)
{
U64 ticks = idp->getHistoricalCount(j);
@ -937,7 +928,7 @@ void LLFastTimerView::draw()
//normalize to highlighted timer
cur_max = llmax(cur_max, ticks);
}
F32 x = mGraphRect.mLeft + ((F32) (mGraphRect.getWidth()))/(LLFastTimer::DeclareTimer::HISTORY_NUM-1)*j;
F32 x = mGraphRect.mLeft + ((F32) (mGraphRect.getWidth()))/(LLTrace::BlockTimer::HISTORY_NUM-1)*j;
F32 y = mGraphRect.mBottom + (F32) mGraphRect.getHeight()/max_ticks*ticks;
gGL.vertex2f(x,y);
gGL.vertex2f(x,mGraphRect.mBottom);
@ -992,7 +983,7 @@ void LLFastTimerView::draw()
it != end_timer_tree();
++it)
{
LLFastTimer::DeclareTimer* idp = (*it);
LLTrace::BlockTimer* idp = (*it);
if (!first)
{
@ -1014,7 +1005,7 @@ void LLFastTimerView::draw()
it != end_timer_tree();
++it)
{
LLFastTimer::DeclareTimer* idp = (*it);
LLTrace::BlockTimer* idp = (*it);
if (!first)
{
@ -1551,13 +1542,13 @@ void LLFastTimerView::outputAllMetrics()
//static
void LLFastTimerView::doAnalysis(std::string baseline, std::string target, std::string output)
{
if(LLFastTimer::sLog)
if(LLTrace::BlockTimer::sLog)
{
doAnalysisDefault(baseline, target, output) ;
return ;
}
if(LLFastTimer::sMetricLog)
if(LLTrace::BlockTimer::sMetricLog)
{
LLMetricPerformanceTesterBasic::doAnalysisMetrics(baseline, target, output) ;
return ;
@ -1568,7 +1559,7 @@ void LLFastTimerView::onClickCloseBtn()
setVisible(false);
}
LLFastTimer::DeclareTimer& LLFastTimerView::getFrameTimer()
LLTrace::BlockTimer& LLFastTimerView::getFrameTimer()
{
return FTM_FRAME;
}

View File

@ -46,7 +46,7 @@ private:
static LLSD analyzePerformanceLogDefault(std::istream& is) ;
static void exportCharts(const std::string& base, const std::string& target);
void onPause();
LLFastTimer::DeclareTimer& getFrameTimer();
LLTrace::BlockTimer& getFrameTimer();
public:
@ -59,7 +59,7 @@ public:
virtual BOOL handleScrollWheel(S32 x, S32 y, S32 clicks);
virtual void draw();
LLFastTimer::DeclareTimer* getLegendID(S32 y);
LLTrace::BlockTimer* getLegendID(S32 y);
F64 getTime(const std::string& name);
protected:
@ -85,8 +85,8 @@ private:
U64 mMaxCountTotal;
LLRect mBarRect;
S32 mScrollIndex;
LLFastTimer::DeclareTimer* mHoverID;
LLFastTimer::DeclareTimer* mHoverTimer;
LLTrace::BlockTimer* mHoverID;
LLTrace::BlockTimer* mHoverTimer;
LLRect mToolTipRect;
S32 mHoverBarIndex;
LLFrameTimer mHighlightTimer;

View File

@ -31,6 +31,7 @@
#include "llassetstorage.h"
#include "llinventorytype.h"
#include "llfilepicker.h"
#include <queue>
class LLTransactionID;