jwawinperf.pas 39 KB

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