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.

78 lines
1.7 KiB

  1. #ifndef _PROFILE_H_
  2. #define _PROFILE_H_
  3. // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  4. //
  5. // PROFILE.H
  6. //
  7. // Profiling classes for use with IceCAP profiling
  8. //
  9. //
  10. // Copyright 1986-1997 Microsoft Corporation, All Rights Reserved
  11. //
  12. // ========================================================================
  13. //
  14. // CLASS CProfiledBlock
  15. //
  16. // Profiles any block of code in which an instance of this class exists.
  17. //
  18. // To use, just declare one of these in the block you want profiled:
  19. //
  20. // ...
  21. // {
  22. // CProfiledBlock profiledBlock;
  23. //
  24. // //
  25. // // Do stuff to be profiled
  26. // //
  27. // ...
  28. //
  29. // //
  30. // // Do more stuff to be profiled
  31. // //
  32. // ...
  33. // }
  34. //
  35. // //
  36. // // Do stuff that isn't to be profiled
  37. // //
  38. // ...
  39. //
  40. // and the block is automatically profiled. Why bother? Because
  41. // you don't need to have any cleanup code; profiling is automatically
  42. // turned off when execution leaves the block, even if via
  43. // an exception thrown from any of the synchronized stuff. Also,
  44. // profiling information for initialization of local objects
  45. // is automatically gathered as long as the profiled block is
  46. // the first thing declared.
  47. //
  48. class CProfiledBlock
  49. {
  50. public:
  51. #ifdef PROFILING
  52. // CREATORS
  53. //
  54. CProfiledBlock() { StartCAP(); }
  55. ~CProfiledBlock() { StopCAP(); }
  56. // MANIPULATORS
  57. //
  58. void Suspend() { SuspendCAP(); }
  59. void Resume() { ResumeCAP(); }
  60. #else // !defined(PROFILING)
  61. // CREATORS
  62. //
  63. CProfiledBlock() {}
  64. ~CProfiledBlock() {}
  65. // MANIPULATORS
  66. //
  67. void Suspend() {}
  68. void Resume() {}
  69. #endif // PROFILING
  70. };
  71. #endif // !defined(_PROFILE_H_)