Counter Strike : Global Offensive Source Code
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.

106 lines
2.7 KiB

  1. //========= Copyright � 1996-2005, Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================//
  7. #ifndef DATATABLE_INSTRUMENTATION_SERVER_H
  8. #define DATATABLE_INSTRUMENTATION_SERVER_H
  9. #ifdef _WIN32
  10. #pragma once
  11. #endif
  12. #include "tier0/fasttimer.h"
  13. #include "iservernetworkable.h"
  14. class CDTISendTable;
  15. class SendTable;
  16. // Is instrumentation enabled?
  17. extern bool g_bServerDTIEnabled;
  18. // Types of things it times.
  19. typedef enum
  20. {
  21. SERVERDTI_CALCDELTA=0,
  22. SERVERDTI_ENCODE,
  23. SERVERDTI_SHOULDTRANSMIT,
  24. SERVERDTI_WRITE_DELTA_PROPS
  25. } ServerDTITimerType;
  26. // ------------------------------------------------------------------------------------------ //
  27. // Instrumentation functions.
  28. // ------------------------------------------------------------------------------------------ //
  29. // This is called at startup to enable or disable instrumentation.
  30. // If pFilename is null, no instrumentation is performed.
  31. void ServerDTI_Init( char const *pFilename );
  32. // This calls ServerDTI_Flush and cleans up.
  33. void ServerDTI_Term();
  34. // This writes out the instrumentation file.
  35. void ServerDTI_Flush();
  36. // Setup instrumentation on a CRecvDecoder.
  37. CDTISendTable* ServerDTI_HookTable( SendTable *pTable );
  38. void ServerDTI_AddEntityEncodeEvent( SendTable *pTable, float distToPlayer );
  39. // Used to tell if the entity is using manual or auto mode.
  40. void ServerDTI_RegisterNetworkStateChange( SendTable *pTable, bool bStateChanged );
  41. // ------------------------------------------------------------------------------------------ //
  42. // Helper class to place timers easily.
  43. // ------------------------------------------------------------------------------------------ //
  44. class CServerDTITimer
  45. {
  46. public:
  47. CServerDTITimer( const SendTable *pTable, ServerDTITimerType type );
  48. ~CServerDTITimer();
  49. private:
  50. const SendTable *m_pTable;
  51. ServerDTITimerType m_Type;
  52. CFastTimer m_Timer;
  53. };
  54. inline CServerDTITimer::CServerDTITimer( const SendTable *pTable, ServerDTITimerType type )
  55. {
  56. if ( g_bServerDTIEnabled )
  57. {
  58. m_pTable = pTable;
  59. m_Type = type;
  60. m_Timer.Start();
  61. }
  62. }
  63. inline CServerDTITimer::~CServerDTITimer()
  64. {
  65. if ( g_bServerDTIEnabled && m_pTable )
  66. {
  67. m_Timer.End();
  68. extern void _ServerDTI_HookTimer( const SendTable *pTable, ServerDTITimerType timerType, CCycleCount const &count );
  69. _ServerDTI_HookTimer( m_pTable, m_Type, m_Timer.GetDuration() );
  70. }
  71. }
  72. inline void ServerDTI_RegisterNetworkStateChange( SendTable *pTable, bool bStateChanged )
  73. {
  74. if ( g_bServerDTIEnabled )
  75. {
  76. extern void _ServerDTI_RegisterNetworkStateChange( SendTable *pTable, bool bStateChanged );
  77. _ServerDTI_RegisterNetworkStateChange( pTable, bStateChanged );
  78. }
  79. }
  80. #endif // DATATABLE_INSTRUMENTATION_SERVER_H