home *** CD-ROM | disk | FTP | other *** search
/ GameStar 2006 March / Gamestar_82_2006-03_dvd.iso / DVDStar / Editace / quake4_sdkv10.exe / source / idlib / TimingCollection.h < prev    next >
C/C++ Source or Header  |  2005-11-14  |  2KB  |  101 lines

  1. #ifndef __TIMINGCOLLECTION_H_
  2. #define __TIMINGCOLLECTION_H_
  3.  
  4. // Fixme!  Move this.  It doesn't belong in AI at all, obviously.
  5. #include "../idlib/Str.h"
  6. #include "../idlib/containers/List.h"
  7. #include "../idlib/containers/HashTable.h"
  8. #include "../framework/File.h"
  9. #include "Timer.h"
  10.  
  11. //-----------------------------------------------------------------------------
  12. //
  13. //                                rvTimingCollection
  14. //
  15. //-----------------------------------------------------------------------------
  16.  
  17. #define RV_TIMERCOLLECTION
  18.  
  19. #define START_PROFILING(a, b) (a)._TimingStart(b, __FILE__, __LINE__)
  20. #define STOP_PROFILING(a, b) (a)._TimingStop(b, __FILE__, __LINE__)
  21.  
  22. // Easy and quick way to remove all of this from the codebase
  23. #ifdef RV_TIMERCOLLECTION
  24.  
  25. #define MAX_TIMERS    16
  26.  
  27. class rvSingleTiming
  28. {
  29. public:
  30.     int                        mTotalUpdates;
  31.     double                    mCurValue;
  32.     double                    mTotalValue;
  33.     double                    mPeakValue;
  34.     double                    mLimit;
  35.     int                        mLimitExceeded;
  36.     int                        mLimitExceededTimesFive;
  37.     int                        mDisplayLevel;
  38.  
  39.     idStr                    mName;
  40.     idStr                    mParentName;
  41.  
  42.     idStr                    mStartFile;
  43.     int                        mStartLine;
  44.     idStr                    mEndFile;
  45.     int                        mEndLine;
  46.  
  47.     rvSingleTiming();
  48.     rvSingleTiming( idStr &newName );
  49.  
  50.     void                     Clear();
  51.     void                     OutputDataToFile( idFile *file, int framesRecorded );
  52.     void                     OutputInfoToFile( idFile *file );
  53. };
  54.  
  55. class rvTimingCollection
  56. {
  57. protected:
  58.     idTimer                    mTimer[MAX_TIMERS];
  59.     idStr                    mTimerName[MAX_TIMERS];
  60.  
  61.     idList<rvSingleTiming>    mTimings;
  62.     idHashTable    <int>        mTimingsIndex;
  63.  
  64.     int                        mCurTimer;
  65.     int                        mUpdates;
  66.     int                        mCurrentlyUpdating;
  67.     int                        mFramesRecorded;
  68.  
  69.     rvSingleTiming            *GetTiming( idStr &timingName );
  70.     void                    DisplayTimingValues( void );
  71.     void                    OutputToFile( void );
  72.  
  73. public:
  74.     rvTimingCollection();
  75.  
  76.     void                    InitFrame( bool inUse, bool displayText, bool outputFileWhenDone );
  77.     void                    _TimingStart( const char *timingName, const char *fileName, const int lineNum );
  78.     void                    _TimingStop( double msecLimit, const char *fileName, const int lineNum );
  79.     void                    AppendToDict( idDict* dict );
  80.     void                    Clear( void );
  81. };
  82.  
  83. #else
  84.  
  85. class rvTimingCollection
  86. {
  87. protected:
  88. public:
  89.     rvTimingCollection(){}
  90.  
  91.     void                    InitFrame( bool inUse, bool displayText, bool outputFileWhenDone ){}
  92.     void                    _TimingStart( const char *timingName, const char *fileName, const int lineNum ){}
  93.     void                    _TimingStop( double msecLimit, const char *fileName, const int lineNum ){}
  94.     void                    AppendToDict( idDict* dict ){}
  95.     void                    Clear( void ){}
  96. };
  97.  
  98. #endif
  99.  
  100. #endif
  101.