jwawinperf.pas 39 KB

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