llviewerstats.h 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295
  1. /**
  2. * @file llviewerstats.h
  3. * @brief LLViewerStats class header file
  4. *
  5. * $LicenseInfo:firstyear=2002&license=viewergpl$
  6. *
  7. * Copyright (c) 2002-2009, Linden Research, Inc.
  8. *
  9. * Second Life Viewer Source Code
  10. * The source code in this file ("Source Code") is provided by Linden Lab
  11. * to you under the terms of the GNU General Public License, version 2.0
  12. * ("GPL"), unless you have obtained a separate licensing agreement
  13. * ("Other License"), formally executed by you and Linden Lab. Terms of
  14. * the GPL can be found in doc/GPL-license.txt in this distribution, or
  15. * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
  16. *
  17. * There are special exceptions to the terms and conditions of the GPL as
  18. * it is applied to this Source Code. View the full text of the exception
  19. * in the file doc/FLOSS-exception.txt in this software distribution, or
  20. * online at
  21. * http://secondlifegrid.net/programs/open_source/licensing/flossexception
  22. *
  23. * By copying, modifying or distributing this software, you acknowledge
  24. * that you have read and understood your obligations described above,
  25. * and agree to abide by those obligations.
  26. *
  27. * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
  28. * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
  29. * COMPLETENESS OR PERFORMANCE.
  30. * $/LicenseInfo$
  31. */
  32. #ifndef LL_LLVIEWERSTATS_H
  33. #define LL_LLVIEWERSTATS_H
  34. #include "llstat.h"
  35. class LLSD;
  36. enum
  37. {
  38. LL_SIM_STAT_TIME_DILATION = 0,
  39. LL_SIM_STAT_FPS = 1,
  40. LL_SIM_STAT_PHYSFPS = 2,
  41. LL_SIM_STAT_AGENTUPS = 3,
  42. LL_SIM_STAT_FRAMEMS = 4,
  43. LL_SIM_STAT_NETMS = 5,
  44. LL_SIM_STAT_SIMOTHERMS = 6,
  45. LL_SIM_STAT_SIMPHYSICSMS = 7,
  46. LL_SIM_STAT_AGENTMS = 8,
  47. LL_SIM_STAT_IMAGESMS = 9,
  48. LL_SIM_STAT_SCRIPTMS = 10,
  49. LL_SIM_STAT_NUMTASKS = 11,
  50. LL_SIM_STAT_NUMTASKSACTIVE = 12,
  51. LL_SIM_STAT_NUMAGENTMAIN = 13,
  52. LL_SIM_STAT_NUMAGENTCHILD = 14,
  53. LL_SIM_STAT_NUMSCRIPTSACTIVE = 15,
  54. LL_SIM_STAT_LSLIPS = 16,
  55. LL_SIM_STAT_INPPS = 17,
  56. LL_SIM_STAT_OUTPPS = 18,
  57. LL_SIM_STAT_PENDING_DOWNLOADS = 19,
  58. LL_SIM_STAT_PENDING_UPLOADS = 20,
  59. LL_SIM_STAT_VIRTUAL_SIZE_KB = 21,
  60. LL_SIM_STAT_RESIDENT_SIZE_KB = 22,
  61. LL_SIM_STAT_PENDING_LOCAL_UPLOADS = 23,
  62. LL_SIM_STAT_TOTAL_UNACKED_BYTES = 24,
  63. LL_SIM_STAT_PHYSICS_PINNED_TASKS = 25,
  64. LL_SIM_STAT_PHYSICS_LOD_TASKS = 26,
  65. LL_SIM_STAT_SIMPHYSICSSTEPMS = 27,
  66. LL_SIM_STAT_SIMPHYSICSSHAPEMS = 28,
  67. LL_SIM_STAT_SIMPHYSICSOTHERMS = 29,
  68. LL_SIM_STAT_SIMPHYSICSMEMORY = 30,
  69. LL_SIM_STAT_SCRIPT_EPS = 31,
  70. LL_SIM_STAT_SIMSPARETIME = 32,
  71. LL_SIM_STAT_SIMSLEEPTIME = 33,
  72. LL_SIM_STAT_IOPUMPTIME = 34,
  73. LL_SIM_STAT_PCTSCRIPTSRUN = 35,
  74. LL_SIM_STAT_REGION_IDLE = 36, // dataserver only
  75. LL_SIM_STAT_REGION_IDLE_POSSIBLE = 37, // dataserver only
  76. LL_SIM_STAT_SIMAISTEPTIMEMS = 38,
  77. LL_SIM_STAT_SKIPPEDAISILSTEPS_PS = 39,
  78. LL_SIM_STAT_PCTSTEPPEDCHARACTERS = 40
  79. };
  80. class LLViewerStats
  81. {
  82. protected:
  83. LOG_CLASS(LLViewerStats);
  84. public:
  85. // If you change this, please also add a corresponding text label
  86. // in statTypeToText in llviewerstats.cpp
  87. enum EStatType
  88. {
  89. ST_VERSION = 0,
  90. ST_AVATAR_EDIT_SECONDS,
  91. ST_TOOLBOX_SECONDS,
  92. ST_CHAT_COUNT,
  93. ST_IM_COUNT,
  94. ST_FULLSCREEN_BOOL,
  95. ST_RELEASE_COUNT,
  96. ST_CREATE_COUNT,
  97. ST_REZ_COUNT,
  98. ST_FPS_10_SECONDS,
  99. ST_FPS_2_SECONDS,
  100. ST_MOUSELOOK_SECONDS,
  101. ST_FLY_COUNT,
  102. ST_TELEPORT_COUNT,
  103. ST_OBJECT_DELETE_COUNT,
  104. ST_SNAPSHOT_COUNT,
  105. ST_UPLOAD_SOUND_COUNT,
  106. ST_UPLOAD_TEXTURE_COUNT,
  107. ST_EDIT_TEXTURE_COUNT,
  108. ST_KILLED_COUNT,
  109. ST_FRAMETIME_JITTER,
  110. ST_FRAMETIME_SLEW,
  111. ST_INVENTORY_TOO_LONG,
  112. ST_WEARABLES_TOO_LONG,
  113. ST_LOGIN_SECONDS,
  114. ST_LOGIN_TIMEOUT_COUNT,
  115. ST_HAS_BAD_TIMER,
  116. ST_DOWNLOAD_FAILED,
  117. ST_LSL_SAVE_COUNT,
  118. ST_UPLOAD_ANIM_COUNT,
  119. ST_FPS_8_SECONDS,
  120. ST_SIM_FPS_20_SECONDS,
  121. ST_PHYS_FPS_20_SECONDS,
  122. ST_LOSS_05_SECONDS,
  123. ST_FPS_DROP_50_RATIO,
  124. ST_DELTA_BANDWIDTH,
  125. ST_MAX_BANDWIDTH,
  126. ST_VISIBLE_AVATARS,
  127. ST_SHADER_OBJECTS,
  128. ST_SHADER_ENVIRONMENT,
  129. ST_DRAW_DIST,
  130. ST_CHAT_BUBBLES,
  131. ST_SHADER_AVATAR,
  132. ST_FRAME_SECS,
  133. ST_UPDATE_SECS,
  134. ST_NETWORK_SECS,
  135. ST_IMAGE_SECS,
  136. ST_REBUILD_SECS,
  137. ST_RENDER_SECS,
  138. ST_CROSSING_AVG,
  139. ST_CROSSING_MAX,
  140. ST_WINDOW_WIDTH,
  141. ST_WINDOW_HEIGHT,
  142. ST_TEX_BAKES,
  143. ST_TEX_REBAKES,
  144. ST_COUNT
  145. };
  146. LLViewerStats();
  147. // Returns the latest value of given stat
  148. LL_INLINE F64 getStat(EStatType type) const { return mStats[type]; }
  149. // Sets the stat to value
  150. LL_INLINE F64 setStat(EStatType type, F64 value)
  151. {
  152. mStats[type] = value;
  153. return mStats[type];
  154. }
  155. // Adds value to the stat
  156. LL_INLINE F64 incStat(EStatType type, F64 value = 1.f)
  157. {
  158. mStats[type] += value;
  159. return mStats[type];
  160. }
  161. void addSample(U32 stat_id, F32 stat_value);
  162. void updateFrameStats(F64 time_diff);
  163. LL_INLINE void addRenderTimeStat(F32 t) { mFrameRenderTime.addValue(t); }
  164. LL_INLINE F32 getRenderTimeStat() { return mFrameRenderTime.getMean(); }
  165. void addToMessage(LLSD& body) const;
  166. void resetStats();
  167. void idleUpdate();
  168. void updateStatistics(U32 frame_count);
  169. void sendStats();
  170. void resetAvatarStats(); // Used after TPs, in llagent.cpp
  171. LL_INLINE U32 getComplexityReports() { return mComplexityReports; }
  172. LL_INLINE U32 getTooComplexReports() { return mTooComplexReports; }
  173. private:
  174. void avatarRenderingStats();
  175. static void getAvatarRenderStatsCoro(const std::string& url,
  176. std::string region_name);
  177. static void sendAvatarRenderStatsCoro(const std::string& url,
  178. std::string region_name,
  179. const LLSD& data);
  180. public:
  181. LLStat mKBitStat;
  182. LLStat mLayersKBitStat;
  183. LLStat mObjectKBitStat;
  184. LLStat mAssetKBitStat;
  185. LLStat mTextureKBitStat;
  186. LLStat mObjectsDrawnStat;
  187. LLStat mObjectsCulledStat;
  188. LLStat mObjectsTestedStat;
  189. LLStat mObjectsComparedStat;
  190. LLStat mObjectsOccludedStat;
  191. LLStat mFPSStat;
  192. LLStat mPacketsInStat;
  193. LLStat mPacketsLostStat;
  194. LLStat mPacketsOutStat;
  195. LLStat mPacketsLostPercentStat;
  196. LLStat mTexturePacketsStat;
  197. LLStat mActualInKBitStat; // From the packet ring (when faking a bad connection)
  198. LLStat mActualOutKBitStat; // From the packet ring (when faking a bad connection)
  199. // Simulator stats
  200. LLStat mSimTimeDilation;
  201. LLStat mSimFPS;
  202. LLStat mSimPhysicsFPS;
  203. LLStat mSimAgentUPS;
  204. LLStat mSimScriptEPS;
  205. LLStat mSimFrameMsec;
  206. LLStat mSimNetMsec;
  207. LLStat mSimSimOtherMsec;
  208. LLStat mSimSimPhysicsMsec;
  209. LLStat mSimSimPhysicsStepMsec;
  210. LLStat mSimSimPhysicsShapeUpdateMsec;
  211. LLStat mSimSimPhysicsOtherMsec;
  212. LLStat mSimSimAIStepMsec;
  213. LLStat mSimSimSkippedSilhouetteSteps;
  214. LLStat mSimSimPctSteppedCharacters;
  215. LLStat mSimAgentMsec;
  216. LLStat mSimImagesMsec;
  217. LLStat mSimScriptMsec;
  218. LLStat mSimSpareMsec;
  219. LLStat mSimSleepMsec;
  220. LLStat mSimPumpIOMsec;
  221. LLStat mSimMainAgents;
  222. LLStat mSimChildAgents;
  223. LLStat mSimObjects;
  224. LLStat mSimActiveObjects;
  225. LLStat mSimActiveScripts;
  226. LLStat mSimPctScriptsRun;
  227. LLStat mSimInPPS;
  228. LLStat mSimOutPPS;
  229. LLStat mSimPendingDownloads;
  230. LLStat mSimPendingUploads;
  231. LLStat mSimPendingLocalUploads;
  232. LLStat mSimTotalUnackedBytes;
  233. LLStat mPhysicsPinnedTasks;
  234. LLStat mPhysicsLODTasks;
  235. LLStat mPhysicsMemoryAllocated;
  236. LLStat mSimPingStat;
  237. // Actual frame render time stats (in ms), i.e. excluding any frame-rate
  238. // limiting added delay. HB
  239. LLStat mFrameRenderTime;
  240. private:
  241. F64 mStats[ST_COUNT];
  242. F64 mLastTimeDiff; // used for time stat updates
  243. F32 mNextStatsSendingTime;
  244. F32 mNextAvStatsSendingTime;
  245. U32 mComplexityReports;
  246. U32 mTooComplexReports;
  247. };
  248. // Used by llviewermenu.cpp as a menu callback. Not strictly related to
  249. // LLViewerStats, so kept as a separate function.
  250. void output_statistics(void*);
  251. extern LLViewerStats gViewerStats;
  252. extern LLFrameTimer gTextureTimer;
  253. extern U32 gObjectBits;
  254. #endif // LL_LLVIEWERSTATS_H