diff options
| author | Richard Linden <none@none> | 2012-11-01 17:52:11 -0700 | 
|---|---|---|
| committer | Richard Linden <none@none> | 2012-11-01 17:52:11 -0700 | 
| commit | 74fe126590fba03752d1d8d88dd3bb59c6900026 (patch) | |
| tree | 8ce225ede4db348ce7ae1a576da4ed98da54a40a | |
| parent | 3ccbce90e37b92d5b32a2507804adc91bc58065d (diff) | |
SH-3405 FIX convert existing stats to lltrace system
output of floater_stats is now identical to pre-lltrace system (with some tweaks)
| -rw-r--r-- | indra/llcommon/lltrace.h | 95 | ||||
| -rw-r--r-- | indra/llcommon/lltracerecording.cpp | 34 | ||||
| -rw-r--r-- | indra/llcommon/lltracerecording.h | 6 | ||||
| -rw-r--r-- | indra/llcommon/lltracethreadrecorder.cpp | 6 | ||||
| -rw-r--r-- | indra/llui/llstatbar.cpp | 6 | ||||
| -rw-r--r-- | indra/llui/llstatbar.h | 5 | ||||
| -rw-r--r-- | indra/newview/llviewercamera.cpp | 1 | ||||
| -rw-r--r-- | indra/newview/llworld.cpp | 1 | ||||
| -rw-r--r-- | indra/newview/pipeline.cpp | 4 | ||||
| -rw-r--r-- | indra/newview/skins/default/xui/en/floater_stats.xml | 16 | 
10 files changed, 108 insertions, 66 deletions
| diff --git a/indra/llcommon/lltrace.h b/indra/llcommon/lltrace.h index 2823db5cbb..735c45754c 100644 --- a/indra/llcommon/lltrace.h +++ b/indra/llcommon/lltrace.h @@ -138,11 +138,11 @@ namespace LLTrace  			}  		} -		void reset() +		void reset(const AccumulatorBuffer<ACCUMULATOR>* other = NULL)  		{  			for (size_t i = 0; i < mNextStorageSlot; i++)  			{ -				mStorage[i].reset(); +				mStorage[i].reset(other ? &other->mStorage[i] : NULL);  			}  		} @@ -285,54 +285,60 @@ namespace LLTrace  		void addSamples(const self_t& other)  		{ -			mSum += other.mSum; -			if (other.mMin < mMin) -			{ -				mMin = other.mMin; -			} -			if (other.mMax > mMax) -			{ -				mMax = other.mMax; -			} -			mNumSamples += other.mNumSamples; -			F64 weight = (F64)mNumSamples / (F64)(mNumSamples + other.mNumSamples); -			mMean = mMean * weight + other.mMean * (1.f - weight); - -			F64 n_1 = (F64)mNumSamples, -				n_2 = (F64)other.mNumSamples; -			F64 m_1 = mMean, -				m_2 = other.mMean; -			F64 sd_1 = getStandardDeviation(), -				sd_2 = other.getStandardDeviation(); -			// combine variance (and hence standard deviation) of 2 different sized sample groups using -			// the following formula: http://www.mrc-bsu.cam.ac.uk/cochrane/handbook/chapter_7/7_7_3_8_combining_groups.htm -			if (n_1 == 0) +			if (other.mNumSamples)  			{ -				mVarianceSum = other.mVarianceSum; +				mSum += other.mSum; +				if (other.mMin < mMin) +				{ +					mMin = other.mMin; +				} +				if (other.mMax > mMax) +				{ +					mMax = other.mMax; +				} +				F64 weight = (F64)mNumSamples / (F64)(mNumSamples + other.mNumSamples); +				mNumSamples += other.mNumSamples; +				mMean = mMean * weight + other.mMean * (1.f - weight); + +				F64 n_1 = (F64)mNumSamples, +					n_2 = (F64)other.mNumSamples; +				F64 m_1 = mMean, +					m_2 = other.mMean; +				F64 sd_1 = getStandardDeviation(), +					sd_2 = other.getStandardDeviation(); +				// combine variance (and hence standard deviation) of 2 different sized sample groups using +				// the following formula: http://www.mrc-bsu.cam.ac.uk/cochrane/handbook/chapter_7/7_7_3_8_combining_groups.htm +				if (n_1 == 0) +				{ +					mVarianceSum = other.mVarianceSum; +				} +				else if (n_2 == 0) +				{ +					// don't touch variance +					// mVarianceSum = mVarianceSum; +				} +				else +				{ +					mVarianceSum =  (F64)mNumSamples +								* ((((n_1 - 1.f) * sd_1 * sd_1) +									+ ((n_2 - 1.f) * sd_2 * sd_2) +									+ (((n_1 * n_2) / (n_1 + n_2)) +										* ((m_1 * m_1) + (m_2 * m_2) - (2.f * m_1 * m_2)))) +								/ (n_1 + n_2 - 1.f)); +				} +				mLastValue = other.mLastValue;  			} -			else if (n_2 == 0) -			{ -				// don't touch variance -				// mVarianceSum = mVarianceSum; -			} -			else -			{ -				mVarianceSum =  (F64)mNumSamples -							* ((((n_1 - 1.f) * sd_1 * sd_1) -								+ ((n_2 - 1.f) * sd_2 * sd_2) -								+ (((n_1 * n_2) / (n_1 + n_2)) -									* ((m_1 * m_1) + (m_2 * m_2) - (2.f * m_1 * m_2)))) -							/ (n_1 + n_2 - 1.f)); -			} -			mLastValue = other.mLastValue;  		} -		void reset() +		void reset(const self_t* other)  		{  			mNumSamples = 0;  			mSum = 0;  			mMin = 0;  			mMax = 0; +			mMean = 0; +			mVarianceSum = 0; +			mLastValue = other ? other->mLastValue : 0;  		}  		T	getSum() const { return (T)mSum; } @@ -359,6 +365,7 @@ namespace LLTrace  	class LL_COMMON_API CountAccumulator  	{  	public: +		typedef CountAccumulator<T> self_t;  		typedef T value_t;  		CountAccumulator() @@ -378,7 +385,7 @@ namespace LLTrace  			mNumSamples += other.mNumSamples;  		} -		void reset() +		void reset(const self_t* other)  		{  			mNumSamples = 0;  			mSum = 0; @@ -475,6 +482,8 @@ namespace LLTrace  	class LL_COMMON_API TimerAccumulator  	{  	public: +		typedef TimerAccumulator self_t; +  		U32 							mTotalTimeCounter,  										mChildTimeCounter,  										mCalls; @@ -493,7 +502,7 @@ namespace LLTrace  			mCalls += other.mCalls;  		} -		void reset() +		void reset(const self_t* other)  		{  			mTotalTimeCounter = 0;  			mChildTimeCounter = 0; diff --git a/indra/llcommon/lltracerecording.cpp b/indra/llcommon/lltracerecording.cpp index f44a0a2764..a2733fd0e7 100644 --- a/indra/llcommon/lltracerecording.cpp +++ b/indra/llcommon/lltracerecording.cpp @@ -87,6 +87,8 @@ void Recording::handleSplitTo(Recording& other)  {  	stop();  	other.restart(); +	other.mMeasurementsFloat.write()->reset(mMeasurementsFloat); +	other.mMeasurements.write()->reset(mMeasurements);  } @@ -104,7 +106,7 @@ bool Recording::isPrimary() const  	return mCounts->isPrimary();  } -void Recording::mergeRecording( const Recording& other ) +void Recording::appendRecording( const Recording& other )  {  	mCountsFloat.write()->addSamples(*other.mCountsFloat);  	mMeasurementsFloat.write()->addSamples(*other.mMeasurementsFloat); @@ -138,22 +140,34 @@ S64 Recording::getSum( const TraceType<MeasurementAccumulator<S64> >& stat ) con  F64 Recording::getPerSec( const TraceType<CountAccumulator<F64> >& stat ) const  { -	return stat.getAccumulator(mCountsFloat).getSum() / mElapsedSeconds; +	F64 sum = stat.getAccumulator(mCountsFloat).getSum(); +	return  (sum != 0.0)  +		? (sum / mElapsedSeconds) +		: 0.0;  }  F64 Recording::getPerSec( const TraceType<CountAccumulator<S64> >& stat ) const  { -	return (F64)stat.getAccumulator(mCounts).getSum() / mElapsedSeconds; +	S64 sum = stat.getAccumulator(mCounts).getSum(); +	return (sum != 0)  +		? ((F64)sum / mElapsedSeconds) +		: 0.0;  }  F64 Recording::getPerSec( const TraceType<MeasurementAccumulator<F64> >& stat ) const  { -	return stat.getAccumulator(mMeasurementsFloat).getSum() / mElapsedSeconds; +	F64 sum = stat.getAccumulator(mMeasurementsFloat).getSum(); +	return  (sum != 0.0)  +		? (sum / mElapsedSeconds) +		: 0.0;  }  F64 Recording::getPerSec( const TraceType<MeasurementAccumulator<S64> >& stat ) const  { -	return (F64)stat.getAccumulator(mMeasurements).getSum() / mElapsedSeconds; +	S64 sum = stat.getAccumulator(mMeasurements).getSum(); +	return (sum != 0)  +		? ((F64)sum / mElapsedSeconds) +		: 0.0;  }  F64 Recording::getMin( const TraceType<MeasurementAccumulator<F64> >& stat ) const @@ -240,17 +254,19 @@ PeriodicRecording::~PeriodicRecording()  void PeriodicRecording::nextPeriod()  {  	EPlayState play_state = getPlayState(); -	getCurRecordingPeriod().stop(); +	Recording& old_recording = getCurRecordingPeriod();  	mCurPeriod = (mCurPeriod + 1) % mNumPeriods; +	old_recording.splitTo(getCurRecordingPeriod()); +  	switch(play_state)  	{  	case STOPPED: +		getCurRecordingPeriod().stop();  		break;  	case PAUSED:  		getCurRecordingPeriod().pause();  		break;  	case STARTED: -		getCurRecordingPeriod().start();  		break;  	}  	// new period, need to recalculate total @@ -264,7 +280,7 @@ Recording& PeriodicRecording::getTotalRecording()  		mTotalRecording.reset();  		for (S32 i = mCurPeriod + 1; i < mCurPeriod + mNumPeriods; i++)  		{ -			mTotalRecording.mergeRecording(mRecordingPeriods[i % mNumPeriods]); +			mTotalRecording.appendRecording(mRecordingPeriods[i % mNumPeriods]);  		}  	}  	mTotalValid = true; @@ -298,7 +314,7 @@ void PeriodicRecording::handleSplitTo( PeriodicRecording& other )  void ExtendableRecording::extend()  { -	mAcceptedRecording.mergeRecording(mPotentialRecording); +	mAcceptedRecording.appendRecording(mPotentialRecording);  	mPotentialRecording.reset();  } diff --git a/indra/llcommon/lltracerecording.h b/indra/llcommon/lltracerecording.h index 4af973515d..a11f04b14b 100644 --- a/indra/llcommon/lltracerecording.h +++ b/indra/llcommon/lltracerecording.h @@ -81,12 +81,12 @@ class LLVCRControlsMixin  public:  	void splitTo(DERIVED& other)  	{ -		onSplitTo(other); +		handleSplitTo(other);  	}  	void splitFrom(DERIVED& other)  	{ -		other.onSplitTo(*this); +		other.handleSplitTo(*this);  	}  private:  	// atomically stop this object while starting the other @@ -107,7 +107,7 @@ namespace LLTrace  		void makePrimary();  		bool isPrimary() const; -		void mergeRecording(const Recording& other); +		void appendRecording(const Recording& other);  		void update(); diff --git a/indra/llcommon/lltracethreadrecorder.cpp b/indra/llcommon/lltracethreadrecorder.cpp index 15056b80e4..0feb3ab7af 100644 --- a/indra/llcommon/lltracethreadrecorder.cpp +++ b/indra/llcommon/lltracethreadrecorder.cpp @@ -73,7 +73,7 @@ std::list<ThreadRecorder::ActiveRecording>::iterator ThreadRecorder::update( Rec  		if (next_it != mActiveRecordings.end())  		{  			// ...push our gathered data down to it -			next_it->mBaseline.mergeRecording(it->mBaseline); +			next_it->mBaseline.appendRecording(it->mBaseline);  		}  		// copy accumulated measurements into result buffer and clear accumulator (mBaseline) @@ -153,13 +153,13 @@ void SlaveThreadRecorder::pushToMaster()  void SlaveThreadRecorder::SharedData::copyFrom( const Recording& source )  {  	LLMutexLock lock(&mRecordingMutex); -	mRecording.mergeRecording(source); +	mRecording.appendRecording(source);  }  void SlaveThreadRecorder::SharedData::copyTo( Recording& sink )  {  	LLMutexLock lock(&mRecordingMutex); -	sink.mergeRecording(mRecording); +	sink.appendRecording(mRecording);  }  /////////////////////////////////////////////////////////////////////// diff --git a/indra/llui/llstatbar.cpp b/indra/llui/llstatbar.cpp index 6b40f8d475..1bc9a9fc67 100644 --- a/indra/llui/llstatbar.cpp +++ b/indra/llui/llstatbar.cpp @@ -53,6 +53,7 @@ LLStatBar::LLStatBar(const Params& p)  	  mLabelSpacing(p.label_spacing),  	  mPrecision(p.precision),  	  mUpdatesPerSec(p.update_rate), +	  mUnitScale(p.unit_scale),  	  mPerSec(p.show_per_sec),  	  mDisplayBar(p.show_bar),  	  mDisplayHistory(p.show_history), @@ -148,6 +149,11 @@ void LLStatBar::draw()  		mean = recording.getMean(*mMeasurementIntp);  	} +	current *= mUnitScale; +	min *= mUnitScale; +	max *= mUnitScale; +	mean *= mUnitScale; +  	if ((mUpdatesPerSec == 0.f) || (mUpdateTimer.getElapsedTimeF32() > 1.f/mUpdatesPerSec) || (mValue == 0.f))  	{  		if (mDisplayMean) diff --git a/indra/llui/llstatbar.h b/indra/llui/llstatbar.h index 6aefb1e213..083da8444e 100644 --- a/indra/llui/llstatbar.h +++ b/indra/llui/llstatbar.h @@ -44,7 +44,8 @@ public:  								bar_max,  								tick_spacing,  								label_spacing, -								update_rate; +								update_rate, +								unit_scale;  		Optional<U32>			precision; @@ -64,6 +65,7 @@ public:  			  label_spacing("label_spacing", 10.0f),  			  precision("precision", 0),  			  update_rate("update_rate", 5.0f), +			  unit_scale("unit_scale", 1.f),  			  show_per_sec("show_per_sec", true),  			  show_bar("show_bar", TRUE),  			  show_history("show_history", false), @@ -92,6 +94,7 @@ private:  	F32 mLabelSpacing;  	U32 mPrecision;  	F32 mUpdatesPerSec; +	F32 mUnitScale;  	BOOL mPerSec;				// Use the per sec stats.  	BOOL mDisplayBar;			// Display the bar graph.  	BOOL mDisplayHistory; diff --git a/indra/newview/llviewercamera.cpp b/indra/newview/llviewercamera.cpp index 831304f428..f74897daa7 100644 --- a/indra/newview/llviewercamera.cpp +++ b/indra/newview/llviewercamera.cpp @@ -170,7 +170,6 @@ void LLViewerCamera::updateCameraLocation(const LLVector3 ¢er,  	sVelocityStat.add(dpos);  	sAngularVelocityStat.add(drot); -	LLTrace::Recording& recording = LLTrace::get_frame_recording().getTotalRecording();  	mAverageSpeed = LLTrace::get_frame_recording().getPeriodMeanPerSec(sVelocityStat);  	mAverageAngularSpeed = LLTrace::get_frame_recording().getPeriodMeanPerSec(sAngularVelocityStat);  	mCosHalfCameraFOV = cosf(0.5f * getView() * llmax(1.0f, getAspect())); diff --git a/indra/newview/llworld.cpp b/indra/newview/llworld.cpp index e140f3b23b..126dc59929 100644 --- a/indra/newview/llworld.cpp +++ b/indra/newview/llworld.cpp @@ -711,7 +711,6 @@ void LLWorld::updateNetStats()  	LLStatViewer::PACKETS_IN.add(packets_in);  	LLStatViewer::PACKETS_OUT.add(packets_out);  	LLStatViewer::PACKETS_LOST.add(packets_lost); -	LLStatViewer::PACKETS_LOST_PERCENT.sample(100.f*((F32)packets_lost/(F32)packets_in));  	if (packets_in)  	{  		LLStatViewer::PACKETS_LOST_PERCENT.sample(100.f*((F32)packets_lost/(F32)packets_in)); diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 1e050d2588..bf353cd1e0 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -9754,9 +9754,9 @@ void LLPipeline::generateSunShadow(LLCamera& camera)  	if (gen_shadow)  	{ -		LLTrace::Measurement<>* velocity_stat = LLViewerCamera::getVelocityStat(); +		LLTrace::Count<>* velocity_stat = LLViewerCamera::getVelocityStat();  		F32 fade_amt = gFrameIntervalSeconds.value()  -			* llmax(LLTrace::get_frame_recording().getLastRecordingPeriod().getLastValue(*velocity_stat), 1.0); +			* llmax(LLTrace::get_frame_recording().getLastRecordingPeriod().getSum(*velocity_stat) / LLTrace::get_frame_recording().getLastRecordingPeriod().getDuration().value(), 1.0);  		//update shadow targets  		for (U32 i = 0; i < 2; i++) diff --git a/indra/newview/skins/default/xui/en/floater_stats.xml b/indra/newview/skins/default/xui/en/floater_stats.xml index f9eb16d224..273954ee3e 100644 --- a/indra/newview/skins/default/xui/en/floater_stats.xml +++ b/indra/newview/skins/default/xui/en/floater_stats.xml @@ -104,6 +104,7 @@  				 label="KTris Drawn per Frame"  				 unit_label="/fr"  				 stat="trianglesdrawnstat" +         unit_scale="0.001"  				 bar_min="0"  				 bar_max="10000"  				 tick_spacing="1000" @@ -116,6 +117,7 @@  				 name="ktrissec"  				 label="KTris Drawn per Sec"  				 unit_label="/sec" +         unit_scale="0.001"  				 stat="trianglesdrawnstat"  				 bar_min="0"  				 bar_max="200000" @@ -222,6 +224,8 @@  				 name="gltexmemstat"  				 label="GL Mem"  				 stat="gltexmemstat" +         unit_label="MB" +         unit_scale="0.000001"  				 bar_min="0.f"  				 bar_max="400.f"   				 tick_spacing="100.f" @@ -235,11 +239,13 @@  				 name="formattedmemstat"  				 label="Formatted Mem"  				 stat="formattedmemstat" +         unit_label="MB" +         unit_scale="0.000001"  				 bar_min="0.f"  				 bar_max="400.f"   				 tick_spacing="100.f"  				 label_spacing="200.f"  -				 precision="1" +				 precision="3"  				 show_per_sec="false"            show_bar="false">          </stat_bar> @@ -247,12 +253,14 @@  			  <stat_bar  				 name="rawmemstat"  				 label="Raw Mem" +         unit_label="MB" +         unit_scale="0.000001"  				 stat="rawmemstat"  				 bar_min="0.f"  				 bar_max="400.f"   				 tick_spacing="100.f"  				 label_spacing="200.f"  -				 precision="1" +				 precision="3"  				 show_per_sec="false"            show_bar="false">          </stat_bar> @@ -261,11 +269,13 @@  				 name="glboundmemstat"  				 label="Bound Mem"  				 stat="glboundmemstat" +         unit_label="MB" +         unit_scale="0.000001"  				 bar_min="0.f"  				 bar_max="400.f"   				 tick_spacing="100.f"  				 label_spacing="200.f"  -				 precision="1" +				 precision="3"  				 show_per_sec="false"            show_bar="false">          </stat_bar> | 
