llfloaterstats.cpp 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856
  1. /**
  2. * @file llfloaterstats.cpp
  3. * @brief Container for statistics view
  4. *
  5. * $LicenseInfo:firstyear=2001&license=viewergpl$
  6. *
  7. * Copyright (c) 2001-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. #include "llviewerprecompiledheaders.h"
  33. #include "llfloaterstats.h"
  34. #include "llcontainerview.h"
  35. #include "llfloater.h"
  36. #include "llscrollcontainer.h"
  37. #include "llstatview.h"
  38. #include "lluictrlfactory.h"
  39. #include "llappviewer.h" // gFrameTimeSeconds
  40. #include "llpipeline.h"
  41. #include "llviewercontrol.h"
  42. #include "llviewerdisplay.h" // gLastFPSAverage
  43. #include "llviewerobjectlist.h"
  44. #include "llviewerstats.h"
  45. #include "llviewertexturelist.h"
  46. constexpr S32 LL_SCROLL_BORDER = 1;
  47. LLFloaterStats::LLFloaterStats(const LLSD& val)
  48. : LLFloater("stats"),
  49. mStatsContainer(NULL),
  50. mScrollContainer(NULL),
  51. mFPSStatBar(NULL),
  52. mLastFPSAverageCount(0),
  53. mStatBarMaxFPS(100.f),
  54. mStatBarLastMaxBW(0),
  55. mCurrentMaxFPS(0.f),
  56. mCurrentMaxBW(0.f),
  57. mLastStatRangeChange(0.f)
  58. {
  59. gPipeline.mNeedsDrawStats = true;
  60. LLUICtrlFactory::getInstance()->buildFloater(this,
  61. "floater_statistics.xml",
  62. NULL, false);
  63. LLRect stats_rect(0, getRect().getHeight() - LLFLOATER_HEADER_SIZE,
  64. getRect().getWidth() - LLFLOATER_CLOSE_BOX_SIZE, 0);
  65. mStatsContainer = new LLContainerView("statistics_view", stats_rect);
  66. mStatsContainer->showLabel(false);
  67. LLRect scroll_rect(LL_SCROLL_BORDER,
  68. getRect().getHeight() - LLFLOATER_HEADER_SIZE - LL_SCROLL_BORDER,
  69. getRect().getWidth() - LL_SCROLL_BORDER,
  70. LL_SCROLL_BORDER);
  71. mScrollContainer = new LLScrollableContainer("statistics_scroll",
  72. scroll_rect, mStatsContainer);
  73. mScrollContainer->setFollowsAll();
  74. mScrollContainer->setReserveScrollCorner(true);
  75. mStatsContainer->setScrollContainer(mScrollContainer);
  76. addChild(mScrollContainer);
  77. buildStats();
  78. }
  79. //virual
  80. LLFloaterStats::~LLFloaterStats()
  81. {
  82. if (!gSavedSettings.getBool("DebugShowRenderInfo"))
  83. {
  84. gPipeline.mNeedsDrawStats = false;
  85. }
  86. }
  87. void LLFloaterStats::setFPSStatBarRange(U32 average)
  88. {
  89. mStatBarMaxFPS = (F32)((average / 50U + 1U) * 50U);
  90. mFPSStatBar->mMaxBar = mStatBarMaxFPS;
  91. mFPSStatBar->mTickSpacing = mStatBarMaxFPS / 10.f;
  92. mFPSStatBar->mLabelSpacing = mStatBarMaxFPS / 5.f;
  93. mCurrentMaxFPS = 0.f;
  94. mLastStatRangeChange = gFrameTimeSeconds;
  95. }
  96. void LLFloaterStats::setBWStatBarRange(U32 max)
  97. {
  98. mStatBarLastMaxBW = llmin(((max / 1000U + 1U) * 1000U), 1000000U);
  99. mBWStatBar->mMaxBar = mStatBarLastMaxBW;
  100. mBWStatBar->mTickSpacing = mStatBarLastMaxBW / 10.f;
  101. mBWStatBar->mLabelSpacing = mStatBarLastMaxBW / 2.f;
  102. mCurrentMaxBW = 0.f;
  103. mLastStatRangeChange = gFrameTimeSeconds;
  104. }
  105. // NOTE: this cannot be implemented as a postBuild() (would cause a crash).
  106. void LLFloaterStats::buildStats()
  107. {
  108. LLRect rect;
  109. // Basic stats
  110. LLStatView* stat_viewp = new LLStatView("basic stat view", "Basic",
  111. "OpenDebugStatBasic", rect);
  112. addStatView(stat_viewp);
  113. mFPSStatBar = stat_viewp->addStat("FPS",
  114. &gViewerStats.mFPSStat,
  115. "DebugStatModeFPS", true, true);
  116. mFPSStatBar->setUnitLabel(" fps");
  117. mFPSStatBar->mMinBar = 0.f;
  118. mFPSStatBar->mPrecision = 1;
  119. setFPSStatBarRange(100);
  120. mLastStatRangeChange = 0.f;
  121. mBWStatBar = stat_viewp->addStat("Bandwidth",
  122. &gViewerStats.mKBitStat,
  123. "DebugStatModeBandwidth", true, false);
  124. mBWStatBar->setUnitLabel(" Kbps");
  125. mBWStatBar->mMinBar = 0.f;
  126. mBWStatBar->mMaxBar = 2048.f;
  127. mBWStatBar->mTickSpacing = 256.f;
  128. mBWStatBar->mLabelSpacing = 512.f;
  129. LLStatBar* stat_barp =
  130. stat_viewp->addStat("Packet loss",
  131. &gViewerStats.mPacketsLostPercentStat,
  132. "DebugStatModePacketLoss");
  133. stat_barp->setUnitLabel(" %");
  134. stat_barp->mMinBar = 0.f;
  135. stat_barp->mMaxBar = 5.f;
  136. stat_barp->mTickSpacing = 1.f;
  137. stat_barp->mLabelSpacing = 1.f;
  138. stat_barp->mPerSec = false;
  139. stat_barp->mDisplayMean = true;
  140. stat_barp->mPrecision = 1;
  141. stat_barp = stat_viewp->addStat("Ping sim",
  142. &gViewerStats.mSimPingStat,
  143. "DebugStatMode");
  144. stat_barp->setUnitLabel(" ms");
  145. stat_barp->mMinBar = 0.f;
  146. stat_barp->mMaxBar = 1000.f;
  147. stat_barp->mTickSpacing = 100.f;
  148. stat_barp->mLabelSpacing = 200.f;
  149. stat_barp->mPerSec = false;
  150. stat_barp->mDisplayMean = false;
  151. // Advanced stats
  152. stat_viewp = new LLStatView("advanced stat view", "Advanced",
  153. "OpenDebugStatAdvanced", rect);
  154. addStatView(stat_viewp);
  155. LLStatView* render_statviewp =
  156. stat_viewp->addStatView("render stat view", "Render",
  157. "OpenDebugStatRender", rect);
  158. stat_barp = render_statviewp->addStat("KTris drawn",
  159. &gPipeline.mTrianglesDrawnStat,
  160. "DebugStatModeKTrisDrawnFr");
  161. stat_barp->setUnitLabel("/fr");
  162. stat_barp->mMinBar = 0.f;
  163. stat_barp->mMaxBar = 1000.f;
  164. stat_barp->mTickSpacing = 250.f;
  165. stat_barp->mLabelSpacing = 500.f;
  166. stat_barp->mPerSec = false;
  167. stat_barp = render_statviewp->addStat("KTris drawn",
  168. &gPipeline.mTrianglesDrawnStat,
  169. "DebugStatModeKTrisDrawnSec");
  170. stat_barp->setUnitLabel("/s");
  171. stat_barp->mMinBar = 0.f;
  172. stat_barp->mMaxBar = 50000.f;
  173. stat_barp->mTickSpacing = 12500.f;
  174. stat_barp->mLabelSpacing = 25000.f;
  175. stat_barp = render_statviewp->addStat("Total objects",
  176. &gObjectList.mNumObjectsStat,
  177. "DebugStatModeTotalObjs");
  178. stat_barp->mMinBar = 0.f;
  179. stat_barp->mMaxBar = 15000.f;
  180. stat_barp->mTickSpacing = 2500.f;
  181. stat_barp->mLabelSpacing = 5000.f;
  182. stat_barp->mPerSec = false;
  183. stat_barp = render_statviewp->addStat("New objects",
  184. &gObjectList.mNumNewObjectsStat,
  185. "DebugStatModeNewObjs");
  186. stat_barp->setLabel("New Objs");
  187. stat_barp->setUnitLabel("/s");
  188. stat_barp->mMinBar = 0.f;
  189. stat_barp->mMaxBar = 1000.f;
  190. stat_barp->mTickSpacing = 100.f;
  191. stat_barp->mLabelSpacing = 500.f;
  192. // Texture statistics
  193. LLStatView* texture_statviewp =
  194. render_statviewp->addStatView("texture stat view", "Texture",
  195. "OpenDebugStatTexture", rect);
  196. stat_barp = texture_statviewp->addStat("Count",
  197. &gTextureList.sNumImagesStat,
  198. "DebugStatModeTextureCount");
  199. stat_barp->setUnitLabel("");
  200. stat_barp->mMinBar = 0.f;
  201. stat_barp->mMaxBar = 8000.f;
  202. stat_barp->mTickSpacing = 2000.f;
  203. stat_barp->mLabelSpacing = 4000.f;
  204. stat_barp->mPerSec = false;
  205. stat_barp = texture_statviewp->addStat("Raw count",
  206. &gTextureList.sNumRawImagesStat,
  207. "DebugStatModeRawCount");
  208. stat_barp->setUnitLabel("");
  209. stat_barp->mMinBar = 0.f;
  210. stat_barp->mMaxBar = 8000.f;
  211. stat_barp->mTickSpacing = 2000.f;
  212. stat_barp->mLabelSpacing = 4000.f;
  213. stat_barp->mPerSec = false;
  214. stat_barp = texture_statviewp->addStat("GL memory",
  215. &gTextureList.sGLTexMemStat,
  216. "DebugStatModeGLMem");
  217. stat_barp->setUnitLabel("");
  218. stat_barp->mMinBar = 0.f;
  219. stat_barp->mMaxBar = 512.f;
  220. stat_barp->mTickSpacing = 128.f;
  221. stat_barp->mLabelSpacing = 256.f;
  222. stat_barp->mPrecision = 1;
  223. stat_barp->mPerSec = false;
  224. stat_barp = texture_statviewp->addStat("Bound memory",
  225. &gTextureList.sGLBoundMemStat,
  226. "DebugStatModeBoundMem");
  227. stat_barp->setUnitLabel("");
  228. stat_barp->mMinBar = 0.f;
  229. stat_barp->mMaxBar = 512.f;
  230. stat_barp->mTickSpacing = 128.f;
  231. stat_barp->mLabelSpacing = 256.f;
  232. stat_barp->mPrecision = 1;
  233. stat_barp->mPerSec = false;
  234. // Network statistics
  235. LLStatView* net_statviewp = stat_viewp->addStatView("network stat view",
  236. "Network",
  237. "OpenDebugStatNet",
  238. rect);
  239. stat_barp = net_statviewp->addStat("Packets in",
  240. &gViewerStats.mPacketsInStat,
  241. "DebugStatModePacketsIn");
  242. stat_barp->setUnitLabel("/s");
  243. stat_barp->mMinBar = 0.f;
  244. stat_barp->mMaxBar = 1000.f;
  245. stat_barp->mTickSpacing = 100.f;
  246. stat_barp->mLabelSpacing = 250.f;
  247. stat_barp = net_statviewp->addStat("Packets out",
  248. &gViewerStats.mPacketsOutStat,
  249. "DebugStatModePacketsOut");
  250. stat_barp->setUnitLabel("/s");
  251. stat_barp->mMinBar = 0.f;
  252. stat_barp->mMaxBar = 100.f;
  253. stat_barp->mTickSpacing = 10.f;
  254. stat_barp->mLabelSpacing = 20.f;
  255. stat_barp = net_statviewp->addStat("Objects",
  256. &gViewerStats.mObjectKBitStat,
  257. "DebugStatModeObjects");
  258. stat_barp->setUnitLabel(" Kbps");
  259. stat_barp->mMinBar = 0.f;
  260. stat_barp->mMaxBar = 100.f;
  261. stat_barp->mTickSpacing = 10.f;
  262. stat_barp->mLabelSpacing = 20.f;
  263. stat_barp = net_statviewp->addStat("Texture",
  264. &gViewerStats.mTextureKBitStat,
  265. "DebugStatModeTexture");
  266. stat_barp->setUnitLabel(" Kbps");
  267. stat_barp->mMinBar = 0.f;
  268. stat_barp->mMaxBar = 100.f;
  269. stat_barp->mTickSpacing = 10.f;
  270. stat_barp->mLabelSpacing = 20.f;
  271. stat_barp = net_statviewp->addStat("Asset",
  272. &gViewerStats.mAssetKBitStat,
  273. "DebugStatModeAsset");
  274. stat_barp->setUnitLabel(" Kbps");
  275. stat_barp->mMinBar = 0.f;
  276. stat_barp->mMaxBar = 100.f;
  277. stat_barp->mTickSpacing = 10.f;
  278. stat_barp->mLabelSpacing = 20.f;
  279. stat_barp = net_statviewp->addStat("Layers",
  280. &gViewerStats.mLayersKBitStat,
  281. "DebugStatModeLayers");
  282. stat_barp->setUnitLabel(" Kbps");
  283. stat_barp->mMinBar = 0.f;
  284. stat_barp->mMaxBar = 100.f;
  285. stat_barp->mTickSpacing = 10.f;
  286. stat_barp->mLabelSpacing = 20.f;
  287. stat_barp = net_statviewp->addStat("Actual in",
  288. &gViewerStats.mActualInKBitStat,
  289. "DebugStatModeActualIn", true, false);
  290. stat_barp->setUnitLabel(" Kbps");
  291. stat_barp->mMinBar = 0.f;
  292. stat_barp->mMaxBar = 2048.f;
  293. stat_barp->mTickSpacing = 128.f;
  294. stat_barp->mLabelSpacing = 256.f;
  295. stat_barp = net_statviewp->addStat("Actual out",
  296. &gViewerStats.mActualOutKBitStat,
  297. "DebugStatModeActualOut", true, false);
  298. stat_barp->setUnitLabel(" Kbps");
  299. stat_barp->mMinBar = 0.f;
  300. stat_barp->mMaxBar = 512.f;
  301. stat_barp->mTickSpacing = 128.f;
  302. stat_barp->mLabelSpacing = 256.f;
  303. // Simulator stats
  304. LLStatView* sim_statviewp = new LLStatView("sim stat view", "Simulator",
  305. "OpenDebugStatSim", rect);
  306. addStatView(sim_statviewp);
  307. stat_barp = sim_statviewp->addStat("Time dilation",
  308. &gViewerStats.mSimTimeDilation,
  309. "DebugStatModeTimeDialation");
  310. stat_barp->mPrecision = 2;
  311. stat_barp->mMinBar = 0.f;
  312. stat_barp->mMaxBar = 1.f;
  313. stat_barp->mTickSpacing = 0.25f;
  314. stat_barp->mLabelSpacing = 0.5f;
  315. stat_barp->mPerSec = false;
  316. stat_barp->mDisplayMean = false;
  317. stat_barp = sim_statviewp->addStat("Sim FPS",
  318. &gViewerStats.mSimFPS,
  319. "DebugStatModeSimFPS");
  320. stat_barp->mPrecision = 1;
  321. stat_barp->mMinBar = 0.f;
  322. stat_barp->mMaxBar = 60.f;
  323. stat_barp->mTickSpacing = 10.f;
  324. stat_barp->mLabelSpacing = 20.f;
  325. stat_barp->mPerSec = false;
  326. stat_barp->mDisplayMean = false;
  327. stat_barp = sim_statviewp->addStat("Physics FPS",
  328. &gViewerStats.mSimPhysicsFPS,
  329. "DebugStatModePhysicsFPS");
  330. stat_barp->mPrecision = 1;
  331. stat_barp->mMinBar = 0.f;
  332. stat_barp->mMaxBar = 60.f;
  333. stat_barp->mTickSpacing = 10.0f;
  334. stat_barp->mLabelSpacing = 20.f;
  335. stat_barp->mPerSec = false;
  336. stat_barp->mDisplayMean = false;
  337. LLStatView* phys_details_viewp =
  338. sim_statviewp->addStatView("phys detail view", "Physics details",
  339. "OpenDebugStatPhysicsDetails", rect);
  340. stat_barp = phys_details_viewp->addStat("Pinned objects",
  341. &gViewerStats.mPhysicsPinnedTasks,
  342. "DebugStatModePinnedObjects");
  343. stat_barp->mPrecision = 0;
  344. stat_barp->mMinBar = 0.f;
  345. stat_barp->mMaxBar = 500.f;
  346. stat_barp->mTickSpacing = 50.f;
  347. stat_barp->mLabelSpacing = 100.f;
  348. stat_barp->mPerSec = false;
  349. stat_barp->mDisplayMean = false;
  350. stat_barp = phys_details_viewp->addStat("Low LOD objects",
  351. &gViewerStats.mPhysicsLODTasks,
  352. "DebugStatModeLowLODObjects");
  353. stat_barp->mPrecision = 0;
  354. stat_barp->mMinBar = 0.f;
  355. stat_barp->mMaxBar = 500.f;
  356. stat_barp->mTickSpacing = 50.f;
  357. stat_barp->mLabelSpacing = 100.f;
  358. stat_barp->mPerSec = false;
  359. stat_barp->mDisplayMean = false;
  360. stat_barp =
  361. phys_details_viewp->addStat("Memory allocated",
  362. &gViewerStats.mPhysicsMemoryAllocated,
  363. "DebugStatModeMemoryAllocated");
  364. stat_barp->setUnitLabel(" MB");
  365. stat_barp->mPrecision = 0;
  366. stat_barp->mMinBar = 0.f;
  367. stat_barp->mMaxBar = 1024.f;
  368. stat_barp->mTickSpacing = 128.f;
  369. stat_barp->mLabelSpacing = 256.f;
  370. stat_barp->mPerSec = false;
  371. stat_barp->mDisplayMean = false;
  372. stat_barp = sim_statviewp->addStat("Agent updates/s",
  373. &gViewerStats.mSimAgentUPS,
  374. "DebugStatModeAgentUpdatesSec");
  375. stat_barp->mPrecision = 1;
  376. stat_barp->mMinBar = 0.f;
  377. stat_barp->mMaxBar = 60.f;
  378. stat_barp->mTickSpacing = 10.f;
  379. stat_barp->mLabelSpacing = 20.f;
  380. stat_barp->mPerSec = false;
  381. stat_barp->mDisplayMean = false;
  382. stat_barp = sim_statviewp->addStat("Main agents",
  383. &gViewerStats.mSimMainAgents,
  384. "DebugStatModeMainAgents");
  385. stat_barp->mPrecision = 0;
  386. stat_barp->mMinBar = 0.f;
  387. stat_barp->mMaxBar = 80.f;
  388. stat_barp->mTickSpacing = 10.f;
  389. stat_barp->mLabelSpacing = 40.f;
  390. stat_barp->mPerSec = false;
  391. stat_barp->mDisplayMean = false;
  392. stat_barp = sim_statviewp->addStat("Child agents",
  393. &gViewerStats.mSimChildAgents,
  394. "DebugStatModeChildAgents");
  395. stat_barp->mPrecision = 0;
  396. stat_barp->mMinBar = 0.f;
  397. stat_barp->mMaxBar = 40.f;
  398. stat_barp->mTickSpacing = 5.f;
  399. stat_barp->mLabelSpacing = 10.f;
  400. stat_barp->mPerSec = false;
  401. stat_barp->mDisplayMean = false;
  402. stat_barp = sim_statviewp->addStat("Objects",
  403. &gViewerStats.mSimObjects,
  404. "DebugStatModeSimObjects");
  405. stat_barp->mPrecision = 0;
  406. stat_barp->mMinBar = 0.f;
  407. stat_barp->mMaxBar = 30000.f;
  408. stat_barp->mTickSpacing = 5000.f;
  409. stat_barp->mLabelSpacing = 10000.f;
  410. stat_barp->mPerSec = false;
  411. stat_barp->mDisplayMean = false;
  412. stat_barp = sim_statviewp->addStat("Active objects",
  413. &gViewerStats.mSimActiveObjects,
  414. "DebugStatModeSimActiveObjects");
  415. stat_barp->mPrecision = 0;
  416. stat_barp->mMinBar = 0.f;
  417. stat_barp->mMaxBar = 2000.f;
  418. stat_barp->mTickSpacing = 250.f;
  419. stat_barp->mLabelSpacing = 500.f;
  420. stat_barp->mPerSec = false;
  421. stat_barp->mDisplayMean = false;
  422. stat_barp = sim_statviewp->addStat("Active scripts",
  423. &gViewerStats.mSimActiveScripts,
  424. "DebugStatModeSimActiveScripts");
  425. stat_barp->mPrecision = 0;
  426. stat_barp->mMinBar = 0.f;
  427. stat_barp->mMaxBar = 20000.f;
  428. stat_barp->mTickSpacing = 2500.f;
  429. stat_barp->mLabelSpacing = 5000.f;
  430. stat_barp->mPerSec = false;
  431. stat_barp->mDisplayMean = false;
  432. stat_barp = sim_statviewp->addStat("Scripts run",
  433. &gViewerStats.mSimPctScriptsRun,
  434. "DebugStatModeSimPctScriptsRun");
  435. stat_barp->setUnitLabel(" %");
  436. stat_barp->mMinBar = 0.f;
  437. stat_barp->mMaxBar = 100.f;
  438. stat_barp->mTickSpacing = 10.f;
  439. stat_barp->mLabelSpacing = 20.f;
  440. stat_barp->mPerSec = false;
  441. stat_barp->mDisplayMean = true;
  442. stat_barp->mPrecision = 1;
  443. stat_barp = sim_statviewp->addStat("Script events",
  444. &gViewerStats.mSimScriptEPS,
  445. "DebugStatModeSimScriptEvents");
  446. stat_barp->setUnitLabel(" e/s");
  447. stat_barp->mPrecision = 0;
  448. stat_barp->mMinBar = 0.f;
  449. stat_barp->mMaxBar = 10000.f;
  450. stat_barp->mTickSpacing = 1000.f;
  451. stat_barp->mLabelSpacing = 2000.f;
  452. stat_barp->mPerSec = false;
  453. stat_barp->mDisplayMean = false;
  454. // Pathfinding stats in simulator stats
  455. LLStatView* path_finding_viewp =
  456. sim_statviewp->addStatView("pathfinding view", "Pathfinding",
  457. "OpenDebugStatSimPathFindingDetails", rect);
  458. stat_barp = path_finding_viewp->addStat("AI step time",
  459. &gViewerStats.mSimSimAIStepMsec,
  460. "DebugStatModeSimSimAIStepMsec");
  461. stat_barp->setUnitLabel(" ms");
  462. stat_barp->mPrecision = 3;
  463. stat_barp->mMinBar = 0.f;
  464. stat_barp->mMaxBar = 45.f;
  465. stat_barp->mTickSpacing = 10.f;
  466. stat_barp->mLabelSpacing = 20.f;
  467. stat_barp->mPerSec = false;
  468. stat_barp->mDisplayMean = false;
  469. stat_barp =
  470. path_finding_viewp->addStat("Skipped silhouette steps",
  471. &gViewerStats.mSimSimSkippedSilhouetteSteps,
  472. "DebugStatModeSimSimSkippedSilhouetteSteps");
  473. stat_barp->setUnitLabel("/s");
  474. stat_barp->mMinBar = 0.f;
  475. stat_barp->mMaxBar = 45.f;
  476. stat_barp->mTickSpacing = 4.f;
  477. stat_barp->mLabelSpacing = 8.f;
  478. stat_barp =
  479. path_finding_viewp->addStat("Characters updated",
  480. &gViewerStats.mSimSimPctSteppedCharacters,
  481. "DebugStatModemSimSimPctSteppedCharacters");
  482. stat_barp->setUnitLabel(" %");
  483. stat_barp->mMinBar = 0.f;
  484. stat_barp->mMaxBar = 100.f;
  485. stat_barp->mTickSpacing = 10.f;
  486. stat_barp->mLabelSpacing = 20.f;
  487. stat_barp->mPerSec = false;
  488. stat_barp->mDisplayMean = true;
  489. stat_barp->mPrecision = 1;
  490. // Simulator stats (continued)
  491. stat_barp = sim_statviewp->addStat("Packets in",
  492. &gViewerStats.mSimInPPS,
  493. "DebugStatModeSimInPPS");
  494. stat_barp->setUnitLabel(" p/s");
  495. stat_barp->mPrecision = 0;
  496. stat_barp->mMinBar = 0.f;
  497. stat_barp->mMaxBar = 20000.f;
  498. stat_barp->mTickSpacing = 2500.f;
  499. stat_barp->mLabelSpacing = 10000.f;
  500. stat_barp->mPerSec = false;
  501. stat_barp->mDisplayMean = false;
  502. stat_barp = sim_statviewp->addStat("Packets out",
  503. &gViewerStats.mSimOutPPS,
  504. "DebugStatModeSimOutPPS");
  505. stat_barp->setUnitLabel(" p/s");
  506. stat_barp->mPrecision = 0;
  507. stat_barp->mMinBar = 0.f;
  508. stat_barp->mMaxBar = 20000.f;
  509. stat_barp->mTickSpacing = 2500.f;
  510. stat_barp->mLabelSpacing = 10000.f;
  511. stat_barp->mPerSec = false;
  512. stat_barp->mDisplayMean = false;
  513. stat_barp = sim_statviewp->addStat("Pending downloads",
  514. &gViewerStats.mSimPendingDownloads,
  515. "DebugStatModeSimPendingDownloads");
  516. stat_barp->mPrecision = 0;
  517. stat_barp->mMinBar = 0.f;
  518. stat_barp->mMaxBar = 800.f;
  519. stat_barp->mTickSpacing = 100.f;
  520. stat_barp->mLabelSpacing = 200.f;
  521. stat_barp->mPerSec = false;
  522. stat_barp->mDisplayMean = false;
  523. stat_barp = sim_statviewp->addStat("Pending uploads",
  524. &gViewerStats.mSimPendingUploads,
  525. "SimPendingUploads");
  526. stat_barp->mPrecision = 0;
  527. stat_barp->mMinBar = 0.f;
  528. stat_barp->mMaxBar = 100.f;
  529. stat_barp->mTickSpacing = 25.f;
  530. stat_barp->mLabelSpacing = 50.f;
  531. stat_barp->mPerSec = false;
  532. stat_barp->mDisplayMean = false;
  533. stat_barp = sim_statviewp->addStat("Total unacked bytes",
  534. &gViewerStats.mSimTotalUnackedBytes,
  535. "DebugStatModeSimTotalUnackedBytes");
  536. stat_barp->setUnitLabel(" Kb");
  537. stat_barp->mPrecision = 0;
  538. stat_barp->mMinBar = 0.f;
  539. stat_barp->mMaxBar = 10000.f;
  540. stat_barp->mTickSpacing = 2500.f;
  541. stat_barp->mLabelSpacing = 5000.f;
  542. stat_barp->mPerSec = false;
  543. stat_barp->mDisplayMean = false;
  544. LLStatView* sim_time_viewp =
  545. sim_statviewp->addStatView("sim perf view", "Time (ms)",
  546. "OpenDebugStatSimTime", rect);
  547. stat_barp = sim_time_viewp->addStat("Total frame time",
  548. &gViewerStats.mSimFrameMsec,
  549. "DebugStatModeSimFrameMsec");
  550. stat_barp->setUnitLabel(" ms");
  551. stat_barp->mPrecision = 1;
  552. stat_barp->mMinBar = 0.f;
  553. stat_barp->mMaxBar = 50.f;
  554. stat_barp->mTickSpacing = 12.5f;
  555. stat_barp->mLabelSpacing = 25.f;
  556. stat_barp->mPerSec = false;
  557. stat_barp->mDisplayMean = false;
  558. stat_barp = sim_time_viewp->addStat("Net time",
  559. &gViewerStats.mSimNetMsec,
  560. "DebugStatModeSimNetMsec");
  561. stat_barp->setUnitLabel(" ms");
  562. stat_barp->mPrecision = 1;
  563. stat_barp->mMinBar = 0.f;
  564. stat_barp->mMaxBar = 50.f;
  565. stat_barp->mTickSpacing = 12.5f;
  566. stat_barp->mLabelSpacing = 25.f;
  567. stat_barp->mPerSec = false;
  568. stat_barp->mDisplayMean = false;
  569. stat_barp = sim_time_viewp->addStat("Physics time",
  570. &gViewerStats.mSimSimPhysicsMsec,
  571. "DebugStatModeSimSimPhysicsMsec");
  572. stat_barp->setUnitLabel(" ms");
  573. stat_barp->mPrecision = 1;
  574. stat_barp->mMinBar = 0.f;
  575. stat_barp->mMaxBar = 20.f;
  576. stat_barp->mTickSpacing = 5.f;
  577. stat_barp->mLabelSpacing = 10.f;
  578. stat_barp->mPerSec = false;
  579. stat_barp->mDisplayMean = false;
  580. stat_barp = sim_time_viewp->addStat("Simulation time",
  581. &gViewerStats.mSimSimOtherMsec,
  582. "DebugStatModeSimSimOtherMsec");
  583. stat_barp->setUnitLabel(" ms");
  584. stat_barp->mPrecision = 1;
  585. stat_barp->mMinBar = 0.f;
  586. stat_barp->mMaxBar = 20.f;
  587. stat_barp->mTickSpacing = 5.f;
  588. stat_barp->mLabelSpacing = 10.f;
  589. stat_barp->mPerSec = false;
  590. stat_barp->mDisplayMean = false;
  591. stat_barp = sim_time_viewp->addStat("Agent time",
  592. &gViewerStats.mSimAgentMsec,
  593. "DebugStatModeSimAgentMsec");
  594. stat_barp->setUnitLabel(" ms");
  595. stat_barp->mPrecision = 1;
  596. stat_barp->mMinBar = 0.f;
  597. stat_barp->mMaxBar = 20.f;
  598. stat_barp->mTickSpacing = 5.f;
  599. stat_barp->mLabelSpacing = 10.f;
  600. stat_barp->mPerSec = false;
  601. stat_barp->mDisplayMean = false;
  602. stat_barp = sim_time_viewp->addStat("Images time",
  603. &gViewerStats.mSimImagesMsec,
  604. "DebugStatModeSimImagesMsec");
  605. stat_barp->setUnitLabel(" ms");
  606. stat_barp->mPrecision = 1;
  607. stat_barp->mMinBar = 0.f;
  608. stat_barp->mMaxBar = 20.f;
  609. stat_barp->mTickSpacing = 5.f;
  610. stat_barp->mLabelSpacing = 10.f;
  611. stat_barp->mPerSec = false;
  612. stat_barp->mDisplayMean = false;
  613. stat_barp = sim_time_viewp->addStat("Script time",
  614. &gViewerStats.mSimScriptMsec,
  615. "DebugStatModeSimScriptMsec");
  616. stat_barp->setUnitLabel(" ms");
  617. stat_barp->mPrecision = 1;
  618. stat_barp->mMinBar = 0.f;
  619. stat_barp->mMaxBar = 40.f;
  620. stat_barp->mTickSpacing = 10.f;
  621. stat_barp->mLabelSpacing = 20.f;
  622. stat_barp->mPerSec = false;
  623. stat_barp->mDisplayMean = false;
  624. stat_barp = sim_time_viewp->addStat("Spare time",
  625. &gViewerStats.mSimSpareMsec,
  626. "DebugStatModeSimSpareMsec");
  627. stat_barp->setUnitLabel(" ms");
  628. stat_barp->mPrecision = 1;
  629. stat_barp->mMinBar = 0.f;
  630. stat_barp->mMaxBar = 20.f;
  631. stat_barp->mTickSpacing = 5.f;
  632. stat_barp->mLabelSpacing = 10.f;
  633. stat_barp->mPerSec = false;
  634. stat_barp->mDisplayMean = false;
  635. // 2nd level time blocks under 'Details' second
  636. LLStatView* detailed_time_viewp =
  637. sim_time_viewp->addStatView("sim perf view", "Time details (ms)",
  638. "OpenDebugStatSimTimeDetails", rect);
  639. {
  640. stat_barp =
  641. detailed_time_viewp->addStat("Physics step",
  642. &gViewerStats.mSimSimPhysicsStepMsec,
  643. "DebugStatModeSimSimPhysicsStepMsec");
  644. stat_barp->setUnitLabel(" ms");
  645. stat_barp->mPrecision = 1;
  646. stat_barp->mMinBar = 0.f;
  647. stat_barp->mMaxBar = 20.f;
  648. stat_barp->mTickSpacing = 5.f;
  649. stat_barp->mLabelSpacing = 10.f;
  650. stat_barp->mPerSec = false;
  651. stat_barp->mDisplayMean = false;
  652. stat_barp =
  653. detailed_time_viewp->addStat("Update phys. shapes",
  654. &gViewerStats.mSimSimPhysicsShapeUpdateMsec,
  655. "DebugStatModeSimSimPhysicsShapeUpdateMsec");
  656. stat_barp->setUnitLabel(" ms");
  657. stat_barp->mPrecision = 1;
  658. stat_barp->mMinBar = 0.f;
  659. stat_barp->mMaxBar = 20.f;
  660. stat_barp->mTickSpacing = 5.f;
  661. stat_barp->mLabelSpacing = 10.f;
  662. stat_barp->mPerSec = false;
  663. stat_barp->mDisplayMean = false;
  664. stat_barp = detailed_time_viewp->addStat("Physics other",
  665. &gViewerStats.mSimSimPhysicsOtherMsec,
  666. "DebugStatModeSimSimPhysicsOtherMsec");
  667. stat_barp->setUnitLabel(" ms");
  668. stat_barp->mPrecision = 1;
  669. stat_barp->mMinBar = 0.f;
  670. stat_barp->mMaxBar = 20.f;
  671. stat_barp->mTickSpacing = 5.f;
  672. stat_barp->mLabelSpacing = 10.f;
  673. stat_barp->mPerSec = false;
  674. stat_barp->mDisplayMean = false;
  675. stat_barp = detailed_time_viewp->addStat("Sleep time",
  676. &gViewerStats.mSimSleepMsec,
  677. "DebugStatModeSimSleepMsec");
  678. stat_barp->setUnitLabel(" ms");
  679. stat_barp->mPrecision = 1;
  680. stat_barp->mMinBar = 0.f;
  681. stat_barp->mMaxBar = 20.f;
  682. stat_barp->mTickSpacing = 5.f;
  683. stat_barp->mLabelSpacing = 10.f;
  684. stat_barp->mPerSec = false;
  685. stat_barp->mDisplayMean = false;
  686. stat_barp = detailed_time_viewp->addStat("Pump IO",
  687. &gViewerStats.mSimPumpIOMsec,
  688. "DebugStatModeSimPumpIOMsec");
  689. stat_barp->setUnitLabel(" ms");
  690. stat_barp->mPrecision = 1;
  691. stat_barp->mMinBar = 0.f;
  692. stat_barp->mMaxBar = 20.f;
  693. stat_barp->mTickSpacing = 5.f;
  694. stat_barp->mLabelSpacing = 10.f;
  695. stat_barp->mPerSec = false;
  696. stat_barp->mDisplayMean = false;
  697. }
  698. LLRect r = getRect();
  699. // Reshape based on the parameters we set.
  700. reshape(r.getWidth(), r.getHeight());
  701. }
  702. //virtual
  703. void LLFloaterStats::reshape(S32 width, S32 height, bool called_from_parent)
  704. {
  705. if (mStatsContainer)
  706. {
  707. LLRect rect = mStatsContainer->getRect();
  708. mStatsContainer->reshape(rect.getWidth() - 2, rect.getHeight());
  709. }
  710. LLFloater::reshape(width, height, called_from_parent);
  711. }
  712. void LLFloaterStats::addStatView(LLStatView* stat)
  713. {
  714. mStatsContainer->addChildAtEnd(stat);
  715. }
  716. //virtual
  717. void LLFloaterStats::onOpen()
  718. {
  719. LLFloater::onOpen();
  720. gSavedSettings.setBool("ShowDebugStats", true);
  721. reshape(getRect().getWidth(), getRect().getHeight());
  722. }
  723. //virtual
  724. void LLFloaterStats::onClose(bool app_quitting)
  725. {
  726. setVisible(false);
  727. if (!app_quitting)
  728. {
  729. gSavedSettings.setBool("ShowDebugStats", false);
  730. }
  731. }
  732. //virtual
  733. void LLFloaterStats::draw()
  734. {
  735. F32 fps = gViewerStats.mFPSStat.getCurrentPerSec();
  736. if (fps > mCurrentMaxFPS)
  737. {
  738. mCurrentMaxFPS = fps;
  739. }
  740. F32 bw = gViewerStats.mKBitStat.getMeanPerSec() * 1.5f;
  741. if (bw > mCurrentMaxBW)
  742. {
  743. mCurrentMaxBW = bw;
  744. mLastStatRangeChange = 0.f; // Change immediately
  745. }
  746. if (gFrameTimeSeconds - mLastStatRangeChange > 2.f)
  747. {
  748. if (gLastFPSAverage && gLastFPSAverage != mLastFPSAverageCount)
  749. {
  750. mLastFPSAverageCount = gLastFPSAverage;
  751. setFPSStatBarRange(mLastFPSAverageCount);
  752. }
  753. if (mCurrentMaxFPS > mStatBarMaxFPS && mCurrentMaxFPS > 50.f)
  754. {
  755. setFPSStatBarRange((U32)mCurrentMaxFPS - 49);
  756. }
  757. if (mCurrentMaxBW > mStatBarLastMaxBW)
  758. {
  759. setBWStatBarRange(mCurrentMaxBW);
  760. }
  761. }
  762. LLFloater::draw();
  763. }