Leaked source code of windows server 2003
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.

61 lines
1.3 KiB

  1. //+------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1993.
  5. //
  6. // File: stopwtch.hxx
  7. //
  8. // Contents: class definition for performance timer
  9. //
  10. // Classes: CStopWatch
  11. //
  12. // Functions:
  13. //
  14. // History: 8-July-93 t-martig Created
  15. //
  16. //--------------------------------------------------------------------------
  17. #ifndef __STOPWTCH_H
  18. #define __STOPWTCH_H
  19. class CStopWatch
  20. {
  21. public:
  22. CStopWatch();
  23. ULONG Read ();
  24. void Reset ();
  25. ULONG Resolution ();
  26. private:
  27. LARGE_INTEGER liStart;
  28. LARGE_INTEGER liFreq;
  29. };
  30. // Helper functions to make the code cleaner when you want to be
  31. // able to get both the individual and average times.
  32. inline void ResetAverage( BOOL fAverage, CStopWatch &sw )
  33. {
  34. if (fAverage)
  35. sw.Reset();
  36. }
  37. inline void ResetNotAverage( BOOL fAverage, CStopWatch &sw )
  38. {
  39. if (!fAverage)
  40. sw.Reset();
  41. }
  42. inline void ReadAverage( BOOL fAverage, CStopWatch &sw,
  43. ULONG &ulTime, ULONG ulIterations )
  44. {
  45. if (fAverage)
  46. ulTime = sw.Read() / ulIterations;
  47. }
  48. inline void ReadNotAverage( BOOL fAverage, CStopWatch &sw, ULONG &ulTime )
  49. {
  50. if (!fAverage)
  51. ulTime = sw.Read();
  52. }
  53. #endif // __STOPWTCH_H