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.

174 lines
5.0 KiB

  1. /*++
  2. Copyright (C) 1997-2001 Microsoft Corporation
  3. Module Name:
  4. PERFCACH.H
  5. Abstract:
  6. Defines data useful for the NT performance providers.
  7. History:
  8. a-davj 04-Mar-97 Created.
  9. --*/
  10. #define PERMANENT 0xFFFFFFFF
  11. // If an object has not be retrieved in this many MS, the stop
  12. // automatically getting it
  13. #define MAX_UNUSED_KEEP 30000
  14. // Define how big the buffers will start as. This size should be a bit
  15. // bigger than the "standard" counters and thus reallocations shouldnt
  16. // be necessary
  17. #define INITIAL_ALLOCATION 25000
  18. // maximum age in ms of the "newest" data in the cache
  19. #define MAX_NEW_AGE 2000
  20. // maximum age in ms of the "oldest" data in the cache
  21. #define MAX_OLD_AGE 10000
  22. // minimum time difference between old and new sample
  23. #define MIN_TIME_DIFF 1000
  24. typedef struct _LINESTRUCT
  25. {
  26. LONGLONG lnNewTime;
  27. LONGLONG lnOldTime;
  28. LONGLONG lnOldTime100Ns ;
  29. LONGLONG lnNewTime100Ns ;
  30. LONGLONG lnaCounterValue[2];
  31. LONGLONG lnaOldCounterValue[2];
  32. DWORD lnCounterType;
  33. LONGLONG lnPerfFreq ;
  34. LONGLONG ObjPerfFreq ;
  35. LONGLONG ObjCounterTimeNew;
  36. LONGLONG ObjCounterTimeOld;
  37. }LINESTRUCT ;
  38. typedef LINESTRUCT *PLINESTRUCT ;
  39. FLOAT CounterEntry (PLINESTRUCT pLine);
  40. class Entry : public CObject {
  41. public:
  42. int iObject;
  43. DWORD dwLastUsed;
  44. };
  45. //***************************************************************************
  46. //
  47. // CLASS NAME:
  48. //
  49. // CIndicyList
  50. //
  51. // DESCRIPTION:
  52. //
  53. // Implementation of the CIndicyList class. This class keeps a list of the
  54. // object types that are to be retrieved. Each object type also has a time
  55. // of last use so that object types that are no longer used will not be
  56. // retrieved forever. Some entries are part of the standard globals and
  57. // are marked as permanent so that they will always be read.
  58. //
  59. //***************************************************************************
  60. class CIndicyList : public CObject {
  61. public:
  62. BOOL SetUse(int iObj);
  63. BOOL bItemInList(int iObj);
  64. BOOL bAdd(int iObj, DWORD dwTime);
  65. void PruneOld(void);
  66. LPCTSTR pGetAll(void);
  67. // BOOL bItemInList(int iObj);
  68. ~CIndicyList(){FreeAll();};
  69. CIndicyList & operator = ( CIndicyList & from);
  70. void FreeAll(void);
  71. private:
  72. TString sAll;
  73. CFlexArray Entries;
  74. };
  75. //***************************************************************************
  76. //
  77. // CLASS NAME:
  78. //
  79. // PerfBuff
  80. //
  81. // DESCRIPTION:
  82. //
  83. // Holds a chunk of data read from the registry's perf monitor data.
  84. //
  85. //***************************************************************************
  86. class PerfBuff : public CObject {
  87. public:
  88. friend class PerfCache;
  89. DWORD Read(HKEY hKey, int iObj, BOOL bInitial);
  90. LPSTR Get(int iObj);
  91. void Free();
  92. ~PerfBuff(){Free();};
  93. PerfBuff();
  94. BOOL bOK(HKEY hKey, DWORD dwMaxAge, int iObj);
  95. PerfBuff & operator = ( PerfBuff & from);
  96. BOOL bEmpty(void){return !dwSize;};
  97. // __int64 Time(void){return dwBuffLastRead;};
  98. // __int64 Time2(void){return PerfTime;};
  99. private:
  100. DWORD dwSize;
  101. LPSTR pData;
  102. CIndicyList List;
  103. HKEY hKeyLastRead;
  104. DWORD dwBuffLastRead; // GetCurrentTime of last read
  105. LONGLONG PerfTime; // Time in last block
  106. LONGLONG PerfTime100nSec; // Time in last block
  107. LONGLONG PerfFreq;
  108. };
  109. //***************************************************************************
  110. //
  111. // CLASS NAME:
  112. //
  113. // PerfCache
  114. //
  115. // DESCRIPTION:
  116. //
  117. // Implementation of the PerfCache class. This is the object which is
  118. // directly used by the perf provider class. Each object keeps track of
  119. // several PerfBuff object. There is a newest which is what was just read,
  120. // an oldest which has previously read data and an intermediate buffer which
  121. // has data that isnt quite old enough to be moved into the old buffer. Note
  122. // that time average data requires having two samples which are separated by
  123. // a MIN_TIME_DIFF time difference.
  124. //
  125. //***************************************************************************
  126. class PerfCache : public CObject {
  127. public:
  128. void FreeOldBuffers(void);
  129. DWORD dwGetNew(LPCTSTR pName, int iObj, LPSTR * pData,PLINESTRUCT pls);
  130. DWORD dwGetPair(LPCTSTR pName, int iObj, LPSTR * pOldData,
  131. LPSTR * pNewData,PLINESTRUCT pls);
  132. PerfCache();
  133. ~PerfCache();
  134. private:
  135. PerfBuff Old,New;
  136. HKEY hHandle;
  137. TString sMachine;
  138. DWORD dwGetHandle(LPCTSTR pName);
  139. };