Source code of Windows XP (NT5)
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.

101 lines
2.0 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1992 - 1993.
  5. //
  6. // File: perf.hxx
  7. //
  8. // Contents:
  9. //
  10. // Classes:
  11. //
  12. // Functions:
  13. //
  14. // History: 10-03-94 RichardW Created
  15. //
  16. //----------------------------------------------------------------------------
  17. #ifdef PERF
  18. typedef struct _SpmPerfCounter {
  19. ULONGLONG Time;
  20. ULONGLONG TotalTime;
  21. DWORD Count;
  22. DWORD Reserved;
  23. } SpmPerfCounter, * PSpmPerfCounter;
  24. typedef struct _SpmPerfArray {
  25. DWORD PerfId;
  26. DWORD cCounters;
  27. SpmPerfCounter Counters[1];
  28. } SpmPerfArray, * PSpmPerfArray;
  29. #define DECLARE_PERFARRAY(x) PSpmPerfArray x;
  30. DWORD
  31. SpmPerfRegister(DWORD cCounters);
  32. PSpmPerfArray
  33. SpmPerfInstanciate(DWORD PerfId);
  34. VOID
  35. SpmPerfRelease(PVOID pvPerf,
  36. char * pszBanner,
  37. char * *ppszCounterLabels);
  38. VOID
  39. SpmPerfDump( PVOID pvPerf,
  40. char * pszBanner,
  41. char * *ppszCounterLabels);
  42. VOID
  43. SpmPerfSetFile(char * pszFile);
  44. __inline
  45. VOID
  46. SpmPerfBegin(
  47. PVOID pvPerf,
  48. DWORD Counter)
  49. {
  50. PSpmPerfCounter pCounter;
  51. PSpmPerfArray pArray;
  52. pArray = (PSpmPerfArray) pvPerf;
  53. pCounter = &pArray->Counters[Counter];
  54. NtQuerySystemTime((PLARGE_INTEGER) &pCounter->Time);
  55. }
  56. __inline
  57. VOID
  58. SpmPerfEnd(
  59. PVOID pvPerf,
  60. DWORD Counter)
  61. {
  62. PSpmPerfCounter pCounter;
  63. ULONGLONG EndTime;
  64. PSpmPerfArray pArray;
  65. pArray = (PSpmPerfArray) pvPerf;
  66. pCounter = &pArray->Counters[Counter];
  67. NtQuerySystemTime((PLARGE_INTEGER) &EndTime);
  68. EndTime -= pCounter->Time;
  69. pCounter->Time = EndTime;
  70. pCounter->TotalTime += EndTime;
  71. pCounter->Count++;
  72. }
  73. #else // Not PERF
  74. #define DECLARE_PERFARRAY(x)
  75. #define SpmPerfRegister(x) 1
  76. #define SpmPerfInstanciate(x) NULL
  77. #define SpmPerfRelease(x,y,z)
  78. #define SpmPerfBegin(x,y)
  79. #define SpmPerfEnd(x,y)
  80. #define SpmPerfSetFile(x)
  81. #endif // PERF or not to PERF