Team Fortress 2 Source Code as on 22/4/2020
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

131 lines
2.7 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================//
  7. #include "quakedef.h"
  8. #include "enginestats.h"
  9. #include "basetypes.h"
  10. #include "clientstats.h"
  11. #include "limits.h"
  12. #include "sysexternal.h"
  13. #include "gl_matsysiface.h"
  14. #include "filesystem_engine.h"
  15. #include "tier0/vprof.h"
  16. // memdbgon must be the last include file in a .cpp file!!!
  17. #include "tier0/memdbgon.h"
  18. //-----------------------------------------------------------------------------
  19. // itty bitty interface for stat time
  20. //-----------------------------------------------------------------------------
  21. class CStatTime : public IClientStatsTime
  22. {
  23. public:
  24. float GetTime()
  25. {
  26. return Sys_FloatTime();
  27. }
  28. };
  29. CStatTime g_StatTime;
  30. CEngineStats::CEngineStats() : m_InFrame( false )
  31. {
  32. m_bInRun = false;
  33. }
  34. void CEngineStats::BeginRun( void )
  35. {
  36. m_bInRun = true;
  37. m_totalNumFrames = 0;
  38. // frame timing data
  39. m_runStartTime = Sys_FloatTime();
  40. }
  41. void CEngineStats::EndRun( void )
  42. {
  43. m_runEndTime = Sys_FloatTime();
  44. m_bInRun = false;
  45. }
  46. void CEngineStats::BeginFrame( void )
  47. {
  48. m_bPaused = false;
  49. m_InFrame = false;
  50. }
  51. void CEngineStats::ComputeFrameTimeStats( void )
  52. {
  53. m_StatGroup.m_StatFrameTime[ENGINE_STATS_FRAME_TIME] = m_flFrameTime / 1000.0f;
  54. m_StatGroup.m_StatFrameTime[ENGINE_STATS_FPS_VARIABILITY] = m_flFPSVariability / 1000.0f;
  55. m_StatGroup.m_StatFrameTime[ENGINE_STATS_FPS] = (m_flFrameTime != 0.0f) ? ( 1.0f / (1000.0f * m_flFrameTime) ) : 0.0f;
  56. }
  57. void CEngineStats::EndFrame( void )
  58. {
  59. if (!m_InFrame)
  60. return;
  61. }
  62. //-----------------------------------------------------------------------------
  63. // Advances the next frame for the stats...
  64. //-----------------------------------------------------------------------------
  65. void CEngineStats::NextFrame()
  66. {
  67. }
  68. //-----------------------------------------------------------------------------
  69. // Pause those stats!
  70. //-----------------------------------------------------------------------------
  71. void CEngineStats::PauseStats( bool bPaused )
  72. {
  73. if (bPaused)
  74. {
  75. if (m_InFrame)
  76. {
  77. m_bPaused = true;
  78. m_InFrame = false;
  79. }
  80. }
  81. else // !bPaused
  82. {
  83. if (m_bPaused)
  84. {
  85. m_InFrame = true;
  86. m_bPaused = false;
  87. }
  88. }
  89. }
  90. //-----------------------------------------------------------------------------
  91. // returns timed stats
  92. //-----------------------------------------------------------------------------
  93. double CEngineStats::TimedStatInFrame( EngineTimedStatId_t stat ) const
  94. {
  95. return m_StatGroup.m_StatFrameTime[stat];
  96. }
  97. double CEngineStats::TotalTimedStat( EngineTimedStatId_t stat ) const
  98. {
  99. return m_StatGroup.m_TotalStatTime[stat];
  100. }
  101. double CEngineStats::GetRunTime( void )
  102. {
  103. return m_runEndTime - m_runStartTime;
  104. }