aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/newview/llviewerstats.cpp
diff options
context:
space:
mode:
authorJacek Antonelli2008-08-15 23:44:46 -0500
committerJacek Antonelli2008-08-15 23:44:46 -0500
commit38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4 (patch)
treeadca584755d22ca041a2dbfc35d4eca01f70b32c /linden/indra/newview/llviewerstats.cpp
parentREADME.txt (diff)
downloadmeta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.zip
meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.gz
meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.bz2
meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.xz
Second Life viewer sources 1.13.2.12
Diffstat (limited to '')
-rw-r--r--linden/indra/newview/llviewerstats.cpp320
1 files changed, 320 insertions, 0 deletions
diff --git a/linden/indra/newview/llviewerstats.cpp b/linden/indra/newview/llviewerstats.cpp
new file mode 100644
index 0000000..e1e783c
--- /dev/null
+++ b/linden/indra/newview/llviewerstats.cpp
@@ -0,0 +1,320 @@
1/**
2 * @file llviewerstats.cpp
3 * @brief LLViewerStats class implementation
4 *
5 * Copyright (c) 2002-2007, Linden Research, Inc.
6 *
7 * The source code in this file ("Source Code") is provided by Linden Lab
8 * to you under the terms of the GNU General Public License, version 2.0
9 * ("GPL"), unless you have obtained a separate licensing agreement
10 * ("Other License"), formally executed by you and Linden Lab. Terms of
11 * the GPL can be found in doc/GPL-license.txt in this distribution, or
12 * online at http://secondlife.com/developers/opensource/gplv2
13 *
14 * There are special exceptions to the terms and conditions of the GPL as
15 * it is applied to this Source Code. View the full text of the exception
16 * in the file doc/FLOSS-exception.txt in this software distribution, or
17 * online at http://secondlife.com/developers/opensource/flossexception
18 *
19 * By copying, modifying or distributing this software, you acknowledge
20 * that you have read and understood your obligations described above,
21 * and agree to abide by those obligations.
22 *
23 * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
24 * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
25 * COMPLETENESS OR PERFORMANCE.
26 */
27
28#include "llviewerprecompiledheaders.h"
29
30#include "llviewerstats.h"
31#include "llviewerthrottle.h"
32
33#include "message.h"
34#include "lltimer.h"
35
36LLViewerStats *gViewerStats = NULL;
37
38extern U32 gFrameCount;
39extern LLTimer gRenderStartTime;
40
41class StatAttributes
42{
43public:
44 StatAttributes(const char *name,
45 const BOOL enabled,
46 const BOOL is_timer)
47 : mName(name),
48 mEnabled(enabled),
49 mIsTimer(is_timer)
50 {
51 }
52
53 const char *mName;
54 const BOOL mEnabled;
55 const BOOL mIsTimer;
56};
57
58const StatAttributes STAT_INFO[LLViewerStats::ST_COUNT] =
59{
60 // ST_MOUSELOOK_SECONDS
61 StatAttributes("Seconds in Mouselook", FALSE, TRUE),
62 // ST_AVATAR_EDIT_SECONDS
63 StatAttributes("Seconds in Edit Appearence", FALSE, TRUE),
64 // ST_TOOLBOX_SECONDS
65 StatAttributes("Seconds using Toolbox", FALSE, TRUE),
66 // ST_CHAT_COUNT
67 StatAttributes("Chat messages sent", FALSE, FALSE),
68 // ST_IM_COUNT
69 StatAttributes("IMs sent", FALSE, FALSE),
70 // ST_FULLSCREEN_BOOL
71 StatAttributes("Fullscreen mode", TRUE, FALSE),
72 // ST_RELEASE_COUNT
73 StatAttributes("Object release count", FALSE, FALSE),
74 // ST_CREATE_COUNT
75 StatAttributes("Object create count", FALSE, FALSE),
76 // ST_REZ_COUNT
77 StatAttributes("Object rez count", FALSE, FALSE),
78 // ST_FPS_10_SECONDS
79 StatAttributes("Seconds below 10 FPS", FALSE, TRUE),
80 // ST_FPS_5_SECONDS
81 StatAttributes("Seconds below 5 FPS", FALSE, TRUE),
82 // ST_FPS_2_SECONDS
83 StatAttributes("Seconds below 2 FPS", FALSE, TRUE),
84 // ST_FLY_COUNT
85 StatAttributes("Fly count", FALSE, FALSE),
86 // ST_TELEPORT_COUNT
87 StatAttributes("Teleport count", FALSE, FALSE),
88 // ST_OBJECT_DELETE_COUNT
89 StatAttributes("Objects deleted", FALSE, FALSE),
90 // ST_SNAPSHOT_COUNT
91 StatAttributes("Snapshots taken", FALSE, FALSE),
92 // ST_UPLOAD_SOUND_COUNT
93 StatAttributes("Sounds uploaded", FALSE, FALSE),
94 // ST_UPLOAD_TEXTURE_COUNT
95 StatAttributes("Textures uploaded", FALSE, FALSE),
96 // ST_EDIT_TEXTURE_COUNT
97 StatAttributes("Changes to textures on objects", FALSE, FALSE),
98 // ST_KILLED_COUNT
99 StatAttributes("Number of times killed", FALSE, FALSE),
100 // ST_FRAMETIME_JITTER
101 StatAttributes("Average delta between sucessive frame times", FALSE, FALSE),
102 // ST_FRAMETIME_SLEW
103 StatAttributes("Average delta between frame time and mean", FALSE, FALSE),
104 // ST_INVENTORY_TOO_LONG
105 StatAttributes("Inventory took too long to load", FALSE, FALSE),
106 // ST_WEARABLES_TOO_LONG
107 StatAttributes("Wearables took too long to load", FALSE, FALSE),
108 // ST_LOGIN_SECONDS
109 StatAttributes("Time between LoginRequest and LoginReply", FALSE, FALSE),
110 // ST_LOGIN_TIMEOUT_COUNT
111 StatAttributes("Number of login attempts that timed out", FALSE, FALSE),
112 // ST_HAS_BAD_TIMER
113 StatAttributes("Known bad timer if != 0.0", FALSE, FALSE),
114 // ST_DOWNLOAD_FAILED
115 StatAttributes("Number of times LLAssetStorage::getAssetData() has failed", FALSE, FALSE),
116 // ST_LSL_SAVE_COUNT
117 StatAttributes("Number of times user has saved a script", FALSE, FALSE),
118 // ST_UPLOAD_ANIM_COUNT
119 StatAttributes("Animations uploaded", FALSE, FALSE),
120 // ST_FPS_8_SECONDS
121 StatAttributes("Seconds below 8 FPS", TRUE, TRUE),
122 // ST_SIM_FPS_20_SECONDS
123 StatAttributes("Seconds with sim FPS below 20", TRUE, TRUE),
124 // ST_PHYS_FPS_20_SECONDS
125 StatAttributes("Seconds with physics FPS below 20", TRUE, TRUE),
126 // ST_LOSS_05_SECONDS
127 StatAttributes("Seconds with packet loss > 5%", TRUE, TRUE),
128 // ST_FPS_DROP_50_RATIO
129 StatAttributes("Ratio of frames 2x longer than previous", TRUE, FALSE),
130 // ST_MEDIA_OBJECT_LIST_LENGTH
131 StatAttributes("Number of objects that want to display web pages", TRUE, FALSE),
132 // ST_DELTA_BANDWIDTH
133 StatAttributes("Increase/Decrease in bandwidth based on packet loss", TRUE, FALSE),
134 // ST_MAX_BANDWIDTH
135 StatAttributes("Max bandwidth setting", TRUE, FALSE),
136 // ST_LIGHTING_DETAIL
137 StatAttributes("Lighting Detail", TRUE, FALSE),
138 // ST_VISIBLE_AVATARS
139 StatAttributes("Visible Avatars", TRUE, FALSE),
140 // ST_SHADER_OJECTS
141 StatAttributes("Object Shaders", TRUE, FALSE),
142 // ST_SHADER_ENVIRONMENT
143 StatAttributes("Environment Shaders", TRUE, FALSE),
144 // ST_VISIBLE_DRAW_DIST
145 StatAttributes("Draw Distance", TRUE, FALSE),
146 // ST_VISIBLE_CHAT_BUBBLES
147 StatAttributes("Chat Bubbles Enabled", TRUE, FALSE),
148 // ST_SHADER_AVATAR
149 StatAttributes("Avatar Shaders", TRUE, FALSE),
150 // ST_FRAME_SECS
151 StatAttributes("FRAME_SECS", TRUE, FALSE),
152 // ST_UPDATE_SECS
153 StatAttributes("UPDATE_SECS", TRUE, FALSE),
154 // ST_NETWORK_SECS
155 StatAttributes("NETWORK_SECS", TRUE, FALSE),
156 // ST_IMAGE_SECS
157 StatAttributes("IMAGE_SECS", TRUE, FALSE),
158 // ST_REBUILD_SECS
159 StatAttributes("REBUILD_SECS", TRUE, FALSE),
160 // ST_RENDER_SECS
161 StatAttributes("RENDER_SECS", TRUE, FALSE),
162 // ST_CROSSING_AVG
163 StatAttributes("CROSSING_AVG", TRUE, FALSE),
164 // ST_CROSSING_MAX
165 StatAttributes("CROSSING_MAX", TRUE, FALSE),
166 // ST_LIBXUL_WIDGET_USED
167 StatAttributes("LibXUL Widget used", TRUE, FALSE),
168 // ST_WINDOW_WIDTH
169 StatAttributes("Window width", TRUE, FALSE),
170 // ST_WINDOW_HEIGHT
171 StatAttributes("Window height", TRUE, FALSE),
172 // ST_TEX_BAKES
173 StatAttributes("Texture Bakes", TRUE, FALSE),
174 // ST_TEX_REBAKES
175 StatAttributes("Texture Rebakes", TRUE, FALSE)
176};
177
178LLViewerStats::LLViewerStats()
179 : mPacketsLostPercentStat(64),
180 mLastTimeDiff(0.0)
181{
182 for (S32 i = 0; i < ST_COUNT; i++)
183 {
184 mStats[i] = 0.0;
185 }
186
187 if (LLTimer::knownBadTimer())
188 {
189 mStats[ST_HAS_BAD_TIMER] = 1.0;
190 }
191}
192
193LLViewerStats::~LLViewerStats()
194{
195}
196
197void LLViewerStats::resetStats()
198{
199 gViewerStats->mKBitStat.reset();
200 gViewerStats->mLayersKBitStat.reset();
201 gViewerStats->mObjectKBitStat.reset();
202 gViewerStats->mTextureKBitStat.reset();
203 gViewerStats->mVFSPendingOperations.reset();
204 gViewerStats->mAssetKBitStat.reset();
205 gViewerStats->mPacketsInStat.reset();
206 gViewerStats->mPacketsLostStat.reset();
207 gViewerStats->mPacketsOutStat.reset();
208 gViewerStats->mFPSStat.reset();
209 gViewerStats->mTexturePacketsStat.reset();
210}
211
212
213F64 LLViewerStats::getStat(EStatType type) const
214{
215 return mStats[type];
216}
217
218F64 LLViewerStats::setStat(EStatType type, F64 value)
219{
220 mStats[type] = value;
221 return mStats[type];
222}
223
224F64 LLViewerStats::incStat(EStatType type, F64 value)
225{
226 mStats[type] += value;
227 return mStats[type];
228}
229
230void LLViewerStats::updateFrameStats(const F64 time_diff)
231{
232 if (mPacketsLostPercentStat.getCurrent() > 5.0)
233 {
234 incStat(LLViewerStats::ST_LOSS_05_SECONDS, time_diff);
235 }
236
237 if (mSimFPS.getCurrent() < 20.f && mSimFPS.getCurrent() > 0.f)
238 {
239 incStat(LLViewerStats::ST_SIM_FPS_20_SECONDS, time_diff);
240 }
241
242 if (mSimPhysicsFPS.getCurrent() < 20.f && mSimPhysicsFPS.getCurrent() > 0.f)
243 {
244 incStat(LLViewerStats::ST_PHYS_FPS_20_SECONDS, time_diff);
245 }
246
247 if (time_diff >= 0.5)
248 {
249 incStat(LLViewerStats::ST_FPS_2_SECONDS, time_diff);
250 }
251 if (time_diff >= 0.2)
252 {
253 incStat(LLViewerStats::ST_FPS_5_SECONDS, time_diff);
254 }
255 if (time_diff >= 0.125)
256 {
257 incStat(LLViewerStats::ST_FPS_8_SECONDS, time_diff);
258 }
259 if (time_diff >= 0.1)
260 {
261 incStat(LLViewerStats::ST_FPS_10_SECONDS, time_diff);
262 }
263
264 if (gFrameCount && mLastTimeDiff > 0.0)
265 {
266 // new "stutter" meter
267 setStat(LLViewerStats::ST_FPS_DROP_50_RATIO,
268 (getStat(LLViewerStats::ST_FPS_DROP_50_RATIO) * (F64)(gFrameCount - 1) +
269 (time_diff >= 2.0 * mLastTimeDiff ? 1.0 : 0.0)) / gFrameCount);
270
271
272 // old stats that were never really used
273 setStat(LLViewerStats::ST_FRAMETIME_JITTER,
274 (getStat(LLViewerStats::ST_FRAMETIME_JITTER) * (gFrameCount - 1) +
275 fabs(mLastTimeDiff - time_diff) / mLastTimeDiff) / gFrameCount);
276
277 F32 average_frametime = gRenderStartTime.getElapsedTimeF32() / (F32)gFrameCount;
278 setStat(LLViewerStats::ST_FRAMETIME_SLEW,
279 (getStat(LLViewerStats::ST_FRAMETIME_SLEW) * (gFrameCount - 1) +
280 fabs(average_frametime - time_diff) / average_frametime) / gFrameCount);
281
282 F32 max_bandwidth = gViewerThrottle.getMaxBandwidth();
283 F32 delta_bandwidth = gViewerThrottle.getCurrentBandwidth() - max_bandwidth;
284 setStat(LLViewerStats::ST_DELTA_BANDWIDTH, delta_bandwidth / 1024.f);
285
286 setStat(LLViewerStats::ST_MAX_BANDWIDTH, max_bandwidth / 1024.f);
287
288 }
289
290 mLastTimeDiff = time_diff;
291
292}
293
294void LLViewerStats::addToMessage() const
295{
296 for (S32 i = 0; i < ST_COUNT; i++)
297 {
298 if (STAT_INFO[i].mEnabled)
299 {
300 // TODO: send timer value so dataserver can normalize
301 gMessageSystem->nextBlockFast(_PREHASH_MiscStats);
302 gMessageSystem->addU32Fast(_PREHASH_Type, (U32)i);
303 gMessageSystem->addF64Fast(_PREHASH_Value, mStats[i]);
304 llinfos << "STAT: " << STAT_INFO[i].mName << ": " << mStats[i] << llendl;
305 }
306 }
307}
308
309// static
310const char *LLViewerStats::statTypeToText(EStatType type)
311{
312 if (type >= 0 && type < ST_COUNT)
313 {
314 return STAT_INFO[type].mName;
315 }
316 else
317 {
318 return "Unknown statistic";
319 }
320}