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