SH-3275 WIP Run viewer metrics for object update messages

cleaned up LLStat and removed unnecessary includes
master
Richard Linden 2012-08-07 19:55:47 -07:00
parent 5564fcb271
commit c8a36e9cfd
13 changed files with 108 additions and 331 deletions

View File

@ -42,25 +42,25 @@ LLStat::stat_map_t LLStat::sStatList;
LLTimer LLStat::sTimer;
LLFrameTimer LLStat::sFrameTimer;
void LLStat::init()
void LLStat::reset()
{
llassert(mNumBins > 0);
mNumValues = 0;
mLastValue = 0.f;
mLastTime = 0.f;
mCurBin = (mNumBins-1);
delete[] mBins;
mBins = new ValueEntry[mNumBins];
mCurBin = mNumBins-1;
mNextBin = 0;
mBins = new F32[mNumBins];
mBeginTime = new F64[mNumBins];
mTime = new F64[mNumBins];
mDT = new F32[mNumBins];
for (U32 i = 0; i < mNumBins; i++)
{
mBins[i] = 0.f;
mBeginTime[i] = 0.0;
mTime[i] = 0.0;
mDT[i] = 0.f;
}
}
LLStat::LLStat(std::string name, S32 num_bins, BOOL use_frame_timer)
: mUseFrameTimer(use_frame_timer),
mNumBins(num_bins),
mName(name)
{
llassert(mNumBins > 0);
mLastTime = 0.f;
reset();
if (!mName.empty())
{
@ -71,27 +71,9 @@ void LLStat::init()
}
}
LLStat::LLStat(const U32 num_bins, const BOOL use_frame_timer)
: mUseFrameTimer(use_frame_timer),
mNumBins(num_bins)
{
init();
}
LLStat::LLStat(std::string name, U32 num_bins, BOOL use_frame_timer)
: mUseFrameTimer(use_frame_timer),
mNumBins(num_bins),
mName(name)
{
init();
}
LLStat::~LLStat()
{
delete[] mBins;
delete[] mBeginTime;
delete[] mTime;
delete[] mDT;
if (!mName.empty())
{
@ -103,76 +85,15 @@ LLStat::~LLStat()
}
}
void LLStat::reset()
{
U32 i;
mNumValues = 0;
mLastValue = 0.f;
mCurBin = (mNumBins-1);
delete[] mBins;
delete[] mBeginTime;
delete[] mTime;
delete[] mDT;
mBins = new F32[mNumBins];
mBeginTime = new F64[mNumBins];
mTime = new F64[mNumBins];
mDT = new F32[mNumBins];
for (i = 0; i < mNumBins; i++)
{
mBins[i] = 0.f;
mBeginTime[i] = 0.0;
mTime[i] = 0.0;
mDT[i] = 0.f;
}
}
void LLStat::setBeginTime(const F64 time)
{
mBeginTime[mNextBin] = time;
}
void LLStat::addValueTime(const F64 time, const F32 value)
{
if (mNumValues < mNumBins)
{
mNumValues++;
}
// Increment the bin counters.
mCurBin++;
if ((U32)mCurBin == mNumBins)
{
mCurBin = 0;
}
mNextBin++;
if ((U32)mNextBin == mNumBins)
{
mNextBin = 0;
}
mBins[mCurBin] = value;
mTime[mCurBin] = time;
mDT[mCurBin] = (F32)(mTime[mCurBin] - mBeginTime[mCurBin]);
//this value is used to prime the min/max calls
mLastTime = mTime[mCurBin];
mLastValue = value;
// Set the begin time for the next stat segment.
mBeginTime[mNextBin] = mTime[mCurBin];
mTime[mNextBin] = mTime[mCurBin];
mDT[mNextBin] = 0.f;
}
void LLStat::start()
{
if (mUseFrameTimer)
{
mBeginTime[mNextBin] = sFrameTimer.getElapsedSeconds();
mBins[mNextBin].mBeginTime = sFrameTimer.getElapsedSeconds();
}
else
{
mBeginTime[mNextBin] = sTimer.getElapsedTimeF64();
mBins[mNextBin].mBeginTime = sTimer.getElapsedTimeF64();
}
}
@ -185,41 +106,41 @@ void LLStat::addValue(const F32 value)
// Increment the bin counters.
mCurBin++;
if ((U32)mCurBin == mNumBins)
if (mCurBin >= mNumBins)
{
mCurBin = 0;
}
mNextBin++;
if ((U32)mNextBin == mNumBins)
if (mNextBin >= mNumBins)
{
mNextBin = 0;
}
mBins[mCurBin] = value;
mBins[mCurBin].mValue = value;
if (mUseFrameTimer)
{
mTime[mCurBin] = sFrameTimer.getElapsedSeconds();
mBins[mCurBin].mTime = sFrameTimer.getElapsedSeconds();
}
else
{
mTime[mCurBin] = sTimer.getElapsedTimeF64();
mBins[mCurBin].mTime = sTimer.getElapsedTimeF64();
}
mDT[mCurBin] = (F32)(mTime[mCurBin] - mBeginTime[mCurBin]);
mBins[mCurBin].mDT = (F32)(mBins[mCurBin].mTime - mBins[mCurBin].mBeginTime);
//this value is used to prime the min/max calls
mLastTime = mTime[mCurBin];
mLastTime = mBins[mCurBin].mTime;
mLastValue = value;
// Set the begin time for the next stat segment.
mBeginTime[mNextBin] = mTime[mCurBin];
mTime[mNextBin] = mTime[mCurBin];
mDT[mNextBin] = 0.f;
mBins[mNextBin].mBeginTime = mBins[mCurBin].mTime;
mBins[mNextBin].mTime = mBins[mCurBin].mTime;
mBins[mNextBin].mDT = 0.f;
}
F32 LLStat::getMax() const
{
U32 i;
S32 i;
F32 current_max = mLastValue;
if (mNumBins == 0)
{
@ -230,13 +151,13 @@ F32 LLStat::getMax() const
for (i = 0; (i < mNumBins) && (i < mNumValues); i++)
{
// Skip the bin we're currently filling.
if (i == (U32)mNextBin)
if (i == mNextBin)
{
continue;
}
if (mBins[i] > current_max)
if (mBins[i].mValue > current_max)
{
current_max = mBins[i];
current_max = mBins[i].mValue;
}
}
}
@ -245,17 +166,17 @@ F32 LLStat::getMax() const
F32 LLStat::getMean() const
{
U32 i;
S32 i;
F32 current_mean = 0.f;
U32 samples = 0;
S32 samples = 0;
for (i = 0; (i < mNumBins) && (i < mNumValues); i++)
{
// Skip the bin we're currently filling.
if (i == (U32)mNextBin)
if (i == mNextBin)
{
continue;
}
current_mean += mBins[i];
current_mean += mBins[i].mValue;
samples++;
}
@ -273,7 +194,7 @@ F32 LLStat::getMean() const
F32 LLStat::getMin() const
{
U32 i;
S32 i;
F32 current_min = mLastValue;
if (mNumBins == 0)
@ -285,53 +206,19 @@ F32 LLStat::getMin() const
for (i = 0; (i < mNumBins) && (i < mNumValues); i++)
{
// Skip the bin we're currently filling.
if (i == (U32)mNextBin)
if (i == mNextBin)
{
continue;
}
if (mBins[i] < current_min)
if (mBins[i].mValue < current_min)
{
current_min = mBins[i];
current_min = mBins[i].mValue;
}
}
}
return current_min;
}
F32 LLStat::getSum() const
{
U32 i;
F32 sum = 0.f;
for (i = 0; (i < mNumBins) && (i < mNumValues); i++)
{
// Skip the bin we're currently filling.
if (i == (U32)mNextBin)
{
continue;
}
sum += mBins[i];
}
return sum;
}
F32 LLStat::getSumDuration() const
{
U32 i;
F32 sum = 0.f;
for (i = 0; (i < mNumBins) && (i < mNumValues); i++)
{
// Skip the bin we're currently filling.
if (i == (U32)mNextBin)
{
continue;
}
sum += mDT[i];
}
return sum;
}
F32 LLStat::getPrev(S32 age) const
{
S32 bin;
@ -347,7 +234,7 @@ F32 LLStat::getPrev(S32 age) const
// Bogus for bin we're currently working on.
return 0.f;
}
return mBins[bin];
return mBins[bin].mValue;
}
F32 LLStat::getPrevPerSec(S32 age) const
@ -365,107 +252,34 @@ F32 LLStat::getPrevPerSec(S32 age) const
// Bogus for bin we're currently working on.
return 0.f;
}
return mBins[bin] / mDT[bin];
}
F64 LLStat::getPrevBeginTime(S32 age) const
{
S32 bin;
bin = mCurBin - age;
while (bin < 0)
{
bin += mNumBins;
}
if (bin == mNextBin)
{
// Bogus for bin we're currently working on.
return 0.f;
}
return mBeginTime[bin];
}
F64 LLStat::getPrevTime(S32 age) const
{
S32 bin;
bin = mCurBin - age;
while (bin < 0)
{
bin += mNumBins;
}
if (bin == mNextBin)
{
// Bogus for bin we're currently working on.
return 0.f;
}
return mTime[bin];
}
F32 LLStat::getBin(S32 bin) const
{
return mBins[bin];
}
F32 LLStat::getBinPerSec(S32 bin) const
{
return mBins[bin] / mDT[bin];
}
F64 LLStat::getBinBeginTime(S32 bin) const
{
return mBeginTime[bin];
}
F64 LLStat::getBinTime(S32 bin) const
{
return mTime[bin];
return mBins[bin].mValue / mBins[bin].mDT;
}
F32 LLStat::getCurrent() const
{
return mBins[mCurBin];
return mBins[mCurBin].mValue;
}
F32 LLStat::getCurrentPerSec() const
{
return mBins[mCurBin] / mDT[mCurBin];
}
F64 LLStat::getCurrentBeginTime() const
{
return mBeginTime[mCurBin];
}
F64 LLStat::getCurrentTime() const
{
return mTime[mCurBin];
}
F32 LLStat::getCurrentDuration() const
{
return mDT[mCurBin];
return mBins[mCurBin].mValue / mBins[mCurBin].mDT;
}
F32 LLStat::getMeanPerSec() const
{
U32 i;
S32 i;
F32 value = 0.f;
F32 dt = 0.f;
for (i = 0; (i < mNumBins) && (i < mNumValues); i++)
{
// Skip the bin we're currently filling.
if (i == (U32)mNextBin)
if (i == mNextBin)
{
continue;
}
value += mBins[i];
dt += mDT[i];
value += mBins[i].mValue;
dt += mBins[i].mDT;
}
if (dt > 0.f)
@ -481,14 +295,14 @@ F32 LLStat::getMeanPerSec() const
F32 LLStat::getMeanDuration() const
{
F32 dur = 0.0f;
U32 count = 0;
for (U32 i=0; (i < mNumBins) && (i < mNumValues); i++)
S32 count = 0;
for (S32 i=0; (i < mNumBins) && (i < mNumValues); i++)
{
if (i == (U32)mNextBin)
if (i == mNextBin)
{
continue;
}
dur += mDT[i];
dur += mBins[i].mDT;
count++;
}
@ -505,46 +319,45 @@ F32 LLStat::getMeanDuration() const
F32 LLStat::getMaxPerSec() const
{
U32 i;
F32 value;
if (mNextBin != 0)
{
value = mBins[0]/mDT[0];
value = mBins[0].mValue/mBins[0].mDT;
}
else if (mNumValues > 0)
{
value = mBins[1]/mDT[1];
value = mBins[1].mValue/mBins[1].mDT;
}
else
{
value = 0.f;
}
for (i = 0; (i < mNumBins) && (i < mNumValues); i++)
for (S32 i = 0; (i < mNumBins) && (i < mNumValues); i++)
{
// Skip the bin we're currently filling.
if (i == (U32)mNextBin)
if (i == mNextBin)
{
continue;
}
value = llmax(value, mBins[i]/mDT[i]);
value = llmax(value, mBins[i].mValue/mBins[i].mDT);
}
return value;
}
F32 LLStat::getMinPerSec() const
{
U32 i;
S32 i;
F32 value;
if (mNextBin != 0)
{
value = mBins[0]/mDT[0];
value = mBins[0].mValue/mBins[0].mDT;
}
else if (mNumValues > 0)
{
value = mBins[1]/mDT[1];
value = mBins[1].mValue/mBins[0].mDT;
}
else
{
@ -554,25 +367,15 @@ F32 LLStat::getMinPerSec() const
for (i = 0; (i < mNumBins) && (i < mNumValues); i++)
{
// Skip the bin we're currently filling.
if (i == (U32)mNextBin)
if (i == mNextBin)
{
continue;
}
value = llmin(value, mBins[i]/mDT[i]);
value = llmin(value, mBins[i].mValue/mBins[i].mDT);
}
return value;
}
F32 LLStat::getMinDuration() const
{
F32 dur = 0.0f;
for (U32 i=0; (i < mNumBins) && (i < mNumValues); i++)
{
dur = llmin(dur, mDT[i]);
}
return dur;
}
U32 LLStat::getNumValues() const
{
return mNumValues;
@ -583,11 +386,6 @@ S32 LLStat::getNumBins() const
return mNumBins;
}
S32 LLStat::getCurBin() const
{
return mCurBin;
}
S32 LLStat::getNextBin() const
{
return mNextBin;

View File

@ -27,12 +27,10 @@
#ifndef LL_LLSTAT_H
#define LL_LLSTAT_H
#include <deque>
#include <map>
#include "lltimer.h"
#include "llframetimer.h"
#include "llfile.h"
class LLSD;
@ -43,56 +41,31 @@ private:
typedef std::multimap<std::string, LLStat*> stat_map_t;
static stat_map_t sStatList;
void init();
public:
LLStat(U32 num_bins = 32, BOOL use_frame_timer = FALSE);
LLStat(std::string name, U32 num_bins = 32, BOOL use_frame_timer = FALSE);
LLStat(std::string name = std::string(), S32 num_bins = 32, BOOL use_frame_timer = FALSE);
~LLStat();
void reset();
void start(); // Start the timer for the current "frame", otherwise uses the time tracked from
// the last addValue
void reset();
void addValue(const F32 value = 1.f); // Adds the current value being tracked, and tracks the DT.
void addValue(const S32 value) { addValue((F32)value); }
void addValue(const U32 value) { addValue((F32)value); }
void setBeginTime(const F64 time);
void addValueTime(const F64 time, const F32 value = 1.f);
S32 getCurBin() const;
S32 getNextBin() const;
F32 getCurrent() const;
F32 getCurrentPerSec() const;
F64 getCurrentBeginTime() const;
F64 getCurrentTime() const;
F32 getCurrentDuration() const;
F32 getPrev(S32 age) const; // Age is how many "addValues" previously - zero is current
F32 getPrevPerSec(S32 age) const; // Age is how many "addValues" previously - zero is current
F64 getPrevBeginTime(S32 age) const;
F64 getPrevTime(S32 age) const;
F32 getBin(S32 bin) const;
F32 getBinPerSec(S32 bin) const;
F64 getBinBeginTime(S32 bin) const;
F64 getBinTime(S32 bin) const;
F32 getMax() const;
F32 getMaxPerSec() const;
F32 getCurrent() const;
F32 getCurrentPerSec() const;
F32 getMin() const;
F32 getMinPerSec() const;
F32 getMean() const;
F32 getMeanPerSec() const;
F32 getMeanDuration() const;
F32 getMin() const;
F32 getMinPerSec() const;
F32 getMinDuration() const;
F32 getSum() const;
F32 getSumDuration() const;
F32 getMax() const;
F32 getMaxPerSec() const;
U32 getNumValues() const;
S32 getNumBins() const;
@ -104,10 +77,21 @@ private:
U32 mNumBins;
F32 mLastValue;
F64 mLastTime;
F32 *mBins;
F64 *mBeginTime;
F64 *mTime;
F32 *mDT;
struct ValueEntry
{
ValueEntry()
: mValue(0.f),
mBeginTime(0.0),
mTime(0.0),
mDT(0.f)
{}
F32 mValue;
F64 mBeginTime;
F64 mTime;
F32 mDT;
};
ValueEntry* mBins;
S32 mCurBin;
S32 mNextBin;

View File

@ -40,7 +40,6 @@
#include "llpacketack.h"
#include "lluuid.h"
#include "llthrottle.h"
#include "llstat.h"
//
// Constants

View File

@ -42,7 +42,6 @@
#include "llpumpio.h"
#include "llsd.h"
#include "llsdserialize_xml.h"
#include "llstat.h"
#include "llstl.h"
#include "lltimer.h"

View File

@ -29,7 +29,6 @@
#include "lldarray.h"
#include "message.h" // TODO: babbage: Remove...
#include "llstat.h"
#include "llstl.h"
class LLMsgVarData

View File

@ -36,7 +36,6 @@
#include "llapr.h"
#include "llmemtype.h"
#include "llstl.h"
#include "llstat.h"
// These should not be enabled in production, but they can be
// intensely useful during development for finding certain kinds of

View File

@ -33,6 +33,7 @@
#include "llerror.h"
#include "llrect.h"
#include "llstring.h"
#include "llstat.h"
// project includes
#include "lluictrlfactory.h"
@ -83,7 +84,8 @@ BOOL LLFloaterJoystick::postBuild()
for (U32 i = 0; i < 6; i++)
{
mAxisStats[i] = new LLStat(4);
std::string stat_name(llformat("Joystick axis %d", i));
mAxisStats[i] = new LLStat(stat_name, 4);
std::string axisname = llformat("axis%d", i);
mAxisStatsBar[i] = getChild<LLStatBar>(axisname);
if (mAxisStatsBar[i])

View File

@ -35,6 +35,7 @@
#include "lltextureinfo.h"
#include "llapr.h"
#include "llimageworker.h"
#include "llstat.h"
//#include "lltexturecache.h"
class LLViewerTexture;

View File

@ -120,11 +120,11 @@ public:
protected:
void calcProjection(const F32 far_distance) const;
LLStat mVelocityStat;
LLStat mAngularVelocityStat;
LLVector3 mVelocityDir ;
F32 mAverageSpeed ;
F32 mAverageAngularSpeed ;
LLStat mVelocityStat;
LLStat mAngularVelocityStat;
LLVector3 mVelocityDir ;
F32 mAverageSpeed ;
F32 mAverageAngularSpeed ;
mutable LLMatrix4 mProjectionMatrix; // Cache of perspective matrix
mutable LLMatrix4 mModelviewMatrix;

View File

@ -59,8 +59,6 @@
#include "indra_constants.h"
#include "llinitparam.h"
//#include "linden_common.h"
//#include "llpreprocessor.h"
#include "llallocator.h"
#include "llapp.h"
#include "llcriticaldamp.h"
@ -77,10 +75,8 @@
#include "llprocessor.h"
#include "llrefcount.h"
#include "llsafehandle.h"
//#include "llsecondlifeurls.h"
#include "llsd.h"
#include "llsingleton.h"
#include "llstat.h"
#include "llstl.h"
#include "llstrider.h"
#include "llstring.h"
@ -88,11 +84,8 @@
#include "llthread.h"
#include "lltimer.h"
#include "lluuidhashmap.h"
//#include "processor.h"
#include "stdenums.h"
#include "stdtypes.h"
//#include "string_table.h"
//#include "timer.h"
#include "timing.h"
#include "u64.h"

View File

@ -67,12 +67,12 @@ void (*LLViewerTextureList::sUUIDCallback)(void **, const LLUUID&) = NULL;
U32 LLViewerTextureList::sTextureBits = 0;
U32 LLViewerTextureList::sTexturePackets = 0;
S32 LLViewerTextureList::sNumImages = 0;
LLStat LLViewerTextureList::sNumImagesStat(32, TRUE);
LLStat LLViewerTextureList::sNumRawImagesStat(32, TRUE);
LLStat LLViewerTextureList::sGLTexMemStat(32, TRUE);
LLStat LLViewerTextureList::sGLBoundMemStat(32, TRUE);
LLStat LLViewerTextureList::sRawMemStat(32, TRUE);
LLStat LLViewerTextureList::sFormattedMemStat(32, TRUE);
LLStat LLViewerTextureList::sNumImagesStat("Num Images", 32, TRUE);
LLStat LLViewerTextureList::sNumRawImagesStat("Num Raw Images", 32, TRUE);
LLStat LLViewerTextureList::sGLTexMemStat("GL Texture Mem", 32, TRUE);
LLStat LLViewerTextureList::sGLBoundMemStat("GL Bound Mem", 32, TRUE);
LLStat LLViewerTextureList::sRawMemStat("Raw Image Mem", 32, TRUE);
LLStat LLViewerTextureList::sFormattedMemStat("Formatted Image Mem", 32, TRUE);
LLViewerTextureList gTextureList;
static LLFastTimer::DeclareTimer FTM_PROCESS_IMAGES("Process Images");

View File

@ -77,6 +77,7 @@
#include "llmediaentry.h"
#include "llurldispatcher.h"
#include "raytrace.h"
#include "llstat.h"
// newview includes
#include "llagent.h"
@ -1540,7 +1541,8 @@ LLViewerWindow::LLViewerWindow(const Params& p)
mResDirty(false),
mStatesDirty(false),
mCurrResolutionIndex(0),
mProgressView(NULL)
mProgressView(NULL),
mMouseVelocityStat(new LLStat("Mouse Velocity"))
{
// gKeyboard is still NULL, so it doesn't do LLWindowListener any good to
// pass its value right now. Instead, pass it a nullary function that
@ -2064,6 +2066,8 @@ LLViewerWindow::~LLViewerWindow()
delete mDebugText;
mDebugText = NULL;
delete mMouseVelocityStat;
}
@ -3238,7 +3242,7 @@ void LLViewerWindow::updateMouseDelta()
mouse_vel.setVec((F32) dx, (F32) dy);
}
mMouseVelocityStat.addValue(mouse_vel.magVec());
mMouseVelocityStat->addValue(mouse_vel.magVec());
}
void LLViewerWindow::updateKeyboardFocus()

View File

@ -41,7 +41,6 @@
#include "llcursortypes.h"
#include "llwindowcallbacks.h"
#include "lltimer.h"
#include "llstat.h"
#include "llmousehandler.h"
#include "llhandle.h"
#include "llinitparam.h"
@ -50,7 +49,7 @@
#include <boost/signals2.hpp>
#include <boost/scoped_ptr.hpp>
class LLStat;
class LLView;
class LLViewerObject;
class LLUUID;
@ -251,7 +250,7 @@ public:
S32 getCurrentMouseDX() const { return mCurrentMouseDelta.mX; }
S32 getCurrentMouseDY() const { return mCurrentMouseDelta.mY; }
LLCoordGL getCurrentMouseDelta() const { return mCurrentMouseDelta; }
LLStat * getMouseVelocityStat() { return &mMouseVelocityStat; }
LLStat* getMouseVelocityStat() { return mMouseVelocityStat; }
BOOL getLeftMouseDown() const { return mLeftMouseDown; }
BOOL getMiddleMouseDown() const { return mMiddleMouseDown; }
BOOL getRightMouseDown() const { return mRightMouseDown; }
@ -428,7 +427,7 @@ private:
LLCoordGL mCurrentMousePoint; // last mouse position in GL coords
LLCoordGL mLastMousePoint; // Mouse point at last frame.
LLCoordGL mCurrentMouseDelta; //amount mouse moved this frame
LLStat mMouseVelocityStat;
LLStat* mMouseVelocityStat;
BOOL mLeftMouseDown;
BOOL mMiddleMouseDown;
BOOL mRightMouseDown;