/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. #ifndef LL_LLVIEWERSTATS_H
  27. #define LL_LLVIEWERSTATS_H
  28. #include "llstat.h"
  29. #include "lltextureinfo.h"
  30. class LLViewerStats : public LLSingleton<LLViewerStats>
  31. {
  32. public:
  33. LLStat mKBitStat;
  34. LLStat mLayersKBitStat;
  35. LLStat mObjectKBitStat;
  36. LLStat mAssetKBitStat;
  37. LLStat mTextureKBitStat;
  38. LLStat mVFSPendingOperations;
  39. LLStat mObjectsDrawnStat;
  40. LLStat mObjectsCulledStat;
  41. LLStat mObjectsTestedStat;
  42. LLStat mObjectsComparedStat;
  43. LLStat mObjectsOccludedStat;
  44. LLStat mFPSStat;
  45. LLStat mPacketsInStat;
  46. LLStat mPacketsLostStat;
  47. LLStat mPacketsOutStat;
  48. LLStat mPacketsLostPercentStat;
  49. LLStat mTexturePacketsStat;
  50. LLStat mActualInKBitStat; // From the packet ring (when faking a bad connection)
  51. LLStat mActualOutKBitStat; // From the packet ring (when faking a bad connection)
  52. LLStat mTrianglesDrawnStat;
  53. // Simulator stats
  54. LLStat mSimTimeDilation;
  55. LLStat mSimFPS;
  56. LLStat mSimPhysicsFPS;
  57. LLStat mSimAgentUPS;
  58. LLStat mSimScriptEPS;
  59. LLStat mSimFrameMsec;
  60. LLStat mSimNetMsec;
  61. LLStat mSimSimOtherMsec;
  62. LLStat mSimSimPhysicsMsec;
  63. LLStat mSimSimPhysicsStepMsec;
  64. LLStat mSimSimPhysicsShapeUpdateMsec;
  65. LLStat mSimSimPhysicsOtherMsec;
  66. LLStat mSimAgentMsec;
  67. LLStat mSimImagesMsec;
  68. LLStat mSimScriptMsec;
  69. LLStat mSimSpareMsec;
  70. LLStat mSimSleepMsec;
  71. LLStat mSimPumpIOMsec;
  72. LLStat mSimMainAgents;
  73. LLStat mSimChildAgents;
  74. LLStat mSimObjects;
  75. LLStat mSimActiveObjects;
  76. LLStat mSimActiveScripts;
  77. LLStat mSimInPPS;
  78. LLStat mSimOutPPS;
  79. LLStat mSimPendingDownloads;
  80. LLStat mSimPendingUploads;
  81. LLStat mSimPendingLocalUploads;
  82. LLStat mSimTotalUnackedBytes;
  83. LLStat mPhysicsPinnedTasks;
  84. LLStat mPhysicsLODTasks;
  85. LLStat mPhysicsMemoryAllocated;
  86. LLStat mSimPingStat;
  87. LLStat mNumImagesStat;
  88. LLStat mNumRawImagesStat;
  89. LLStat mGLTexMemStat;
  90. LLStat mGLBoundMemStat;
  91. LLStat mRawMemStat;
  92. LLStat mFormattedMemStat;
  93. LLStat mNumObjectsStat;
  94. LLStat mNumActiveObjectsStat;
  95. LLStat mNumNewObjectsStat;
  96. LLStat mNumSizeCulledStat;
  97. LLStat mNumVisCulledStat;
  98. void resetStats();
  99. public:
  100. // If you change this, please also add a corresponding text label
  101. // in statTypeToText in llviewerstats.cpp
  102. enum EStatType
  103. {
  104. ST_VERSION = 0,
  105. ST_AVATAR_EDIT_SECONDS = 1,
  106. ST_TOOLBOX_SECONDS = 2,
  107. ST_CHAT_COUNT = 3,
  108. ST_IM_COUNT = 4,
  109. ST_FULLSCREEN_BOOL = 5,
  110. ST_RELEASE_COUNT= 6,
  111. ST_CREATE_COUNT = 7,
  112. ST_REZ_COUNT = 8,
  113. ST_FPS_10_SECONDS = 9,
  114. ST_FPS_2_SECONDS = 10,
  115. ST_MOUSELOOK_SECONDS = 11,
  116. ST_FLY_COUNT = 12,
  117. ST_TELEPORT_COUNT = 13,
  118. ST_OBJECT_DELETE_COUNT = 14,
  119. ST_SNAPSHOT_COUNT = 15,
  120. ST_UPLOAD_SOUND_COUNT = 16,
  121. ST_UPLOAD_TEXTURE_COUNT = 17,
  122. ST_EDIT_TEXTURE_COUNT = 18,
  123. ST_KILLED_COUNT = 19,
  124. ST_FRAMETIME_JITTER = 20,
  125. ST_FRAMETIME_SLEW = 21,
  126. ST_INVENTORY_TOO_LONG = 22,
  127. ST_WEARABLES_TOO_LONG = 23,
  128. ST_LOGIN_SECONDS = 24,
  129. ST_LOGIN_TIMEOUT_COUNT = 25,
  130. ST_HAS_BAD_TIMER = 26,
  131. ST_DOWNLOAD_FAILED = 27,
  132. ST_LSL_SAVE_COUNT = 28,
  133. ST_UPLOAD_ANIM_COUNT = 29,
  134. ST_FPS_8_SECONDS = 30,
  135. ST_SIM_FPS_20_SECONDS = 31,
  136. ST_PHYS_FPS_20_SECONDS = 32,
  137. ST_LOSS_05_SECONDS = 33,
  138. ST_FPS_DROP_50_RATIO = 34,
  139. ST_ENABLE_VBO = 35,
  140. ST_DELTA_BANDWIDTH = 36,
  141. ST_MAX_BANDWIDTH = 37,
  142. ST_LIGHTING_DETAIL = 38,
  143. ST_VISIBLE_AVATARS = 39,
  144. ST_SHADER_OBJECTS = 40,
  145. ST_SHADER_ENVIRONMENT = 41,
  146. ST_DRAW_DIST = 42,
  147. ST_CHAT_BUBBLES = 43,
  148. ST_SHADER_AVATAR = 44,
  149. ST_FRAME_SECS = 45,
  150. ST_UPDATE_SECS = 46,
  151. ST_NETWORK_SECS = 47,
  152. ST_IMAGE_SECS = 48,
  153. ST_REBUILD_SECS = 49,
  154. ST_RENDER_SECS = 50,
  155. ST_CROSSING_AVG = 51,
  156. ST_CROSSING_MAX = 52,
  157. ST_LIBXUL_WIDGET_USED = 53, // Unused
  158. ST_WINDOW_WIDTH = 54,
  159. ST_WINDOW_HEIGHT = 55,
  160. ST_TEX_BAKES = 56,
  161. ST_TEX_REBAKES = 57,
  162. ST_COUNT = 58
  163. };
  164. LLViewerStats();
  165. ~LLViewerStats();
  166. // all return latest value of given stat
  167. F64 getStat(EStatType type) const;
  168. F64 setStat(EStatType type, F64 value); // set the stat to value
  169. F64 incStat(EStatType type, F64 value = 1.f); // add value to the stat
  170. void updateFrameStats(const F64 time_diff);
  171. void addToMessage(LLSD &body) const;
  172. struct StatsAccumulator
  173. {
  174. S32 mCount;
  175. F32 mSum;
  176. F32 mSumOfSquares;
  177. F32 mMinValue;
  178. F32 mMaxValue;
  179. U32 mCountOfNextUpdatesToIgnore;
  180. inline StatsAccumulator()
  181. {
  182. reset();
  183. }
  184. inline void push( F32 val )
  185. {
  186. if ( mCountOfNextUpdatesToIgnore > 0 )
  187. {
  188. mCountOfNextUpdatesToIgnore--;
  189. return;
  190. }
  191. mCount++;
  192. mSum += val;
  193. mSumOfSquares += val * val;
  194. if (mCount == 1 || val > mMaxValue)
  195. {
  196. mMaxValue = val;
  197. }
  198. if (mCount == 1 || val < mMinValue)
  199. {
  200. mMinValue = val;
  201. }
  202. }
  203. inline F32 getMean() const
  204. {
  205. return (mCount == 0) ? 0.f : ((F32)mSum)/mCount;
  206. }
  207. inline F32 getMinValue() const
  208. {
  209. return mMinValue;
  210. }
  211. inline F32 getMaxValue() const
  212. {
  213. return mMaxValue;
  214. }
  215. inline F32 getStdDev() const
  216. {
  217. const F32 mean = getMean();
  218. return (mCount == 0) ? 0.f : sqrt( mSumOfSquares/mCount - (mean * mean) );
  219. }
  220. inline U32 getCount() const
  221. {
  222. return mCount;
  223. }
  224. inline void reset()
  225. {
  226. mCount = 0;
  227. mSum = mSumOfSquares = 0.f;
  228. mMinValue = 0.0f;
  229. mMaxValue = 0.0f;
  230. mCountOfNextUpdatesToIgnore = 0;
  231. }
  232. inline LLSD getData() const
  233. {
  234. LLSD data;
  235. data["mean"] = getMean();
  236. data["std_dev"] = getStdDev();
  237. data["count"] = (S32)mCount;
  238. data["min"] = getMinValue();
  239. data["max"] = getMaxValue();
  240. return data;
  241. }
  242. };
  243. StatsAccumulator mAgentPositionSnaps;
  244. private:
  245. F64 mStats[ST_COUNT];
  246. F64 mLastTimeDiff; // used for time stat updates
  247. };
  248. static const F32 SEND_STATS_PERIOD = 300.0f;
  249. // The following are from (older?) statistics code found in appviewer.
  250. void init_statistics();
  251. void reset_statistics();
  252. void output_statistics(void*);
  253. void update_statistics(U32 frame_count);
  254. void send_stats();
  255. extern std::map<S32,LLFrameTimer> gDebugTimers;
  256. extern std::map<S32,std::string> gDebugTimerLabel;
  257. extern U32 gTotalTextureBytes;
  258. extern U32 gTotalObjectBytes;
  259. extern U32 gTotalTextureBytesPerBoostLevel[] ;
  260. #endif // LL_LLVIEWERSTATS_H