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.

72 lines
1.9 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose: Analogous to l2cache.h, this class represents information gleaned
  4. // from the 360's Performance Monitor Counters. In particular we
  5. // are interested in l2 cache misses and load-hit-stores.
  6. //
  7. //=============================================================================//
  8. #ifndef CPMCDATA_H
  9. #define CPMCDATA_H
  10. #ifdef _WIN32
  11. #pragma once
  12. #endif
  13. #ifndef _X360
  14. #error This file must only be compiled for XBOX360!
  15. #endif
  16. // Warning:
  17. // As written, this class only supports profiling thread 0, processor 0.
  18. class CPMCData
  19. {
  20. public:
  21. CPMCData();
  22. ~CPMCData() {};
  23. void Start( void );
  24. void End( void );
  25. /// This function should be called exactly once during the lifespan of the program;
  26. /// it will set up the counters to record the information we are interested in.
  27. /// This will stomp on whoever else might have set the performance counters elsewhere
  28. /// in the game.
  29. static void InitializeOnceProgramWide( void );
  30. static bool IsInitialized();
  31. //-------------------------------------------------------------------------
  32. // GetL2CacheMisses
  33. //-------------------------------------------------------------------------
  34. uint64 GetL2CacheMisses( void ) const
  35. {
  36. return m_Delta.L2CacheMiss;
  37. }
  38. uint64 GetLHS( void ) const
  39. {
  40. return m_Delta.LHS;
  41. }
  42. /*
  43. #ifdef DBGFLAG_VALIDATE
  44. void Validate( CValidator &validator, tchar *pchName ); // Validate our internal structures
  45. #endif // DBGFLAG_VALIDATE
  46. */
  47. private:
  48. /// represents saved numbers from the counters we are interested in
  49. struct PMCounters
  50. {
  51. uint64 L2CacheMiss;
  52. uint64 LHS; ///< load hit store
  53. PMCounters(int64 _l2cm, int64 _lhs ) : L2CacheMiss(_l2cm), LHS(_lhs) {};
  54. PMCounters() : L2CacheMiss(0), LHS(0) {};
  55. };
  56. PMCounters m_OnStart; ///< values when we began the timer
  57. PMCounters m_Delta ; ///< computed total delta between start/stop
  58. };
  59. #endif // CPMCDATA_H