PageRenderTime 44ms CodeModel.GetById 21ms app.highlight 18ms RepoModel.GetById 2ms app.codeStats 0ms

/indra/newview/llviewerstats.h

https://bitbucket.org/lindenlab/viewer-beta/
C++ Header | 298 lines | 230 code | 38 blank | 30 comment | 9 complexity | baa6cad05c3c374cdee13a1f957bfb6c MD5 | raw file
  1/** 
  2 * @file llviewerstats.h
  3 * @brief LLViewerStats class header file
  4 *
  5 * $LicenseInfo:firstyear=2002&license=viewerlgpl$
  6 * Second Life Viewer Source Code
  7 * Copyright (C) 2010, Linden Research, Inc.
  8 * 
  9 * This library is free software; you can redistribute it and/or
 10 * modify it under the terms of the GNU Lesser General Public
 11 * License as published by the Free Software Foundation;
 12 * version 2.1 of the License only.
 13 * 
 14 * This library is distributed in the hope that it will be useful,
 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 17 * Lesser General Public License for more details.
 18 * 
 19 * You should have received a copy of the GNU Lesser General Public
 20 * License along with this library; if not, write to the Free Software
 21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 22 * 
 23 * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
 24 * $/LicenseInfo$
 25 */
 26
 27#ifndef LL_LLVIEWERSTATS_H
 28#define LL_LLVIEWERSTATS_H
 29
 30#include "llstat.h"
 31#include "lltextureinfo.h"
 32
 33class LLViewerStats : public LLSingleton<LLViewerStats>
 34{
 35public:
 36	LLStat mKBitStat;
 37	LLStat mLayersKBitStat;
 38	LLStat mObjectKBitStat;
 39	LLStat mAssetKBitStat;
 40	LLStat mTextureKBitStat;
 41	LLStat mVFSPendingOperations;
 42	LLStat mObjectsDrawnStat;
 43	LLStat mObjectsCulledStat;
 44	LLStat mObjectsTestedStat;
 45	LLStat mObjectsComparedStat;
 46	LLStat mObjectsOccludedStat;
 47	LLStat mFPSStat;
 48	LLStat mPacketsInStat;
 49	LLStat mPacketsLostStat;
 50	LLStat mPacketsOutStat;
 51	LLStat mPacketsLostPercentStat;
 52	LLStat mTexturePacketsStat;
 53	LLStat mActualInKBitStat;	// From the packet ring (when faking a bad connection)
 54	LLStat mActualOutKBitStat;	// From the packet ring (when faking a bad connection)
 55	LLStat mTrianglesDrawnStat;
 56
 57	// Simulator stats
 58	LLStat mSimTimeDilation;
 59
 60	LLStat mSimFPS;
 61	LLStat mSimPhysicsFPS;
 62	LLStat mSimAgentUPS;
 63	LLStat mSimScriptEPS;
 64
 65	LLStat mSimFrameMsec;
 66	LLStat mSimNetMsec;
 67	LLStat mSimSimOtherMsec;
 68	LLStat mSimSimPhysicsMsec;
 69
 70	LLStat mSimSimPhysicsStepMsec;
 71	LLStat mSimSimPhysicsShapeUpdateMsec;
 72	LLStat mSimSimPhysicsOtherMsec;
 73
 74	LLStat mSimAgentMsec;
 75	LLStat mSimImagesMsec;
 76	LLStat mSimScriptMsec;
 77	LLStat mSimSpareMsec;
 78	LLStat mSimSleepMsec;
 79	LLStat mSimPumpIOMsec;
 80
 81	LLStat mSimMainAgents;
 82	LLStat mSimChildAgents;
 83	LLStat mSimObjects;
 84	LLStat mSimActiveObjects;
 85	LLStat mSimActiveScripts;
 86
 87	LLStat mSimInPPS;
 88	LLStat mSimOutPPS;
 89	LLStat mSimPendingDownloads;
 90	LLStat mSimPendingUploads;
 91	LLStat mSimPendingLocalUploads;
 92	LLStat mSimTotalUnackedBytes;
 93
 94	LLStat mPhysicsPinnedTasks;
 95	LLStat mPhysicsLODTasks;
 96	LLStat mPhysicsMemoryAllocated;
 97
 98	LLStat mSimPingStat;
 99
100	LLStat mNumImagesStat;
101	LLStat mNumRawImagesStat;
102	LLStat mGLTexMemStat;
103	LLStat mGLBoundMemStat;
104	LLStat mRawMemStat;
105	LLStat mFormattedMemStat;
106
107	LLStat mNumObjectsStat;
108	LLStat mNumActiveObjectsStat;
109	LLStat mNumNewObjectsStat;
110	LLStat mNumSizeCulledStat;
111	LLStat mNumVisCulledStat;
112
113	void resetStats();
114public:
115	// If you change this, please also add a corresponding text label
116	// in statTypeToText in llviewerstats.cpp
117	enum EStatType
118	{
119		ST_VERSION = 0,
120		ST_AVATAR_EDIT_SECONDS = 1,
121		ST_TOOLBOX_SECONDS = 2,
122		ST_CHAT_COUNT = 3,
123		ST_IM_COUNT = 4,
124		ST_FULLSCREEN_BOOL = 5,
125		ST_RELEASE_COUNT= 6,
126		ST_CREATE_COUNT = 7,
127		ST_REZ_COUNT = 8,
128		ST_FPS_10_SECONDS = 9,
129		ST_FPS_2_SECONDS = 10,
130		ST_MOUSELOOK_SECONDS = 11,
131		ST_FLY_COUNT = 12,
132		ST_TELEPORT_COUNT = 13,
133		ST_OBJECT_DELETE_COUNT = 14,
134		ST_SNAPSHOT_COUNT = 15,
135		ST_UPLOAD_SOUND_COUNT = 16,
136		ST_UPLOAD_TEXTURE_COUNT = 17,
137		ST_EDIT_TEXTURE_COUNT = 18,
138		ST_KILLED_COUNT = 19,
139		ST_FRAMETIME_JITTER = 20,
140		ST_FRAMETIME_SLEW = 21,
141		ST_INVENTORY_TOO_LONG = 22,
142		ST_WEARABLES_TOO_LONG = 23,
143		ST_LOGIN_SECONDS = 24,
144		ST_LOGIN_TIMEOUT_COUNT = 25,
145		ST_HAS_BAD_TIMER = 26,
146		ST_DOWNLOAD_FAILED = 27,
147		ST_LSL_SAVE_COUNT = 28,
148		ST_UPLOAD_ANIM_COUNT = 29,
149		ST_FPS_8_SECONDS = 30,
150		ST_SIM_FPS_20_SECONDS = 31,
151		ST_PHYS_FPS_20_SECONDS = 32,
152		ST_LOSS_05_SECONDS = 33,
153		ST_FPS_DROP_50_RATIO = 34,
154		ST_ENABLE_VBO = 35,
155		ST_DELTA_BANDWIDTH = 36,
156		ST_MAX_BANDWIDTH = 37,
157		ST_LIGHTING_DETAIL = 38,
158		ST_VISIBLE_AVATARS = 39,
159		ST_SHADER_OBJECTS = 40,
160		ST_SHADER_ENVIRONMENT = 41,
161		ST_DRAW_DIST = 42,
162		ST_CHAT_BUBBLES = 43,
163		ST_SHADER_AVATAR = 44,
164		ST_FRAME_SECS = 45,
165		ST_UPDATE_SECS = 46,
166		ST_NETWORK_SECS = 47,
167		ST_IMAGE_SECS = 48,
168		ST_REBUILD_SECS = 49,
169		ST_RENDER_SECS = 50,
170		ST_CROSSING_AVG = 51,
171		ST_CROSSING_MAX = 52,
172		ST_LIBXUL_WIDGET_USED = 53, // Unused
173		ST_WINDOW_WIDTH = 54,
174		ST_WINDOW_HEIGHT = 55,
175		ST_TEX_BAKES = 56,
176		ST_TEX_REBAKES = 57,
177		
178		ST_COUNT = 58
179	};
180
181
182	LLViewerStats();
183	~LLViewerStats();
184
185	// all return latest value of given stat
186	F64 getStat(EStatType type) const;
187	F64 setStat(EStatType type, F64 value);		// set the stat to value
188	F64 incStat(EStatType type, F64 value = 1.f);	// add value to the stat
189
190	void updateFrameStats(const F64 time_diff);
191	
192	void addToMessage(LLSD &body) const;
193
194	struct  StatsAccumulator
195	{
196		S32 mCount;
197		F32 mSum;
198		F32 mSumOfSquares;
199		F32 mMinValue;
200		F32 mMaxValue;
201		U32 mCountOfNextUpdatesToIgnore;
202
203		inline StatsAccumulator()
204		{
205			reset();
206		}
207
208		inline void push( F32 val )
209		{
210			if ( mCountOfNextUpdatesToIgnore > 0 )
211			{
212				mCountOfNextUpdatesToIgnore--;
213				return;
214			}
215			
216			mCount++;
217			mSum += val;
218			mSumOfSquares += val * val;
219			if (mCount == 1 || val > mMaxValue)
220			{
221				mMaxValue = val;
222			}
223			if (mCount == 1 || val < mMinValue)
224			{
225				mMinValue = val;
226			}
227		}
228		
229		inline F32 getMean() const
230		{
231			return (mCount == 0) ? 0.f : ((F32)mSum)/mCount;
232		}
233
234		inline F32 getMinValue() const
235		{
236			return mMinValue;
237		}
238
239		inline F32 getMaxValue() const
240		{
241			return mMaxValue;
242		}
243
244		inline F32 getStdDev() const
245		{
246			const F32 mean = getMean();
247			return (mCount == 0) ? 0.f : sqrt( mSumOfSquares/mCount - (mean * mean) );
248		}
249		
250		inline U32 getCount() const
251		{
252			return mCount;
253		}
254
255		inline void reset()
256		{
257			mCount = 0;
258			mSum = mSumOfSquares = 0.f;
259			mMinValue = 0.0f;
260			mMaxValue = 0.0f;
261			mCountOfNextUpdatesToIgnore = 0;
262		}
263		
264		inline LLSD getData() const
265		{
266			LLSD data;
267			data["mean"] = getMean();
268			data["std_dev"] = getStdDev();
269			data["count"] = (S32)mCount;
270			data["min"] = getMinValue();
271			data["max"] = getMaxValue();
272			return data;
273		}
274	};
275
276	StatsAccumulator mAgentPositionSnaps;
277	
278private:
279	F64	mStats[ST_COUNT];
280
281	F64 mLastTimeDiff;  // used for time stat updates
282};
283
284static const F32 SEND_STATS_PERIOD = 300.0f;
285
286// The following are from (older?) statistics code found in appviewer.
287void init_statistics();
288void reset_statistics();
289void output_statistics(void*);
290void update_statistics(U32 frame_count);
291void send_stats();
292
293extern std::map<S32,LLFrameTimer> gDebugTimers;
294extern std::map<S32,std::string> gDebugTimerLabel;
295extern U32	gTotalTextureBytes;
296extern U32  gTotalObjectBytes;
297extern U32  gTotalTextureBytesPerBoostLevel[] ;
298#endif // LL_LLVIEWERSTATS_H