jwawinperf.pas 38 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882
  1. {******************************************************************************}
  2. { }
  3. { Performance Monitoring API interface Unit for Object Pascal }
  4. { }
  5. { Portions created by Microsoft are Copyright (C) 1995-2001 Microsoft }
  6. { Corporation. All Rights Reserved. }
  7. { }
  8. { The original file is: winperf.h, released June 2000. The original Pascal }
  9. { code is: WinPerf.pas, released December 2000. The initial developer of the }
  10. { Pascal code is Marcel van Brakel (brakelm att chello dott nl). }
  11. { }
  12. { Portions created by Marcel van Brakel are Copyright (C) 1999-2001 }
  13. { Marcel van Brakel. All Rights Reserved. }
  14. { }
  15. { Obtained through: Joint Endeavour of Delphi Innovators (Project JEDI) }
  16. { }
  17. { You may retrieve the latest version of this file at the Project JEDI }
  18. { APILIB home page, located at http://jedi-apilib.sourceforge.net }
  19. { }
  20. { The contents of this file are used with permission, subject to the Mozilla }
  21. { Public License Version 1.1 (the "License"); you may not use this file except }
  22. { in compliance with the License. You may obtain a copy of the License at }
  23. { http://www.mozilla.org/MPL/MPL-1.1.html }
  24. { }
  25. { Software distributed under the License is distributed on an "AS IS" basis, }
  26. { WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for }
  27. { the specific language governing rights and limitations under the License. }
  28. { }
  29. { Alternatively, the contents of this file may be used under the terms of the }
  30. { GNU Lesser General Public License (the "LGPL License"), in which case the }
  31. { provisions of the LGPL License are applicable instead of those above. }
  32. { If you wish to allow use of your version of this file only under the terms }
  33. { of the LGPL License and not to allow others to use your version of this file }
  34. { under the MPL, indicate your decision by deleting the provisions above and }
  35. { replace them with the notice and other provisions required by the LGPL }
  36. { License. If you do not delete the provisions above, a recipient may use }
  37. { your version of this file under either the MPL or the LGPL License. }
  38. { }
  39. { For more information about the LGPL: http://www.gnu.org/copyleft/lesser.html }
  40. { }
  41. {******************************************************************************}
  42. unit JwaWinPerf;
  43. {$WEAKPACKAGEUNIT}
  44. {$HPPEMIT ''}
  45. {$HPPEMIT '#include "WinPerf.h"'}
  46. {$HPPEMIT ''}
  47. {$I jediapilib.inc}
  48. interface
  49. uses
  50. JwaWinBase, JwaWinType;
  51. // Header file for the Performance Monitor data.
  52. //
  53. // This file contains the definitions of the data structures returned
  54. // by the Configuration Registry in response to a request for
  55. // performance data. This file is used by both the Configuration
  56. // Registry and the Performance Monitor to define their interface.
  57. // The complete interface is described here, except for the name
  58. // of the node to query in the registry. It is
  59. //
  60. // HKEY_PERFORMANCE_DATA.
  61. //
  62. // By querying that node with a subkey of "Global" the caller will
  63. // retrieve the structures described here.
  64. //
  65. // There is no need to RegOpenKey() the reserved handle HKEY_PERFORMANCE_DATA,
  66. // but the caller should RegCloseKey() the handle so that network transports
  67. // and drivers can be removed or installed (which cannot happen while
  68. // they are open for monitoring.) Remote requests must first
  69. // RegConnectRegistry().
  70. // Data structure definitions.
  71. // In order for data to be returned through the Configuration Registry
  72. // in a system-independent fashion, it must be self-describing.
  73. // In the following, all offsets are in bytes.
  74. //
  75. // Data is returned through the Configuration Registry in a
  76. // a data block which begins with a _PERF_DATA_BLOCK structure.
  77. //
  78. const
  79. PERF_DATA_VERSION = 1;
  80. {$EXTERNALSYM PERF_DATA_VERSION}
  81. PERF_DATA_REVISION = 1;
  82. {$EXTERNALSYM PERF_DATA_REVISION}
  83. type
  84. PPERF_DATA_BLOCK = ^PERF_DATA_BLOCK;
  85. {$EXTERNALSYM PPERF_DATA_BLOCK}
  86. _PERF_DATA_BLOCK = record
  87. Signature: array [0..3] of WCHAR; // Signature: Unicode "PERF"
  88. LittleEndian: DWORD; // 0 = Big Endian, 1 = Little Endian
  89. Version: DWORD; // Version of these data structures
  90. // starting at 1
  91. Revision: DWORD; // Revision of these data structures
  92. // starting at 0 for each Version
  93. TotalByteLength: DWORD; // Total length of data block
  94. HeaderLength: DWORD; // Length of this structure
  95. NumObjectTypes: DWORD; // Number of types of objects
  96. // being reported
  97. DefaultObject: LONG; // Object Title Index of default
  98. // object to display when data from
  99. // this system is retrieved (-1 =
  100. // none, but this is not expected to
  101. // be used)
  102. SystemTime: SYSTEMTIME; // Time at the system under
  103. // measurement
  104. PerfTime: LARGE_INTEGER; // Performance counter value
  105. // at the system under measurement
  106. PerfFreq: LARGE_INTEGER; // Performance counter frequency
  107. // at the system under measurement
  108. PerfTime100nSec: LARGE_INTEGER; // Performance counter time in 100 nsec
  109. // units at the system under measurement
  110. SystemNameLength: DWORD; // Length of the system name
  111. SystemNameOffset: DWORD; // Offset, from beginning of this
  112. // structure, to name of system
  113. // being measured
  114. end;
  115. {$EXTERNALSYM _PERF_DATA_BLOCK}
  116. PERF_DATA_BLOCK = _PERF_DATA_BLOCK;
  117. {$EXTERNALSYM PERF_DATA_BLOCK}
  118. TPerfDataBlock = PERF_DATA_BLOCK;
  119. PPerfDataBlock = PPERF_DATA_BLOCK;
  120. //
  121. // The _PERF_DATA_BLOCK structure is followed by NumObjectTypes of
  122. // data sections, one for each type of object measured. Each object
  123. // type section begins with a _PERF_OBJECT_TYPE structure.
  124. //
  125. PPERF_OBJECT_TYPE = ^PERF_OBJECT_TYPE;
  126. {$EXTERNALSYM PPERF_OBJECT_TYPE}
  127. _PERF_OBJECT_TYPE = record
  128. TotalByteLength: DWORD; // Length of this object definition
  129. // including this structure, the
  130. // counter definitions, and the
  131. // instance definitions and the
  132. // counter blocks for each instance:
  133. // This is the offset from this
  134. // structure to the next object, if
  135. // any
  136. DefinitionLength: DWORD; // Length of object definition,
  137. // which includes this structure
  138. // and the counter definition
  139. // structures for this object: this
  140. // is the offset of the first
  141. // instance or of the counters
  142. // for this object if there is
  143. // no instance
  144. HeaderLength: DWORD; // Length of this structure: this
  145. // is the offset to the first
  146. // counter definition for this
  147. // object
  148. ObjectNameTitleIndex: DWORD; // Index to name in Title Database
  149. ObjectNameTitle: LPWSTR; // Initially NULL, for use by
  150. // analysis program to point to
  151. // retrieved title string
  152. ObjectHelpTitleIndex: DWORD; // Index to Help in Title Database
  153. ObjectHelpTitle: LPWSTR; // Initially NULL, for use by
  154. // analysis program to point to
  155. // retrieved title string
  156. DetailLevel: DWORD; // Object level of detail (for
  157. // controlling display complexity);
  158. // will be min of detail levels
  159. // for all this object's counters
  160. NumCounters: DWORD; // Number of counters in each
  161. // counter block (one counter
  162. // block per instance)
  163. DefaultCounter: LONG; // Default counter to display when
  164. // this object is selected, index
  165. // starting at 0 (-1 = none, but
  166. // this is not expected to be used)
  167. NumInstances: LONG; // Number of object instances
  168. // for which counters are being
  169. // returned from the system under
  170. // measurement. If the object defined
  171. // will never have any instance data
  172. // structures (PERF_INSTANCE_DEFINITION)
  173. // then this value should be -1, if the
  174. // object can have 0 or more instances,
  175. // but has none present, then this
  176. // should be 0, otherwise this field
  177. // contains the number of instances of
  178. // this counter.
  179. CodePage: DWORD; // 0 if instance strings are in
  180. // UNICODE, else the Code Page of
  181. // the instance names
  182. PerfTime: LARGE_INTEGER; // Sample Time in "Object" units
  183. PerfFreq: LARGE_INTEGER; // Frequency of "Object" units in
  184. // counts per second.
  185. end;
  186. {$EXTERNALSYM _PERF_OBJECT_TYPE}
  187. PERF_OBJECT_TYPE = _PERF_OBJECT_TYPE;
  188. {$EXTERNALSYM PERF_OBJECT_TYPE}
  189. TPerfObjectType = PERF_OBJECT_TYPE;
  190. PPerfObjectType = PPERF_OBJECT_TYPE;
  191. const
  192. PERF_NO_INSTANCES = -1; // no instances (see NumInstances above)
  193. {$EXTERNALSYM PERF_NO_INSTANCES}
  194. //
  195. // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  196. //
  197. // PERF_COUNTER_DEFINITION.CounterType field values
  198. //
  199. //
  200. // Counter ID Field Definition:
  201. //
  202. // 3 2 2 2 2 1 1 1
  203. // 1 8 4 2 0 6 2 0 8 0
  204. // +--------+--------+----+----+--------+--------+----+----+----------------+
  205. // |Display |Calculation |Time|Counter | |Ctr |Size| |
  206. // |Flags |Modifiers |Base|SubType |Reserved|Type|Fld | Reserved |
  207. // +--------+--------+----+----+--------+--------+----+----+----------------+
  208. //
  209. //
  210. // The counter type is the "or" of the following values as described below
  211. //
  212. // select one of the following to indicate the counter's data size
  213. //
  214. PERF_SIZE_DWORD = $00000000;
  215. {$EXTERNALSYM PERF_SIZE_DWORD}
  216. PERF_SIZE_LARGE = $00000100;
  217. {$EXTERNALSYM PERF_SIZE_LARGE}
  218. PERF_SIZE_ZERO = $00000200; // for Zero Length Fields
  219. {$EXTERNALSYM PERF_SIZE_ZERO}
  220. PERF_SIZE_VARIABLE_LEN = $00000300; // length is in CounterLength Fields
  221. // of Counter Definition struct
  222. {$EXTERNALSYM PERF_SIZE_VARIABLE_LEN}
  223. //
  224. // select one of the following values to indicate the counter field usage
  225. //
  226. PERF_TYPE_NUMBER = $00000000; // a number (not a counter)
  227. {$EXTERNALSYM PERF_TYPE_NUMBER}
  228. PERF_TYPE_COUNTER = $00000400; // an increasing numeric Value
  229. {$EXTERNALSYM PERF_TYPE_COUNTER}
  230. PERF_TYPE_TEXT = $00000800; // a text Fields
  231. {$EXTERNALSYM PERF_TYPE_TEXT}
  232. PERF_TYPE_ZERO = $00000C00; // displays a zero
  233. {$EXTERNALSYM PERF_TYPE_ZERO}
  234. //
  235. // If the PERF_TYPE_NUMBER field was selected, then select one of the
  236. // following to describe the Number
  237. //
  238. PERF_NUMBER_HEX = $00000000; // display as HEX Value
  239. {$EXTERNALSYM PERF_NUMBER_HEX}
  240. PERF_NUMBER_DECIMAL = $00010000; // display as a decimal integer
  241. {$EXTERNALSYM PERF_NUMBER_DECIMAL}
  242. PERF_NUMBER_DEC_1000 = $00020000; // display as a decimal/1000
  243. {$EXTERNALSYM PERF_NUMBER_DEC_1000}
  244. //
  245. // If the PERF_TYPE_COUNTER value was selected then select one of the
  246. // following to indicate the type of counter
  247. //
  248. PERF_COUNTER_VALUE = $00000000; // display counter Value
  249. {$EXTERNALSYM PERF_COUNTER_VALUE}
  250. PERF_COUNTER_RATE = $00010000; // divide ctr / delta time
  251. {$EXTERNALSYM PERF_COUNTER_RATE}
  252. PERF_COUNTER_FRACTION = $00020000; // divide ctr / base
  253. {$EXTERNALSYM PERF_COUNTER_FRACTION}
  254. PERF_COUNTER_BASE = $00030000; // base value used in fractions
  255. {$EXTERNALSYM PERF_COUNTER_BASE}
  256. PERF_COUNTER_ELAPSED = $00040000; // subtract counter from current time
  257. {$EXTERNALSYM PERF_COUNTER_ELAPSED}
  258. PERF_COUNTER_QUEUELEN = $00050000; // Use Queuelen processing func.
  259. {$EXTERNALSYM PERF_COUNTER_QUEUELEN}
  260. PERF_COUNTER_HISTOGRAM = $00060000; // Counter begins or ends a histogram
  261. {$EXTERNALSYM PERF_COUNTER_HISTOGRAM}
  262. PERF_COUNTER_PRECISION = $00070000; // divide ctr / private clock
  263. {$EXTERNALSYM PERF_COUNTER_PRECISION}
  264. //
  265. // If the PERF_TYPE_TEXT value was selected, then select one of the
  266. // following to indicate the type of TEXT data.
  267. //
  268. PERF_TEXT_UNICODE = $00000000; // type of text in text Fields
  269. {$EXTERNALSYM PERF_TEXT_UNICODE}
  270. PERF_TEXT_ASCII = $00010000; // ASCII using the CodePage Fields
  271. {$EXTERNALSYM PERF_TEXT_ASCII}
  272. //
  273. // Timer SubTypes
  274. //
  275. PERF_TIMER_TICK = $00000000; // use system perf. freq for base
  276. {$EXTERNALSYM PERF_TIMER_TICK}
  277. PERF_TIMER_100NS = $00100000; // use 100 NS timer time base units
  278. {$EXTERNALSYM PERF_TIMER_100NS}
  279. PERF_OBJECT_TIMER = $00200000; // use the object timer freq
  280. {$EXTERNALSYM PERF_OBJECT_TIMER}
  281. //
  282. // Any types that have calculations performed can use one or more of
  283. // the following calculation modification flags listed here
  284. //
  285. PERF_DELTA_COUNTER = $00400000; // compute difference First
  286. {$EXTERNALSYM PERF_DELTA_COUNTER}
  287. PERF_DELTA_BASE = $00800000; // compute base diff as well
  288. {$EXTERNALSYM PERF_DELTA_BASE}
  289. PERF_INVERSE_COUNTER = $01000000; // show as 1.00-value (assumes:
  290. {$EXTERNALSYM PERF_INVERSE_COUNTER}
  291. PERF_MULTI_COUNTER = $02000000; // sum of multiple instances
  292. {$EXTERNALSYM PERF_MULTI_COUNTER}
  293. //
  294. // Select one of the following values to indicate the display suffix (if any)
  295. //
  296. PERF_DISPLAY_NO_SUFFIX = $00000000; // no suffix
  297. {$EXTERNALSYM PERF_DISPLAY_NO_SUFFIX}
  298. PERF_DISPLAY_PER_SEC = $10000000; // "/sec"
  299. {$EXTERNALSYM PERF_DISPLAY_PER_SEC}
  300. PERF_DISPLAY_PERCENT = $20000000; // "%"
  301. {$EXTERNALSYM PERF_DISPLAY_PERCENT}
  302. PERF_DISPLAY_SECONDS = $30000000; // "secs"
  303. {$EXTERNALSYM PERF_DISPLAY_SECONDS}
  304. PERF_DISPLAY_NOSHOW = $40000000; // value is not displayed
  305. {$EXTERNALSYM PERF_DISPLAY_NOSHOW}
  306. //
  307. // Predefined counter types
  308. //
  309. // 32-bit Counter. Divide delta by delta time. Display suffix: "/sec"
  310. PERF_COUNTER_COUNTER =
  311. PERF_SIZE_DWORD or PERF_TYPE_COUNTER or PERF_COUNTER_RATE or
  312. PERF_TIMER_TICK or PERF_DELTA_COUNTER or PERF_DISPLAY_PER_SEC;
  313. {$EXTERNALSYM PERF_COUNTER_COUNTER}
  314. // 64-bit Timer. Divide delta by delta time. Display suffix: "%"
  315. PERF_COUNTER_TIMER =
  316. PERF_SIZE_LARGE or PERF_TYPE_COUNTER or PERF_COUNTER_RATE or
  317. PERF_TIMER_TICK or PERF_DELTA_COUNTER or PERF_DISPLAY_PERCENT;
  318. {$EXTERNALSYM PERF_COUNTER_TIMER}
  319. // Queue Length Space-Time Product. Divide delta by delta time. No Display Suffix.
  320. PERF_COUNTER_QUEUELEN_TYPE =
  321. PERF_SIZE_DWORD or PERF_TYPE_COUNTER or PERF_COUNTER_QUEUELEN or
  322. PERF_TIMER_TICK or PERF_DELTA_COUNTER or PERF_DISPLAY_NO_SUFFIX;
  323. {$EXTERNALSYM PERF_COUNTER_QUEUELEN_TYPE}
  324. // Queue Length Space-Time Product. Divide delta by delta time. No Display Suffix.
  325. PERF_COUNTER_LARGE_QUEUELEN_TYPE =
  326. PERF_SIZE_LARGE or PERF_TYPE_COUNTER or PERF_COUNTER_QUEUELEN or
  327. PERF_TIMER_TICK or PERF_DELTA_COUNTER or PERF_DISPLAY_NO_SUFFIX;
  328. {$EXTERNALSYM PERF_COUNTER_LARGE_QUEUELEN_TYPE}
  329. // Queue Length Space-Time Product using 100 Ns timebase.
  330. // Divide delta by delta time. No Display Suffix.
  331. PERF_COUNTER_100NS_QUEUELEN_TYPE =
  332. PERF_SIZE_LARGE or PERF_TYPE_COUNTER or PERF_COUNTER_QUEUELEN or
  333. PERF_TIMER_100NS or PERF_DELTA_COUNTER or PERF_DISPLAY_NO_SUFFIX;
  334. {$EXTERNALSYM PERF_COUNTER_100NS_QUEUELEN_TYPE}
  335. // Queue Length Space-Time Product using Object specific timebase.
  336. // Divide delta by delta time. No Display Suffix.
  337. PERF_COUNTER_OBJ_TIME_QUEUELEN_TYPE =
  338. PERF_SIZE_LARGE or PERF_TYPE_COUNTER or PERF_COUNTER_QUEUELEN or
  339. PERF_OBJECT_TIMER or PERF_DELTA_COUNTER or PERF_DISPLAY_NO_SUFFIX;
  340. {$EXTERNALSYM PERF_COUNTER_OBJ_TIME_QUEUELEN_TYPE}
  341. // 64-bit Counter. Divide delta by delta time. Display Suffix: "/sec"
  342. PERF_COUNTER_BULK_COUNT =
  343. PERF_SIZE_LARGE or PERF_TYPE_COUNTER or PERF_COUNTER_RATE or
  344. PERF_TIMER_TICK or PERF_DELTA_COUNTER or PERF_DISPLAY_PER_SEC;
  345. {$EXTERNALSYM PERF_COUNTER_BULK_COUNT}
  346. // Indicates the counter is not a counter but rather Unicode text Display as text.
  347. PERF_COUNTER_TEXT =
  348. PERF_SIZE_VARIABLE_LEN or PERF_TYPE_TEXT or PERF_TEXT_UNICODE or
  349. PERF_DISPLAY_NO_SUFFIX;
  350. {$EXTERNALSYM PERF_COUNTER_TEXT}
  351. // Indicates the data is a counter which should not be
  352. // time averaged on display (such as an error counter on a serial line)
  353. // Display as is. No Display Suffix.
  354. PERF_COUNTER_RAWCOUNT =
  355. PERF_SIZE_DWORD or PERF_TYPE_NUMBER or PERF_NUMBER_DECIMAL or
  356. PERF_DISPLAY_NO_SUFFIX;
  357. {$EXTERNALSYM PERF_COUNTER_RAWCOUNT}
  358. // Same as PERF_COUNTER_RAWCOUNT except its size is a large integer
  359. PERF_COUNTER_LARGE_RAWCOUNT =
  360. PERF_SIZE_LARGE or PERF_TYPE_NUMBER or PERF_NUMBER_DECIMAL or
  361. PERF_DISPLAY_NO_SUFFIX;
  362. {$EXTERNALSYM PERF_COUNTER_LARGE_RAWCOUNT}
  363. // Special case for RAWCOUNT that want to be displayed in hex
  364. // Indicates the data is a counter which should not be
  365. // time averaged on display (such as an error counter on a serial line)
  366. // Display as is. No Display Suffix.
  367. PERF_COUNTER_RAWCOUNT_HEX =
  368. PERF_SIZE_DWORD or PERF_TYPE_NUMBER or PERF_NUMBER_HEX or
  369. PERF_DISPLAY_NO_SUFFIX;
  370. {$EXTERNALSYM PERF_COUNTER_RAWCOUNT_HEX}
  371. // Same as PERF_COUNTER_RAWCOUNT_HEX except its size is a large integer
  372. PERF_COUNTER_LARGE_RAWCOUNT_HEX =
  373. PERF_SIZE_LARGE or PERF_TYPE_NUMBER or PERF_NUMBER_HEX or
  374. PERF_DISPLAY_NO_SUFFIX;
  375. {$EXTERNALSYM PERF_COUNTER_LARGE_RAWCOUNT_HEX}
  376. // A count which is either 1 or 0 on each sampling interrupt (% busy)
  377. // Divide delta by delta base. Display Suffix: "%"
  378. PERF_SAMPLE_FRACTION =
  379. PERF_SIZE_DWORD or PERF_TYPE_COUNTER or PERF_COUNTER_FRACTION or
  380. PERF_DELTA_COUNTER or PERF_DELTA_BASE or PERF_DISPLAY_PERCENT;
  381. {$EXTERNALSYM PERF_SAMPLE_FRACTION}
  382. // A count which is sampled on each sampling interrupt (queue length)
  383. // Divide delta by delta time. No Display Suffix.
  384. PERF_SAMPLE_COUNTER =
  385. PERF_SIZE_DWORD or PERF_TYPE_COUNTER or PERF_COUNTER_RATE or
  386. PERF_TIMER_TICK or PERF_DELTA_COUNTER or PERF_DISPLAY_NO_SUFFIX;
  387. {$EXTERNALSYM PERF_SAMPLE_COUNTER}
  388. // A label: no data is associated with this counter (it has 0 length)
  389. // Do not display.
  390. PERF_COUNTER_NODATA =
  391. PERF_SIZE_ZERO or PERF_DISPLAY_NOSHOW;
  392. {$EXTERNALSYM PERF_COUNTER_NODATA}
  393. // 64-bit Timer inverse (e.g., idle is measured, but display busy %)
  394. // Display 100 - delta divided by delta time. Display suffix: "%"
  395. PERF_COUNTER_TIMER_INV =
  396. PERF_SIZE_LARGE or PERF_TYPE_COUNTER or PERF_COUNTER_RATE or
  397. PERF_TIMER_TICK or PERF_DELTA_COUNTER or PERF_INVERSE_COUNTER or
  398. PERF_DISPLAY_PERCENT;
  399. {$EXTERNALSYM PERF_COUNTER_TIMER_INV}
  400. // The divisor for a sample, used with the previous counter to form a
  401. // sampled %. You must check for >0 before dividing by this! This
  402. // counter will directly follow the numerator counter. It should not
  403. // be displayed to the user.
  404. PERF_SAMPLE_BASE =
  405. PERF_SIZE_DWORD or PERF_TYPE_COUNTER or PERF_COUNTER_BASE or
  406. PERF_DISPLAY_NOSHOW or
  407. $00000001; // for compatibility with pre-beta versions
  408. {$EXTERNALSYM PERF_SAMPLE_BASE}
  409. // A timer which, when divided by an average base, produces a time
  410. // in seconds which is the average time of some operation. This
  411. // timer times total operations, and the base is the number of opera-
  412. // tions. Display Suffix: "sec"
  413. PERF_AVERAGE_TIMER =
  414. PERF_SIZE_DWORD or PERF_TYPE_COUNTER or PERF_COUNTER_FRACTION or
  415. PERF_DISPLAY_SECONDS;
  416. {$EXTERNALSYM PERF_AVERAGE_TIMER}
  417. // Used as the denominator in the computation of time or count
  418. // averages. Must directly follow the numerator counter. Not dis-
  419. // played to the user.
  420. PERF_AVERAGE_BASE =
  421. PERF_SIZE_DWORD or PERF_TYPE_COUNTER or PERF_COUNTER_BASE or
  422. PERF_DISPLAY_NOSHOW or
  423. $00000002; // for compatibility with pre-beta versions
  424. {$EXTERNALSYM PERF_AVERAGE_BASE}
  425. // A bulk count which, when divided (typically) by the number of
  426. // operations, gives (typically) the number of bytes per operation.
  427. // No Display Suffix.
  428. PERF_AVERAGE_BULK =
  429. PERF_SIZE_LARGE or PERF_TYPE_COUNTER or PERF_COUNTER_FRACTION or
  430. PERF_DISPLAY_NOSHOW;
  431. {$EXTERNALSYM PERF_AVERAGE_BULK}
  432. // 64-bit Timer in object specific units. Display delta divided by
  433. // delta time as returned in the object type header structure. Display suffix: "%"
  434. PERF_OBJ_TIME_TIMER =
  435. PERF_SIZE_LARGE or PERF_TYPE_COUNTER or PERF_COUNTER_RATE or
  436. PERF_OBJECT_TIMER or PERF_DELTA_COUNTER or PERF_DISPLAY_PERCENT;
  437. {$EXTERNALSYM PERF_OBJ_TIME_TIMER}
  438. // 64-bit Timer in 100 nsec units. Display delta divided by
  439. // delta time. Display suffix: "%"
  440. PERF_100NSEC_TIMER =
  441. PERF_SIZE_LARGE or PERF_TYPE_COUNTER or PERF_COUNTER_RATE or
  442. PERF_TIMER_100NS or PERF_DELTA_COUNTER or PERF_DISPLAY_PERCENT;
  443. {$EXTERNALSYM PERF_100NSEC_TIMER}
  444. // 64-bit Timer inverse (e.g., idle is measured, but display busy %)
  445. // Display 100 - delta divided by delta time. Display suffix: "%"
  446. PERF_100NSEC_TIMER_INV =
  447. PERF_SIZE_LARGE or PERF_TYPE_COUNTER or PERF_COUNTER_RATE or
  448. PERF_TIMER_100NS or PERF_DELTA_COUNTER or PERF_INVERSE_COUNTER or
  449. PERF_DISPLAY_PERCENT;
  450. {$EXTERNALSYM PERF_100NSEC_TIMER_INV}
  451. // 64-bit Timer. Divide delta by delta time. Display suffix: "%"
  452. // Timer for multiple instances, so result can exceed 100%.
  453. PERF_COUNTER_MULTI_TIMER =
  454. PERF_SIZE_LARGE or PERF_TYPE_COUNTER or PERF_COUNTER_RATE or
  455. PERF_DELTA_COUNTER or PERF_TIMER_TICK or PERF_MULTI_COUNTER or
  456. PERF_DISPLAY_PERCENT;
  457. {$EXTERNALSYM PERF_COUNTER_MULTI_TIMER}
  458. // 64-bit Timer inverse (e.g., idle is measured, but display busy %)
  459. // Display 100 * _MULTI_BASE - delta divided by delta time.
  460. // Display suffix: "%" Timer for multiple instances, so result
  461. // can exceed 100%. Followed by a counter of type _MULTI_BASE.
  462. PERF_COUNTER_MULTI_TIMER_INV =
  463. PERF_SIZE_LARGE or PERF_TYPE_COUNTER or PERF_COUNTER_RATE or
  464. PERF_DELTA_COUNTER or PERF_MULTI_COUNTER or PERF_TIMER_TICK or
  465. PERF_INVERSE_COUNTER or PERF_DISPLAY_PERCENT;
  466. {$EXTERNALSYM PERF_COUNTER_MULTI_TIMER_INV}
  467. // Number of instances to which the preceding _MULTI_..._INV counter
  468. // applies. Used as a factor to get the percentage.
  469. PERF_COUNTER_MULTI_BASE =
  470. PERF_SIZE_LARGE or PERF_TYPE_COUNTER or PERF_COUNTER_BASE or
  471. PERF_MULTI_COUNTER or PERF_DISPLAY_NOSHOW;
  472. {$EXTERNALSYM PERF_COUNTER_MULTI_BASE}
  473. // 64-bit Timer in 100 nsec units. Display delta divided by delta time.
  474. // Display suffix: "%" Timer for multiple instances, so result can exceed 100%.
  475. PERF_100NSEC_MULTI_TIMER =
  476. PERF_SIZE_LARGE or PERF_TYPE_COUNTER or PERF_DELTA_COUNTER or
  477. PERF_COUNTER_RATE or PERF_TIMER_100NS or PERF_MULTI_COUNTER or
  478. PERF_DISPLAY_PERCENT;
  479. {$EXTERNALSYM PERF_100NSEC_MULTI_TIMER}
  480. // 64-bit Timer inverse (e.g., idle is measured, but display busy %)
  481. // Display 100 * _MULTI_BASE - delta divided by delta time.
  482. // Display suffix: "%" Timer for multiple instances, so result
  483. // can exceed 100%. Followed by a counter of type _MULTI_BASE.
  484. PERF_100NSEC_MULTI_TIMER_INV =
  485. PERF_SIZE_LARGE or PERF_TYPE_COUNTER or PERF_DELTA_COUNTER or
  486. PERF_COUNTER_RATE or PERF_TIMER_100NS or PERF_MULTI_COUNTER or
  487. PERF_INVERSE_COUNTER or PERF_DISPLAY_PERCENT;
  488. {$EXTERNALSYM PERF_100NSEC_MULTI_TIMER_INV}
  489. // Indicates the data is a fraction of the following counter which
  490. // should not be time averaged on display (such as free space over
  491. // total space.) Display as is. Display the quotient as "%".
  492. PERF_RAW_FRACTION =
  493. PERF_SIZE_DWORD or PERF_TYPE_COUNTER or PERF_COUNTER_FRACTION or
  494. PERF_DISPLAY_PERCENT;
  495. {$EXTERNALSYM PERF_RAW_FRACTION}
  496. PERF_LARGE_RAW_FRACTION =
  497. PERF_SIZE_LARGE or PERF_TYPE_COUNTER or PERF_COUNTER_FRACTION or
  498. PERF_DISPLAY_PERCENT;
  499. {$EXTERNALSYM PERF_LARGE_RAW_FRACTION}
  500. // Indicates the data is a base for the preceding counter which should
  501. // not be time averaged on display (such as free space over total space.)
  502. PERF_RAW_BASE =
  503. PERF_SIZE_DWORD or PERF_TYPE_COUNTER or PERF_COUNTER_BASE or
  504. PERF_DISPLAY_NOSHOW or
  505. $00000003; // for compatibility with pre-beta versions
  506. {$EXTERNALSYM PERF_RAW_BASE}
  507. PERF_LARGE_RAW_BASE =
  508. PERF_SIZE_LARGE or PERF_TYPE_COUNTER or PERF_COUNTER_BASE or
  509. PERF_DISPLAY_NOSHOW;
  510. {$EXTERNALSYM PERF_LARGE_RAW_BASE}
  511. // The data collected in this counter is actually the start time of the
  512. // item being measured. For display, this data is subtracted from the
  513. // sample time to yield the elapsed time as the difference between the two.
  514. // In the definition below, the PerfTime field of the Object contains
  515. // the sample time as indicated by the PERF_OBJECT_TIMER bit and the
  516. // difference is scaled by the PerfFreq of the Object to convert the time
  517. // units into seconds.
  518. PERF_ELAPSED_TIME =
  519. PERF_SIZE_LARGE or PERF_TYPE_COUNTER or PERF_COUNTER_ELAPSED or
  520. PERF_OBJECT_TIMER or PERF_DISPLAY_SECONDS;
  521. {$EXTERNALSYM PERF_ELAPSED_TIME}
  522. //
  523. // The following counter type can be used with the preceding types to
  524. // define a range of values to be displayed in a histogram.
  525. //
  526. PERF_COUNTER_HISTOGRAM_TYPE = $80000000; // Counter begins or ends a histogram
  527. {$EXTERNALSYM PERF_COUNTER_HISTOGRAM_TYPE}
  528. //
  529. // This counter is used to display the difference from one sample
  530. // to the next. The counter value is a constantly increasing number
  531. // and the value displayed is the difference between the current
  532. // value and the previous value. Negative numbers are not allowed
  533. // which shouldn't be a problem as long as the counter value is
  534. // increasing or unchanged.
  535. //
  536. PERF_COUNTER_DELTA =
  537. PERF_SIZE_DWORD or PERF_TYPE_COUNTER or PERF_COUNTER_VALUE or
  538. PERF_DELTA_COUNTER or PERF_DISPLAY_NO_SUFFIX;
  539. {$EXTERNALSYM PERF_COUNTER_DELTA}
  540. PERF_COUNTER_LARGE_DELTA =
  541. PERF_SIZE_LARGE or PERF_TYPE_COUNTER or PERF_COUNTER_VALUE or
  542. PERF_DELTA_COUNTER or PERF_DISPLAY_NO_SUFFIX;
  543. {$EXTERNALSYM PERF_COUNTER_LARGE_DELTA}
  544. //
  545. // The precision counters are timers that consist of two counter values:
  546. // 1) the count of elapsed time of the event being monitored
  547. // 2) the "clock" time in the same units
  548. //
  549. // the precition timers are used where the standard system timers are not
  550. // precise enough for accurate readings. It's assumed that the service
  551. // providing the data is also providing a timestamp at the same time which
  552. // will eliminate any error that may occur since some small and variable
  553. // time elapses between the time the system timestamp is captured and when
  554. // the data is collected from the performance DLL. Only in extreme cases
  555. // has this been observed to be problematic.
  556. //
  557. // when using this type of timer, the definition of the
  558. // PERF_PRECISION_TIMESTAMP counter must immediately follow the
  559. // definition of the PERF_PRECISION_*_TIMER in the Object header
  560. //
  561. // The timer used has the same frequency as the System Performance Timer
  562. PERF_PRECISION_SYSTEM_TIMER =
  563. PERF_SIZE_LARGE or PERF_TYPE_COUNTER or PERF_COUNTER_PRECISION or
  564. PERF_TIMER_TICK or PERF_DELTA_COUNTER or PERF_DISPLAY_PERCENT;
  565. {$EXTERNALSYM PERF_PRECISION_SYSTEM_TIMER}
  566. //
  567. // The timer used has the same frequency as the 100 NanoSecond Timer
  568. PERF_PRECISION_100NS_TIMER =
  569. PERF_SIZE_LARGE or PERF_TYPE_COUNTER or PERF_COUNTER_PRECISION or
  570. PERF_TIMER_100NS or PERF_DELTA_COUNTER or PERF_DISPLAY_PERCENT;
  571. {$EXTERNALSYM PERF_PRECISION_100NS_TIMER}
  572. //
  573. // The timer used is of the frequency specified in the Object header's
  574. // PerfFreq field (PerfTime is ignored)
  575. PERF_PRECISION_OBJECT_TIMER =
  576. PERF_SIZE_LARGE or PERF_TYPE_COUNTER or PERF_COUNTER_PRECISION or
  577. PERF_OBJECT_TIMER or PERF_DELTA_COUNTER or PERF_DISPLAY_PERCENT;
  578. {$EXTERNALSYM PERF_PRECISION_OBJECT_TIMER}
  579. //
  580. // This is the timestamp to use in the computation of the timer specified
  581. // in the previous description block
  582. PERF_PRECISION_TIMESTAMP = PERF_LARGE_RAW_BASE;
  583. {$EXTERNALSYM PERF_PRECISION_TIMESTAMP}
  584. //
  585. // The following are used to determine the level of detail associated
  586. // with the counter. The user will be setting the level of detail
  587. // that should be displayed at any given time.
  588. //
  589. //
  590. PERF_DETAIL_NOVICE = 100; // The uninformed can understand it
  591. {$EXTERNALSYM PERF_DETAIL_NOVICE}
  592. PERF_DETAIL_ADVANCED = 200; // For the advanced user
  593. {$EXTERNALSYM PERF_DETAIL_ADVANCED}
  594. PERF_DETAIL_EXPERT = 300; // For the expert user
  595. {$EXTERNALSYM PERF_DETAIL_EXPERT}
  596. PERF_DETAIL_WIZARD = 400; // For the system designer
  597. {$EXTERNALSYM PERF_DETAIL_WIZARD}
  598. //
  599. //
  600. // There is one of the following for each of the
  601. // PERF_OBJECT_TYPE.NumCounters. The Unicode names in this structure MUST
  602. // come from a message file.
  603. //
  604. //
  605. type
  606. PPERF_COUNTER_DEFINITION = ^PERF_COUNTER_DEFINITION;
  607. {$EXTERNALSYM PPERF_COUNTER_DEFINITION}
  608. _PERF_COUNTER_DEFINITION = record
  609. ByteLength: DWORD; // Length in bytes of this structure
  610. CounterNameTitleIndex: DWORD; // Index of Counter name into
  611. // Title Database
  612. CounterNameTitle: LPWSTR; // Initially NULL, for use by
  613. // analysis program to point to
  614. // retrieved title string
  615. CounterHelpTitleIndex: DWORD; // Index of Counter Help into
  616. // Title Database
  617. CounterHelpTitle: LPWSTR; // Initially NULL, for use by
  618. // analysis program to point to
  619. // retrieved title string
  620. DefaultScale: LONG; // Power of 10 by which to scale
  621. // chart line if vertical axis is 100
  622. // 0 ==> 1, 1 ==> 10, -1 ==>1/10, etc.
  623. DetailLevel: DWORD; // Counter level of detail (for
  624. // controlling display complexity)
  625. CounterType: DWORD; // Type of counter
  626. CounterSize: DWORD; // Size of counter in bytes
  627. CounterOffset: DWORD; // Offset from the start of the
  628. // PERF_COUNTER_BLOCK to the first
  629. // byte of this counter
  630. end;
  631. {$EXTERNALSYM _PERF_COUNTER_DEFINITION}
  632. PERF_COUNTER_DEFINITION = _PERF_COUNTER_DEFINITION;
  633. {$EXTERNALSYM PERF_COUNTER_DEFINITION}
  634. TPerfCounterDefinition = PERF_COUNTER_DEFINITION;
  635. PPerfCounterDefinition = PPERF_COUNTER_DEFINITION;
  636. //
  637. //
  638. // If (PERF_DATA_BLOCK.NumInstances >= 0) then there will be
  639. // PERF_DATA_BLOCK.NumInstances of a (PERF_INSTANCE_DEFINITION
  640. // followed by a PERF_COUNTER_BLOCK followed by the counter data fields)
  641. // for each instance.
  642. //
  643. // If (PERF_DATA_BLOCK.NumInstances < 0) then the counter definition
  644. // strucutre above will be followed by only a PERF_COUNTER_BLOCK and the
  645. // counter data for that COUNTER.
  646. //
  647. const
  648. PERF_NO_UNIQUE_ID = -1;
  649. {$EXTERNALSYM PERF_NO_UNIQUE_ID}
  650. type
  651. PPERF_INSTANCE_DEFINITION = ^PERF_INSTANCE_DEFINITION;
  652. {$EXTERNALSYM PPERF_INSTANCE_DEFINITION}
  653. _PERF_INSTANCE_DEFINITION = record
  654. ByteLength: DWORD; // Length in bytes of this structure,
  655. // including the subsequent name
  656. ParentObjectTitleIndex: DWORD; // Title Index to name of "parent"
  657. // object (e.g., if thread, then
  658. // process is parent object type);
  659. // if logical drive, the physical
  660. // drive is parent object type
  661. ParentObjectInstance: DWORD; // Index to instance of parent object
  662. // type which is the parent of this
  663. // instance.
  664. UniqueID: LONG; // A unique ID used instead of
  665. // matching the name to identify
  666. // this instance, -1 = none
  667. NameOffset: DWORD; // Offset from beginning of
  668. // this struct to the Unicode name
  669. // of this instance
  670. NameLength: DWORD; // Length in bytes of name; 0 = none
  671. // this length includes the characters
  672. // in the string plus the size of the
  673. // terminating NULL char. It does not
  674. // include any additional pad bytes to
  675. // correct structure alignment
  676. end;
  677. {$EXTERNALSYM _PERF_INSTANCE_DEFINITION}
  678. PERF_INSTANCE_DEFINITION = _PERF_INSTANCE_DEFINITION;
  679. {$EXTERNALSYM PERF_INSTANCE_DEFINITION}
  680. TPerfInstanceDefinition = PERF_INSTANCE_DEFINITION;
  681. PPerfInstanceDefinition = PPERF_INSTANCE_DEFINITION;
  682. //
  683. // If .ParentObjectName is 0, there
  684. // is no parent-child hierarchy for this object type. Otherwise,
  685. // the .ParentObjectInstance is an index, starting at 0, into the
  686. // instances reported for the parent object type. It is only
  687. // meaningful if .ParentObjectName is not 0. The purpose of all this
  688. // is to permit reporting/summation of object instances like threads
  689. // within processes, and logical drives within physical drives.
  690. //
  691. //
  692. // The PERF_INSTANCE_DEFINITION will be followed by a PERF_COUNTER_BLOCK.
  693. //
  694. PPERF_COUNTER_BLOCK = ^PERF_COUNTER_BLOCK;
  695. {$EXTERNALSYM PPERF_COUNTER_BLOCK}
  696. _PERF_COUNTER_BLOCK = record
  697. ByteLength: DWORD; // Length in bytes of this structure,
  698. // including the following counters
  699. end;
  700. {$EXTERNALSYM _PERF_COUNTER_BLOCK}
  701. PERF_COUNTER_BLOCK = _PERF_COUNTER_BLOCK;
  702. {$EXTERNALSYM PERF_COUNTER_BLOCK}
  703. TPerfCounterBlock = PERF_COUNTER_BLOCK;
  704. PPerfCounterBlock = PPERF_COUNTER_BLOCK;
  705. //
  706. // The PERF_COUNTER_BLOCK is followed by PERF_OBJECT_TYPE.NumCounters
  707. // number of counters.
  708. //
  709. //
  710. // Support for New Extensible API starting with NT 5.0
  711. //
  712. const
  713. PERF_QUERY_OBJECTS = DWORD($80000000);
  714. {$EXTERNALSYM PERF_QUERY_OBJECTS}
  715. PERF_QUERY_GLOBAL = DWORD($80000001);
  716. {$EXTERNALSYM PERF_QUERY_GLOBAL}
  717. PERF_QUERY_COSTLY = DWORD($80000002);
  718. {$EXTERNALSYM PERF_QUERY_COSTLY}
  719. //
  720. // function typedefs for extensible counter function prototypes
  721. //
  722. type
  723. PM_OPEN_PROC = function(Arg1: LPWSTR): DWORD; stdcall;
  724. {$EXTERNALSYM PM_OPEN_PROC}
  725. PM_COLLECT_PROC = function(Arg1: LPWSTR; Arg2: Pointer; Arg3, Arg4: LPDWORD): DWORD; stdcall;
  726. {$EXTERNALSYM PM_COLLECT_PROC}
  727. PM_CLOSE_PROC = function: DWORD; stdcall;
  728. {$EXTERNALSYM PM_CLOSE_PROC}
  729. PM_QUERY_PROC = function(Arg1: LPDWORD; Arg2: Pointer; Arg3, Arg4: LPDWORD): DWORD; stdcall;
  730. {$EXTERNALSYM PM_QUERY_PROC}
  731. const
  732. MAX_PERF_OBJECTS_IN_QUERY_FUNCTION = LONG(64);
  733. {$EXTERNALSYM MAX_PERF_OBJECTS_IN_QUERY_FUNCTION}
  734. //
  735. // The following are the possible values for
  736. // HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Perflib\EventLogLevel
  737. // The default is WINPERF_LOG_NONE if the registry value is not defined.
  738. // This should be adopted by all perfdlls to avoid flooding the application
  739. // event log.
  740. //
  741. const
  742. WINPERF_LOG_NONE = 0; // No event reported
  743. {$EXTERNALSYM WINPERF_LOG_NONE}
  744. WINPERF_LOG_USER = 1; // Report only errors
  745. {$EXTERNALSYM WINPERF_LOG_USER}
  746. WINPERF_LOG_DEBUG = 2; // Report debug errors as well
  747. {$EXTERNALSYM WINPERF_LOG_DEBUG}
  748. WINPERF_LOG_VERBOSE = 3; // Report everything
  749. {$EXTERNALSYM WINPERF_LOG_VERBOSE}
  750. implementation
  751. end.