1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
|
/**
* @file llviewerim_peningtats.h
* @brief LLViewerStats class header file
*
* $LicenseInfo:firstyear=2002&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_LLVIEWERSTATS_H
#define LL_LLVIEWERSTATS_H
#include "llstat.h"
#include "lltextureinfo.h"
#include "lltracerecording.h"
#include "lltrace.h"
namespace LLStatViewer
{
extern LLTrace::Count<> FPS,
PACKETS_IN,
PACKETS_LOST,
PACKETS_OUT,
TEXTURE_PACKETS,
TRIANGLES_DRAWN,
CHAT_COUNT,
IM_COUNT,
OBJECT_CREATE,
OBJECT_REZ,
LOADING_WEARABLES_LONG_DELAY,
LOGIN_TIMEOUTS,
FAILED_DOWNLOADS,
LSL_SAVES,
ANIMATION_UPLOADS,
FLY,
TELEPORT,
DELETE_OBJECT,
SNAPSHOT,
UPLOAD_SOUND,
UPLOAD_TEXTURE,
EDIT_TEXTURE,
KILLED,
FRAMETIME_DOUBLED,
TEX_BAKES,
TEX_REBAKES;
extern LLTrace::Count<LLUnits::Kilobits> KBIT,
LAYERS_KBIT,
OBJECT_KBIT,
ASSET_KBIT,
TEXTURE_KBIT,
ACTUAL_IN_KBIT,
ACTUAL_OUT_KBIT;
extern LLTrace::Count<LLUnits::Seconds> AVATAR_EDIT_TIME,
TOOLBOX_TIME,
MOUSELOOK_TIME,
FPS_10_TIME,
FPS_8_TIME,
FPS_2_TIME,
SIM_20_FPS_TIME,
SIM_PHYSICS_20_FPS_TIME,
LOSS_5_PERCENT_TIME;
extern LLTrace::Measurement<> SIM_TIME_DILATION,
SIM_FPS,
SIM_PHYSICS_FPS,
SIM_AGENT_UPS,
SIM_SCRIPT_EPS,
SIM_SKIPPED_SILHOUETTE,
SIM_SKIPPED_CHARACTERS_PERCENTAGE,
SIM_MAIN_AGENTS,
SIM_CHILD_AGENTS,
SIM_OBJECTS,
SIM_ACTIVE_OBJECTS,
SIM_ACTIVE_SCRIPTS,
SIM_PERCENTAGE_SCRIPTS_RUN,
SIM_IN_PACKETS_PER_SEC,
SIM_OUT_PACKETS_PER_SEC,
SIM_PENDING_DOWNLOADS,
SIM_PENDING_UPLOADS,
SIM_PENDING_LOCAL_UPLOADS,
SIM_PENDING_VFS_OPERATIONS,
SIM_PHYSICS_PINNED_TASKS,
SIM_PHYSICS_LOD_TASKS,
NUM_IMAGES,
NUM_RAW_IMAGES,
NUM_OBJECTS,
NUM_ACTIVE_OBJECTS,
NUM_NEW_OBJECTS,
NUM_SIZE_CULLED,
NUM_VIS_CULLED,
ENABLE_VBO,
DELTA_BANDWIDTH,
MAX_BANDWIDTH,
LIGHTING_DETAIL,
VISIBLE_AVATARS,
SHADER_OBJECTS,
DRAW_DISTANCE,
CHAT_BUBBLES,
WINDOW_WIDTH,
WINDOW_HEIGHT;
extern LLTrace::Measurement<LLUnits::Bytes> SIM_UNACKED_BYTES,
SIM_PHYSICS_MEM,
GL_TEX_MEM,
GL_BOUND_MEM,
RAW_MEM,
FORMATTED_MEM;
extern LLTrace::Measurement<LLUnits::Seconds> SIM_PHYSICS_TIME,
SIM_PHYSICS_STEP_TIME,
SIM_PHYSICS_SHAPE_UPDATE_TIME,
SIM_PHYSICS_OTHER_TIME,
SIM_AI_TIME,
SIM_AGENTS_TIME,
SIM_IMAGES_TIME,
SIM_SCRIPTS_TIME,
SIM_SPARE_TIME,
SIM_SLEEP_TIME,
SIM_PUMP_IO_TIME,
SIM_PING,
FRAMETIME_JITTER,
FRAMETIME_SLEW,
LOGIN_SECONDS,
REGION_CROSSING_TIME,
FRAME_STACKTIME,
UPDATE_STACKTIME,
NETWORK_STACKTIME,
IMAGE_STACKTIME,
REBUILD_STACKTIME,
RENDER_STACKTIME;
}
class LLViewerStats : public LLSingleton<LLViewerStats>
{
public:
LLStat mVFSPendingOperations,
mFPSStat,
mPacketsInStat,
mPacketsLostStat,
mPacketsOutStat,
mPacketsLostPercentStat,
mTexturePacketsStat,
mActualInKBitStat, // From the packet ring (when faking a bad connection)
mActualOutKBitStat, // From the packet ring (when faking a bad connection)
mTrianglesDrawnStat;
// Simulator stats
LLStat mSimTimeDilation;
LLStat mSimFPS,
mSimPhysicsFPS,
mSimAgentUPS,
mSimScriptEPS;
LLStat mSimFrameMsec,
mSimNetMsec,
mSimSimOtherMsec,
mSimSimPhysicsMsec;
LLStat mSimSimPhysicsStepMsec,
mSimSimPhysicsShapeUpdateMsec,
mSimSimPhysicsOtherMsec,
mSimSimAIStepMsec,
mSimSimSkippedSilhouetteSteps,
mSimSimPctSteppedCharacters;
LLStat mSimAgentMsec,
mSimImagesMsec,
mSimScriptMsec,
mSimSpareMsec,
mSimSleepMsec,
mSimPumpIOMsec;
LLStat mSimMainAgents,
mSimChildAgents,
mSimObjects,
mSimActiveObjects,
mSimActiveScripts,
mSimPctScriptsRun;
LLStat mSimInPPS,
mSimOutPPS,
mSimPendingDownloads,
mSimPendingUploads,
mSimPendingLocalUploads,
mSimTotalUnackedBytes;
LLStat mPhysicsPinnedTasks,
mPhysicsLODTasks,
mPhysicsMemoryAllocated;
LLStat mSimPingStat;
LLStat mNumImagesStat,
mNumRawImagesStat,
mGLTexMemStat,
mGLBoundMemStat,
mRawMemStat,
mFormattedMemStat;
LLStat mNumObjectsStat,
mNumActiveObjectsStat,
mNumNewObjectsStat,
mNumSizeCulledStat,
mNumVisCulledStat;
void resetStats();
public:
// If you change this, please also add a corresponding text label in llviewerstats.cpp
enum EStatType
{
ST_VERSION = 0,
ST_AVATAR_EDIT_SECONDS = 1,
ST_TOOLBOX_SECONDS = 2,
ST_CHAT_COUNT = 3,
ST_IM_COUNT = 4,
ST_FULLSCREEN_BOOL = 5,
ST_RELEASE_COUNT= 6,
ST_CREATE_COUNT = 7,
ST_REZ_COUNT = 8,
ST_FPS_10_SECONDS = 9,
ST_FPS_2_SECONDS = 10,
ST_MOUSELOOK_SECONDS = 11,
ST_FLY_COUNT = 12,
ST_TELEPORT_COUNT = 13,
ST_OBJECT_DELETE_COUNT = 14,
ST_SNAPSHOT_COUNT = 15,
ST_UPLOAD_SOUND_COUNT = 16,
ST_UPLOAD_TEXTURE_COUNT = 17,
ST_EDIT_TEXTURE_COUNT = 18,
ST_KILLED_COUNT = 19,
ST_FRAMETIME_JITTER = 20,
ST_FRAMETIME_SLEW = 21,
ST_INVENTORY_TOO_LONG = 22,
ST_WEARABLES_TOO_LONG = 23,
ST_LOGIN_SECONDS = 24,
ST_LOGIN_TIMEOUT_COUNT = 25,
ST_HAS_BAD_TIMER = 26,
ST_DOWNLOAD_FAILED = 27,
ST_LSL_SAVE_COUNT = 28,
ST_UPLOAD_ANIM_COUNT = 29,
ST_FPS_8_SECONDS = 30,
ST_SIM_FPS_20_SECONDS = 31,
ST_PHYS_FPS_20_SECONDS = 32,
ST_LOSS_05_SECONDS = 33,
ST_FPS_DROP_50_RATIO = 34,
ST_ENABLE_VBO = 35,
ST_DELTA_BANDWIDTH = 36,
ST_MAX_BANDWIDTH = 37,
ST_LIGHTING_DETAIL = 38,
ST_VISIBLE_AVATARS = 39,
ST_SHADER_OBJECTS = 40,
ST_SHADER_ENVIRONMENT = 41,
ST_DRAW_DIST = 42,
ST_CHAT_BUBBLES = 43,
ST_SHADER_AVATAR = 44,
ST_FRAME_SECS = 45,
ST_UPDATE_SECS = 46,
ST_NETWORK_SECS = 47,
ST_IMAGE_SECS = 48,
ST_REBUILD_SECS = 49,
ST_RENDER_SECS = 50,
ST_CROSSING_AVG = 51,
ST_CROSSING_MAX = 52,
ST_LIBXUL_WIDGET_USED = 53, // Unused
ST_WINDOW_WIDTH = 54,
ST_WINDOW_HEIGHT = 55,
ST_TEX_BAKES = 56,
ST_TEX_REBAKES = 57,
ST_COUNT = 58
};
LLViewerStats();
~LLViewerStats();
// all return latest value of given stat
F64 getStat(EStatType type) const;
F64 setStat(EStatType type, F64 value); // set the stat to value
F64 incStat(EStatType type, F64 value = 1.f); // add value to the stat
void updateFrameStats(const F64 time_diff);
void addToMessage(LLSD &body) const;
struct StatsAccumulator
{
S32 mCount;
F32 mSum;
F32 mSumOfSquares;
F32 mMinValue;
F32 mMaxValue;
U32 mCountOfNextUpdatesToIgnore;
inline StatsAccumulator()
{
reset();
}
inline void push( F32 val )
{
if ( mCountOfNextUpdatesToIgnore > 0 )
{
mCountOfNextUpdatesToIgnore--;
return;
}
mCount++;
mSum += val;
mSumOfSquares += val * val;
if (mCount == 1 || val > mMaxValue)
{
mMaxValue = val;
}
if (mCount == 1 || val < mMinValue)
{
mMinValue = val;
}
}
inline F32 getMean() const
{
return (mCount == 0) ? 0.f : ((F32)mSum)/mCount;
}
inline F32 getMinValue() const
{
return mMinValue;
}
inline F32 getMaxValue() const
{
return mMaxValue;
}
inline F32 getStdDev() const
{
const F32 mean = getMean();
return (mCount < 2) ? 0.f : sqrt(llmax(0.f,mSumOfSquares/mCount - (mean * mean)));
}
inline U32 getCount() const
{
return mCount;
}
inline void reset()
{
mCount = 0;
mSum = mSumOfSquares = 0.f;
mMinValue = 0.0f;
mMaxValue = 0.0f;
mCountOfNextUpdatesToIgnore = 0;
}
inline LLSD asLLSD() const
{
LLSD data;
data["mean"] = getMean();
data["std_dev"] = getStdDev();
data["count"] = (S32)mCount;
data["min"] = getMinValue();
data["max"] = getMaxValue();
return data;
}
};
StatsAccumulator mAgentPositionSnaps;
// Phase tracking (originally put in for avatar rezzing), tracking
// progress of active/completed phases for activities like outfit changing.
typedef std::map<std::string,LLFrameTimer> phase_map_t;
typedef std::map<std::string,StatsAccumulator> phase_stats_t;
class PhaseMap
{
private:
phase_map_t mPhaseMap;
static phase_stats_t sStats;
public:
PhaseMap();
LLFrameTimer& getPhaseTimer(const std::string& phase_name);
void startPhase(const std::string& phase_name);
void stopPhase(const std::string& phase_name);
void stopAllPhases();
void clearPhases();
LLSD asLLSD();
static StatsAccumulator& getPhaseStats(const std::string& phase_name);
static void recordPhaseStat(const std::string& phase_name, F32 value);
};
LLTrace::Recording& getRecording() { return mRecording; }
private:
F64 mStats[ST_COUNT];
LLTrace::Recording mRecording;
F64 mLastTimeDiff; // used for time stat updates
};
static const F32 SEND_STATS_PERIOD = 300.0f;
// The following are from (older?) statistics code found in appviewer.
void update_statistics();
void send_stats();
extern LLFrameTimer gTextureTimer;
extern U32 gTotalTextureBytes;
extern U32 gTotalObjectBytes;
extern U32 gTotalTextureBytesPerBoostLevel[] ;
#endif // LL_LLVIEWERSTATS_H
|