Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

963 lines
26 KiB

  1. /*++ BUILD Version: 0001 // Increment this if a change has global effects
  2. Copyright (c) 1992-1993 Microsoft Corporation
  3. Module Name:
  4. counters.c
  5. Abstract:
  6. This module contains the routines to calculate "DataPoint" values from
  7. the registry data.
  8. The algoritms were lifted from RussBls's "Data.C" in winmeter.
  9. All the math is done in floating point to get the correct results, at
  10. the sacrifice of efficiency on a 386 with not 387. We can always
  11. revisit these routines later.
  12. Revision History:
  13. Bob Watson 11/04/92
  14. -- modified calculations to use more integer math and "early
  15. exits" to improve efficiency on slower & non-coprocessor
  16. machines
  17. --*/
  18. //==========================================================================//
  19. // Includes //
  20. //==========================================================================//
  21. #include "setedit.h" // perfmon include files
  22. #include "counters.h" // Exported declarations for this file
  23. //==========================================================================//
  24. // Constants //
  25. //==========================================================================//
  26. #define INVERT PERF_COUNTER_TIMER_INV
  27. #define NS100_INVERT PERF_100NSEC_TIMER_INV
  28. #define NS100 PERF_100NSEC_TIMER
  29. #define TIMER_MULTI PERF_COUNTER_MULTI_TIMER
  30. #define TIMER_MULTI_INVERT PERF_COUNTER_MULTI_TIMER_INV
  31. #define NS100_MULTI PERF_100NSEC_MULTI_TIMER
  32. #define NS100_MULTI_INVERT PERF_100NSEC_MULTI_TIMER_INV
  33. #define FRACTION 1
  34. #define BULK 1
  35. #define TOO_BIG (FLOAT)1500000000
  36. //==========================================================================//
  37. // Local Functions //
  38. //==========================================================================//
  39. #define LargeIntegerLessThanOrEqualZero(X) ((X).QuadPart <= 0)
  40. FLOAT
  41. eLIntToFloat(
  42. IN PLARGE_INTEGER pLargeInt
  43. )
  44. /*++
  45. Routine Description:
  46. Converts a large integer to a floating point number
  47. Arguments:
  48. IN pLargeInt Pointer to large integer to return as a floating point
  49. number.
  50. Return Value:
  51. Floating point representation of Large Integer passed in arg. list
  52. --*/
  53. {
  54. FLOAT eSum;
  55. if (pLargeInt->HighPart == 0) {
  56. return (FLOAT) pLargeInt->LowPart;
  57. } else {
  58. // Scale the high portion so it's value is in the upper 32 bit
  59. // range. Then add it to the low portion.
  60. eSum = (FLOAT) pLargeInt->HighPart * 4.294967296E9f ;
  61. eSum += (FLOAT) pLargeInt->LowPart ;
  62. return (eSum) ;
  63. }
  64. } //eLIntToFloat
  65. FLOAT
  66. eGetTimeInterval(
  67. IN PLARGE_INTEGER pliCurrentTime,
  68. IN PLARGE_INTEGER pliPreviousTime,
  69. IN PLARGE_INTEGER pliFreq
  70. )
  71. /*++
  72. Routine Description:
  73. Get the difference between the current and previous time counts,
  74. then divide by the frequency.
  75. Arguments:
  76. IN pCurrentTime
  77. IN pPreviousTime
  78. used to compute the duration of this sample (the time between
  79. samples
  80. IN pliFreq
  81. # of counts (clock ticks) per second
  82. Return Value:
  83. Floating point representation of Time Interval (seconds)
  84. --*/
  85. {
  86. FLOAT eTimeDifference;
  87. FLOAT eFreq;
  88. FLOAT eTimeInterval ;
  89. LARGE_INTEGER liDifference;
  90. // Get the number of counts that have occured since the last sample
  91. liDifference.QuadPart = pliCurrentTime->QuadPart -
  92. pliPreviousTime->QuadPart;
  93. if (LargeIntegerLessThanOrEqualZero(liDifference)) {
  94. return (FLOAT) 0.0f;
  95. } else {
  96. eTimeDifference = eLIntToFloat(&liDifference);
  97. // Get the counts per second
  98. eFreq = eLIntToFloat(pliFreq) ;
  99. if (eFreq <= 0.0f)
  100. return (FLOAT) 0.0f;
  101. // Get the time since the last sample.
  102. eTimeInterval = eTimeDifference / eFreq ;
  103. return (eTimeInterval) ;
  104. }
  105. } // eGetTimeInterval
  106. FLOAT
  107. Counter_Counter_Common(
  108. IN PLINESTRUCT pLineStruct,
  109. IN INT iType
  110. )
  111. /*++
  112. Routine Description:
  113. Take the difference between the current and previous counts
  114. then divide by the time interval
  115. Arguments:
  116. IN pLineStruct
  117. Line structure containing data to perform computations on
  118. IN iType
  119. Counter Type
  120. Return Value:
  121. Floating point representation of outcome
  122. --*/
  123. {
  124. FLOAT eTimeInterval;
  125. FLOAT eDifference;
  126. FLOAT eCount ;
  127. LARGE_INTEGER liDifference;
  128. if (iType != BULK) {
  129. liDifference.HighPart = 0;
  130. liDifference.LowPart = pLineStruct->lnaCounterValue[0].LowPart -
  131. pLineStruct->lnaOldCounterValue[0].LowPart;
  132. } else {
  133. liDifference.QuadPart = pLineStruct->lnaCounterValue[0].QuadPart -
  134. pLineStruct->lnaOldCounterValue[0].QuadPart;
  135. }
  136. if (LargeIntegerLessThanOrEqualZero(liDifference)) {
  137. return (FLOAT) 0.0f;
  138. } else {
  139. eTimeInterval = eGetTimeInterval(&pLineStruct->lnNewTime,
  140. &pLineStruct->lnOldTime,
  141. &pLineStruct->lnPerfFreq) ;
  142. if (eTimeInterval <= 0.0f) {
  143. return (FLOAT) 0.0f;
  144. } else {
  145. eDifference = eLIntToFloat (&liDifference);
  146. eCount = eDifference / eTimeInterval ;
  147. return(eCount) ;
  148. }
  149. }
  150. } // Counter_Counter_Common
  151. FLOAT
  152. Counter_Average_Timer(
  153. IN PLINESTRUCT pLineStruct
  154. )
  155. /*++
  156. Routine Description:
  157. Take the differences between the current and previous times and counts
  158. divide the time interval by the counts multiply by 10,000,000 (convert
  159. from 100 nsec to sec)
  160. Arguments:
  161. IN pLineStruct
  162. Line structure containing data to perform computations on
  163. Return Value:
  164. Floating point representation of outcome
  165. --*/
  166. {
  167. FLOAT eTimeInterval;
  168. FLOAT eCount;
  169. LARGE_INTEGER liDifference;
  170. // Get the current and previous counts.
  171. liDifference.HighPart = 0;
  172. liDifference.LowPart = pLineStruct->lnaCounterValue[1].LowPart -
  173. pLineStruct->lnaOldCounterValue[1].LowPart;
  174. if ( LargeIntegerLessThanOrEqualZero(liDifference)) {
  175. return (FLOAT) 0.0f;
  176. } else {
  177. // Get the amount of time that has passed since the last sample
  178. eTimeInterval = eGetTimeInterval(&pLineStruct->lnaCounterValue[0],
  179. &pLineStruct->lnaOldCounterValue[0],
  180. &pLineStruct->lnPerfFreq) ;
  181. if (eTimeInterval < 0.0f) { // return 0 if negative time has passed
  182. return (0.0f);
  183. } else {
  184. // Get the number of counts in this time interval.
  185. eCount = eTimeInterval / eLIntToFloat (&liDifference);
  186. return(eCount) ;
  187. }
  188. }
  189. } //Counter_Average_Timer
  190. FLOAT
  191. Counter_Average_Bulk(
  192. IN PLINESTRUCT pLineStruct
  193. )
  194. /*++
  195. Routine Description:
  196. Take the differences between the current and previous byte counts and
  197. operation counts divide the bulk count by the operation counts
  198. Arguments:
  199. IN pLineStruct
  200. Line structure containing data to perform computations on
  201. Return Value:
  202. Floating point representation of outcome
  203. --*/
  204. {
  205. FLOAT eBulkDelta;
  206. FLOAT eDifference;
  207. FLOAT eCount;
  208. LARGE_INTEGER liDifference;
  209. LARGE_INTEGER liBulkDelta;
  210. // Get the bulk count increment since the last sample
  211. liBulkDelta.QuadPart = pLineStruct->lnaCounterValue[0].QuadPart -
  212. pLineStruct->lnaOldCounterValue[0].QuadPart;
  213. if (LargeIntegerLessThanOrEqualZero(liBulkDelta)) {
  214. return (FLOAT) 0.0f;
  215. } else {
  216. // Get the current and previous counts.
  217. liDifference.HighPart = 0;
  218. liDifference.LowPart = pLineStruct->lnaCounterValue[1].LowPart -
  219. pLineStruct->lnaOldCounterValue[1].LowPart;
  220. // Get the number of counts in this time interval.
  221. if ( LargeIntegerLessThanOrEqualZero(liDifference)) {
  222. // Counter value invalid
  223. return (FLOAT) 0.0f;
  224. } else {
  225. eBulkDelta = eLIntToFloat (&liBulkDelta);
  226. eDifference = eLIntToFloat (&liDifference);
  227. eCount = eBulkDelta / eDifference ;
  228. // Scale the value to up to 1 second
  229. return(eCount) ;
  230. }
  231. }
  232. } // Counter_Average_Bulk
  233. FLOAT
  234. Counter_Timer_Common(
  235. IN PLINESTRUCT pLineStruct,
  236. IN INT iType
  237. )
  238. /*++
  239. Routine Description:
  240. Take the difference between the current and previous counts,
  241. Normalize the count (counts per interval)
  242. divide by the time interval (count = % of interval)
  243. if (invert)
  244. subtract from 1 (the normalized size of an interval)
  245. multiply by 100 (convert to a percentage)
  246. this value from 100.
  247. Arguments:
  248. IN pLineStruct
  249. Line structure containing data to perform computations on
  250. IN iType
  251. Counter Type
  252. Return Value:
  253. Floating point representation of outcome
  254. --*/
  255. {
  256. FLOAT eTimeInterval;
  257. FLOAT eDifference;
  258. FLOAT eFreq;
  259. FLOAT eFraction;
  260. FLOAT eMultiBase;
  261. FLOAT eCount ;
  262. LARGE_INTEGER liTimeInterval;
  263. LARGE_INTEGER liDifference;
  264. // Get the amount of time that has passed since the last sample
  265. if (iType == NS100 ||
  266. iType == NS100_INVERT ||
  267. iType == NS100_MULTI ||
  268. iType == NS100_MULTI_INVERT) {
  269. liTimeInterval.QuadPart = pLineStruct->lnNewTime100Ns.QuadPart -
  270. pLineStruct->lnOldTime100Ns.QuadPart;
  271. eTimeInterval = eLIntToFloat (&liTimeInterval);
  272. } else {
  273. eTimeInterval = eGetTimeInterval(&pLineStruct->lnNewTime,
  274. &pLineStruct->lnOldTime,
  275. &pLineStruct->lnPerfFreq) ;
  276. }
  277. if (eTimeInterval <= 0.0f)
  278. return (FLOAT) 0.0f;
  279. // Get the current and previous counts.
  280. liDifference.QuadPart = pLineStruct->lnaCounterValue[0].QuadPart -
  281. pLineStruct->lnaOldCounterValue[0].QuadPart;
  282. // Get the number of counts in this time interval.
  283. // (1, 2, 3 or any number of seconds could have gone by since
  284. // the last sample)
  285. eDifference = eLIntToFloat (&liDifference) ;
  286. if (iType == 0 || iType == INVERT)
  287. {
  288. // Get the counts per interval (second)
  289. eFreq = eLIntToFloat(&pLineStruct->lnPerfFreq) ;
  290. if (eFreq <= 0.0f)
  291. return (FLOAT) 0.0f;
  292. // Calculate the fraction of the counts that are used by whatever
  293. // we are measuring
  294. eFraction = eDifference / eFreq ;
  295. }
  296. else
  297. {
  298. eFraction = eDifference ;
  299. }
  300. // Calculate the fraction of time used by what were measuring.
  301. eCount = eFraction / eTimeInterval ;
  302. // If this is an inverted count take care of the inversion.
  303. if (iType == INVERT || iType == NS100_INVERT)
  304. eCount = (FLOAT) 1.0 - eCount ;
  305. // If this is an inverted multi count take care of the inversion.
  306. if (iType == TIMER_MULTI_INVERT || iType == NS100_MULTI_INVERT) {
  307. eMultiBase = (FLOAT)pLineStruct->lnaCounterValue[1].LowPart ;
  308. eCount = (FLOAT) eMultiBase - eCount ;
  309. }
  310. // Scale the value to up to 100.
  311. eCount *= 100.0f ;
  312. if (eCount < 0.0f) eCount = 0.0f ;
  313. if (eCount > 100.0f &&
  314. iType != NS100_MULTI &&
  315. iType != NS100_MULTI_INVERT &&
  316. iType != TIMER_MULTI &&
  317. iType != TIMER_MULTI_INVERT) {
  318. eCount = 100.0f;
  319. }
  320. return(eCount) ;
  321. } // Counter_Timer_Common
  322. FLOAT
  323. Counter_Raw_Fraction(
  324. IN PLINESTRUCT pLineStruct
  325. )
  326. /*++
  327. Routine Description:
  328. Evaluate a raw fraction (no time, just two values: Numerator and
  329. Denominator) and multiply by 100 (to make a percentage;
  330. Arguments:
  331. IN pLineStruct
  332. Line structure containing data to perform computations on
  333. Return Value:
  334. Floating point representation of outcome
  335. --*/
  336. {
  337. FLOAT eCount ;
  338. LARGE_INTEGER liNumerator;
  339. if ( pLineStruct->lnaCounterValue[0].LowPart == 0 ||
  340. pLineStruct->lnaCounterValue[1].LowPart == 0 ) {
  341. // invalid value
  342. return (0.0f);
  343. } else {
  344. liNumerator.QuadPart =
  345. pLineStruct->lnaCounterValue[0].LowPart * 100L;
  346. eCount = eLIntToFloat(&liNumerator) /
  347. (FLOAT) pLineStruct->lnaCounterValue[1].LowPart;
  348. return(eCount) ;
  349. }
  350. } // Counter_Raw_Fraction
  351. FLOAT
  352. eElapsedTime(
  353. PLINESTRUCT pLineStruct,
  354. INT iType
  355. )
  356. /*++
  357. Routine Description:
  358. Converts 100NS elapsed time to fractional seconds
  359. Arguments:
  360. IN pLineStruct
  361. Line structure containing data to perform computations on
  362. IN iType
  363. Unused.
  364. Return Value:
  365. Floating point representation of elapsed time in seconds
  366. --*/
  367. {
  368. FLOAT eSeconds ;
  369. LARGE_INTEGER liDifference;
  370. if (LargeIntegerLessThanOrEqualZero(pLineStruct->lnaCounterValue[0] )) {
  371. // no data [start time = 0] so return 0
  372. return (FLOAT) 0.0f;
  373. } else {
  374. // otherwise compute difference between current time and start time
  375. liDifference.QuadPart =
  376. pLineStruct->lnNewTime.QuadPart - // sample time in obj. units
  377. pLineStruct->lnaCounterValue[0].QuadPart; // start time in obj. units
  378. if (LargeIntegerLessThanOrEqualZero(liDifference) ||
  379. LargeIntegerLessThanOrEqualZero(pLineStruct->lnObject.PerfFreq)) {
  380. return (FLOAT) 0.0f;
  381. } else {
  382. // convert to fractional seconds using object counter
  383. eSeconds = eLIntToFloat (&liDifference) /
  384. eLIntToFloat (&pLineStruct->lnObject.PerfFreq);
  385. return (eSeconds);
  386. }
  387. }
  388. } // eElapsedTime
  389. FLOAT
  390. Sample_Common(
  391. PLINESTRUCT pLineStruct,
  392. INT iType
  393. )
  394. /*++
  395. Routine Description:
  396. Divites "Top" differenced by Base Difference
  397. Arguments:
  398. IN pLineStruct
  399. Line structure containing data to perform computations on
  400. IN iType
  401. Counter Type
  402. Return Value:
  403. Floating point representation of outcome
  404. --*/
  405. {
  406. FLOAT eCount ;
  407. LONG lDifference;
  408. LONG lBaseDifference;
  409. lDifference = pLineStruct->lnaCounterValue[0].LowPart -
  410. pLineStruct->lnaOldCounterValue[0].LowPart ;
  411. if (lDifference <= 0) {
  412. return (FLOAT) 0.0f;
  413. } else {
  414. lBaseDifference = pLineStruct->lnaCounterValue[1].LowPart -
  415. pLineStruct->lnaOldCounterValue[1].LowPart ;
  416. if ( lBaseDifference <= 0 ) {
  417. // invalid value
  418. return (0.0f);
  419. } else {
  420. eCount = (FLOAT)lDifference / (FLOAT)lBaseDifference ;
  421. if (iType == FRACTION) {
  422. eCount *= (FLOAT) 100.0f ;
  423. }
  424. return(eCount) ;
  425. }
  426. }
  427. } // Sample_Common
  428. //==========================================================================//
  429. // Exported Functions //
  430. //==========================================================================//
  431. /*****************************************************************************
  432. * Counter_Counter - Take the difference between the current and previous
  433. * counts then divide by the time interval
  434. ****************************************************************************/
  435. #define Counter_Counter(pLineStruct) \
  436. Counter_Counter_Common(pLineStruct, 0)
  437. #if 0
  438. FLOAT Counter_Counter(PLINESTRUCT pLineStruct)
  439. {
  440. return Counter_Counter_Common(pLineStruct, 0) ;
  441. }
  442. #endif
  443. /*****************************************************************************
  444. * Counter_Bulk - Take the difference between the current and previous
  445. * counts then divide by the time interval
  446. * Same as a Counter_counter except it uses large_ints
  447. ****************************************************************************/
  448. #define Counter_Bulk(pLineStruct) \
  449. Counter_Counter_Common(pLineStruct, BULK)
  450. #if 0
  451. FLOAT Counter_Bulk(PLINESTRUCT pLineStruct)
  452. {
  453. return Counter_Counter_Common(pLineStruct, BULK) ;
  454. }
  455. #endif
  456. /*****************************************************************************
  457. * Counter_Timer100Ns -
  458. *
  459. * Need to review with RussBl exactly what he is doing here.
  460. ****************************************************************************/
  461. #define Counter_Timer100Ns(pLineStruct) \
  462. Counter_Timer_Common(pLineStruct, NS100)
  463. #if 0
  464. FLOAT Counter_Timer100Ns(PLINESTRUCT pLineStruct)
  465. {
  466. return Counter_Timer_Common(pLineStruct, NS100) ;
  467. }
  468. #endif
  469. /*****************************************************************************
  470. * Counter_Timer100Ns_Inv -
  471. *
  472. * Need to review with RussBl exactly what he is doing here.
  473. ****************************************************************************/
  474. #define Counter_Timer100Ns_Inv(pLineStruct) \
  475. Counter_Timer_Common(pLineStruct, NS100_INVERT)
  476. #if 0
  477. FLOAT Counter_Timer100Ns_Inv(PLINESTRUCT pLineStruct)
  478. {
  479. return Counter_Timer_Common(pLineStruct, NS100_INVERT) ;
  480. }
  481. #endif
  482. /*****************************************************************************
  483. * Counter_Timer_Multi -
  484. *
  485. * Need to review with RussBl exactly what he is doing here.
  486. ****************************************************************************/
  487. #define Counter_Timer_Multi(pLineStruct) \
  488. Counter_Timer_Common(pLineStruct, TIMER_MULTI)
  489. #if 0
  490. FLOAT Counter_Timer_Multi(PLINESTRUCT pLineStruct)
  491. {
  492. return Counter_Timer_Common(pLineStruct, TIMER_MULTI) ;
  493. }
  494. #endif
  495. /*****************************************************************************
  496. * Counter_Timer_Multi_Inv -
  497. *
  498. * Need to review with RussBl exactly what he is doing here.
  499. ****************************************************************************/
  500. #define Counter_Timer_Multi_Inv(pLineStruct) \
  501. Counter_Timer_Common(pLineStruct, TIMER_MULTI_INVERT)
  502. #if 0
  503. FLOAT Counter_Timer_Multi_Inv(PLINESTRUCT pLineStruct)
  504. {
  505. return Counter_Timer_Common(pLineStruct, TIMER_MULTI_INVERT) ;
  506. }
  507. #endif
  508. /*****************************************************************************
  509. * Counter_Timer100Ns_Multi -
  510. *
  511. * Need to review with RussBl exactly what he is doing here.
  512. ****************************************************************************/
  513. #define Counter_Timer100Ns_Multi(pLineStruct) \
  514. Counter_Timer_Common(pLineStruct, NS100_MULTI)
  515. #if 0
  516. FLOAT Counter_Timer100Ns_Multi(PLINESTRUCT pLineStruct)
  517. {
  518. return Counter_Timer_Common(pLineStruct, NS100_MULTI) ;
  519. }
  520. #endif
  521. /*****************************************************************************
  522. * Counter_Timer100Ns_Multi_Inv -
  523. *
  524. * Need to review with RussBl exactly what he is doing here.
  525. ****************************************************************************/
  526. #define Counter_Timer100Ns_Multi_Inv(pLineStruct) \
  527. Counter_Timer_Common(pLineStruct, NS100_MULTI_INVERT)
  528. #if 0
  529. FLOAT Counter_Timer100Ns_Multi_Inv(PLINESTRUCT pLineStruct)
  530. {
  531. return Counter_Timer_Common(pLineStruct, NS100_MULTI_INVERT) ;
  532. }
  533. #endif
  534. /*****************************************************************************
  535. * Counter_Timer - Take the difference between the current and previous
  536. * counts,
  537. * Normalize the count (counts per interval)
  538. * divide by the time interval (count = % of interval)
  539. * multiply by 100 (convert to a percentage)
  540. * this value from 100.
  541. ****************************************************************************/
  542. #define Counter_Timer(pLineStruct) \
  543. Counter_Timer_Common(pLineStruct, 0)
  544. #if 0
  545. FLOAT Counter_Timer(PLINESTRUCT pLineStruct)
  546. {
  547. return Counter_Timer_Common(pLineStruct, 0) ;
  548. }
  549. #endif
  550. /*****************************************************************************
  551. * Counter_Timer_Inv - Take the difference between the current and previous
  552. * counts,
  553. * Normalize the count (counts per interval)
  554. * divide by the time interval (count = % of interval)
  555. * subtract from 1 (the normalized size of an interval)
  556. * multiply by 100 (convert to a percentage)
  557. * this value from 100.
  558. ****************************************************************************/
  559. #define Counter_Timer_Inv(pLineStruct) \
  560. Counter_Timer_Common(pLineStruct, INVERT)
  561. #if 0
  562. FLOAT Counter_Timer_Inv(PLINESTRUCT pLineStruct)
  563. {
  564. return Counter_Timer_Common(pLineStruct, INVERT) ;
  565. }
  566. #endif
  567. /*****************************************************************************
  568. * Sample_Counter -
  569. ****************************************************************************/
  570. #define Sample_Counter(pLineStruct) \
  571. Sample_Common(pLineStruct, 0)
  572. #if 0
  573. FLOAT Sample_Counter(PLINESTRUCT pLineStruct)
  574. {
  575. return Sample_Common(pLineStruct, 0) ;
  576. }
  577. #endif
  578. /*****************************************************************************
  579. * Sample_Fraction -
  580. ****************************************************************************/
  581. #define Sample_Fraction(pLineStruct) \
  582. Sample_Common(pLineStruct, FRACTION)
  583. #if 0
  584. FLOAT Sample_Fraction(PLINESTRUCT pLineStruct)
  585. {
  586. return Sample_Common(pLineStruct, FRACTION) ;
  587. }
  588. #endif
  589. /*****************************************************************************
  590. * Counter_Rawcount - This is just a raw count.
  591. ****************************************************************************/
  592. #define Counter_Rawcount(pLineStruct) \
  593. ((FLOAT) (pLineStruct->lnaCounterValue[0].LowPart))
  594. #if 0
  595. FLOAT Counter_Rawcount(PLINESTRUCT pLineStruct)
  596. {
  597. return((FLOAT) (pLineStruct->lnaCounterValue[0].LowPart)) ;
  598. }
  599. #endif
  600. /*****************************************************************************
  601. * Counter_Large_Rawcount - This is just a raw count.
  602. ****************************************************************************/
  603. #define Counter_Large_Rawcount(pLineStruct) \
  604. ((FLOAT) eLIntToFloat(&(pLineStruct->lnaCounterValue[0])))
  605. /*****************************************************************************
  606. * Counter_Elapsed_Time -
  607. ****************************************************************************/
  608. #define Counter_Elapsed_Time(pLineStruct) \
  609. eElapsedTime (pLineStruct, 0)
  610. #if 0
  611. FLOAT Counter_Elapsed_Time (PLINESTRUCT pLineStruct)
  612. {
  613. return eElapsedTime (pLineStruct, 0);
  614. }
  615. #endif
  616. /*****************************************************************************
  617. * Counter_Null - The counters that return nothing go here.
  618. ****************************************************************************/
  619. #define Counter_Null(pline) \
  620. ((FLOAT) 0.0)
  621. #if 0
  622. FLOAT Counter_Null(PLINESTRUCT pline)
  623. {
  624. return((FLOAT) 0.0);
  625. pline;
  626. }
  627. #endif
  628. FLOAT
  629. CounterEntry (
  630. PLINESTRUCT pLine
  631. )
  632. {
  633. switch (pLine->lnCounterType) {
  634. case PERF_COUNTER_COUNTER:
  635. return Counter_Counter (pLine);
  636. case PERF_COUNTER_TIMER:
  637. return Counter_Timer (pLine);
  638. case PERF_COUNTER_QUEUELEN_TYPE:
  639. return Counter_Queuelen(pLine);
  640. case PERF_COUNTER_BULK_COUNT:
  641. return Counter_Bulk (pLine);
  642. case PERF_COUNTER_TEXT:
  643. return Counter_Null (pLine);
  644. case PERF_COUNTER_RAWCOUNT:
  645. case PERF_COUNTER_RAWCOUNT_HEX:
  646. return Counter_Rawcount(pLine);
  647. case PERF_COUNTER_LARGE_RAWCOUNT:
  648. case PERF_COUNTER_LARGE_RAWCOUNT_HEX:
  649. return Counter_Large_Rawcount(pLine);
  650. case PERF_SAMPLE_FRACTION:
  651. return Sample_Fraction(pLine);
  652. case PERF_SAMPLE_COUNTER:
  653. return Sample_Counter (pLine);
  654. case PERF_COUNTER_NODATA:
  655. return Counter_Null (pLine);
  656. case PERF_COUNTER_TIMER_INV:
  657. return Counter_Timer_Inv (pLine);
  658. case PERF_RAW_BASE:
  659. // case PERF_SAMPLE_BASE:
  660. // case PERF_AVERAGE_BASE:
  661. return Counter_Null (pLine);
  662. case PERF_AVERAGE_TIMER:
  663. return Counter_Average_Timer (pLine);
  664. case PERF_AVERAGE_BULK:
  665. return Counter_Average_Bulk (pLine);
  666. case PERF_100NSEC_TIMER:
  667. return Counter_Timer100Ns (pLine);
  668. case PERF_100NSEC_TIMER_INV:
  669. return Counter_Timer100Ns_Inv (pLine);
  670. case PERF_COUNTER_MULTI_TIMER:
  671. return Counter_Timer_Multi (pLine);
  672. case PERF_COUNTER_MULTI_TIMER_INV:
  673. return Counter_Timer_Multi_Inv (pLine);
  674. case PERF_COUNTER_MULTI_BASE:
  675. return Counter_Null (pLine);
  676. case PERF_100NSEC_MULTI_TIMER:
  677. return Counter_Timer100Ns_Multi (pLine);
  678. case PERF_100NSEC_MULTI_TIMER_INV:
  679. return Counter_Timer100Ns_Multi_Inv (pLine);
  680. case PERF_RAW_FRACTION:
  681. return Counter_Raw_Fraction (pLine);
  682. case PERF_ELAPSED_TIME:
  683. return Counter_Elapsed_Time (pLine);
  684. default:
  685. return Counter_Null (pLine);
  686. }
  687. }
  688. BOOL
  689. IsCounterSupported (
  690. DWORD dwCounterType
  691. )
  692. {
  693. switch (dwCounterType) {
  694. // supported counters
  695. case PERF_COUNTER_COUNTER:
  696. case PERF_COUNTER_TIMER:
  697. case PERF_COUNTER_QUEUELEN_TYPE:
  698. case PERF_COUNTER_BULK_COUNT:
  699. case PERF_COUNTER_RAWCOUNT:
  700. case PERF_COUNTER_RAWCOUNT_HEX:
  701. case PERF_COUNTER_LARGE_RAWCOUNT:
  702. case PERF_COUNTER_LARGE_RAWCOUNT_HEX:
  703. case PERF_SAMPLE_FRACTION:
  704. case PERF_SAMPLE_COUNTER:
  705. case PERF_COUNTER_TIMER_INV:
  706. case PERF_AVERAGE_TIMER:
  707. case PERF_AVERAGE_BULK:
  708. case PERF_100NSEC_TIMER:
  709. case PERF_100NSEC_TIMER_INV:
  710. case PERF_COUNTER_MULTI_TIMER:
  711. case PERF_COUNTER_MULTI_TIMER_INV:
  712. case PERF_100NSEC_MULTI_TIMER:
  713. case PERF_100NSEC_MULTI_TIMER_INV:
  714. case PERF_RAW_FRACTION:
  715. case PERF_ELAPSED_TIME:
  716. return TRUE;
  717. // unsupported counters
  718. case PERF_COUNTER_TEXT:
  719. case PERF_COUNTER_NODATA:
  720. case PERF_RAW_BASE:
  721. // case PERF_SAMPLE_BASE:
  722. // case PERF_AVERAGE_BASE:
  723. case PERF_COUNTER_MULTI_BASE:
  724. default:
  725. return FALSE;
  726. }
  727. }
  728. 
  729.