VirtualBox

Changeset 30589 in vbox


Ignore:
Timestamp:
Jul 2, 2010 6:14:21 PM (15 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
63314
Message:

VBox/stam.h: Added some new macros for STAMPROFILEADV and optimized a couple of existing ones.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/VBox/stam.h

    r28800 r30589  
    634634 * @param   pProfile    Pointer to the STAMPROFILE structure to operate on.
    635635 * @param   Prefix      Identifier prefix used to internal variables.
     636 *
     637 * @remarks Declears a stack variable that will be used by related macros.
    636638 */
    637639#ifndef VBOX_WITHOUT_RELEASE_STATISTICS
     
    647649 * @param   pProfile    Pointer to the STAMPROFILE structure to operate on.
    648650 * @param   Prefix      Identifier prefix used to internal variables.
     651 *
     652 * @remarks Declears a stack variable that will be used by related macros.
    649653 */
    650654#ifdef VBOX_WITH_STATISTICS
     
    664668    do { \
    665669        uint64_t Prefix##_cTicks; \
    666         uint64_t Prefix##_tsStop; \
    667         STAM_GET_TS(Prefix##_tsStop); \
    668         Prefix##_cTicks = Prefix##_tsStop - Prefix##_tsStart; \
     670        STAM_GET_TS(Prefix##_cTicks); \
     671        Prefix##_cTicks -= Prefix##_tsStart; \
    669672        (pProfile)->cTicks += Prefix##_cTicks; \
    670673        (pProfile)->cPeriods++; \
     
    703706    do { \
    704707        uint64_t Prefix##_cTicks; \
    705         uint64_t Prefix##_tsStop; \
    706         STAM_GET_TS(Prefix##_tsStop); \
    707         Prefix##_cTicks = Prefix##_tsStop - Prefix##_tsStart; \
     708        STAM_GET_TS(Prefix##_cTicks); \
     709        Prefix##_cTicks -= Prefix##_tsStart; \
    708710        (pProfile)->cTicks += Prefix##_cTicks; \
    709711        (pProfile)->cPeriods++; \
     
    788790
    789791/** @def STAM_REL_PROFILE_ADV_STOP
    790  * Samples the stop time of a profiling period and updates the sample.
     792 * Samples the stop time of a profiling period (if running) and updates the
     793 * sample.
    791794 *
    792795 * @param   pProfileAdv Pointer to the STAMPROFILEADV structure to operate on.
     
    796799# define STAM_REL_PROFILE_ADV_STOP(pProfileAdv, Prefix) \
    797800    do { \
    798         uint64_t Prefix##_tsStop; \
    799         STAM_GET_TS(Prefix##_tsStop); \
    800801        if ((pProfileAdv)->tsStart) \
    801802        { \
    802             uint64_t Prefix##_cTicks = Prefix##_tsStop - (pProfileAdv)->tsStart; \
     803            uint64_t Prefix##_cTicks; \
     804            STAM_GET_TS(Prefix##_cTicks); \
     805            Prefix##_cTicks -= (pProfileAdv)->tsStart; \
    803806            (pProfileAdv)->tsStart = 0; \
    804807            (pProfileAdv)->Core.cTicks += Prefix##_cTicks; \
     
    814817#endif
    815818/** @def STAM_PROFILE_ADV_STOP
    816  * Samples the stop time of a profiling period and updates the sample.
     819 * Samples the stop time of a profiling period (if running) and updates the
     820 * sample.
    817821 *
    818822 * @param   pProfileAdv Pointer to the STAMPROFILEADV structure to operate on.
     
    823827#else
    824828# define STAM_PROFILE_ADV_STOP(pProfileAdv, Prefix) do { } while (0)
     829#endif
     830
     831
     832/** @def STAM_REL_PROFILE_ADV_STOP_START
     833 * Stops one profile counter (if running) and starts another one.
     834 *
     835 * @param   pProfileAdv1    Pointer to the STAMPROFILEADV structure to stop.
     836 * @param   pProfileAdv2    Pointer to the STAMPROFILEADV structure to start.
     837 * @param   Prefix          Identifier prefix used to internal variables.
     838 */
     839#ifndef VBOX_WITHOUT_RELEASE_STATISTICS
     840# define STAM_REL_PROFILE_ADV_STOP_START(pProfileAdv1, pProfileAdv2, Prefix) \
     841    do { \
     842        uint64_t Prefix##_cTicks; \
     843        STAM_GET_TS(Prefix##_cTicks); \
     844        (pProfileAdv2)->tsStart = Prefix##_cTicks; \
     845        if ((pProfileAdv1)->tsStart) \
     846        { \
     847            Prefix##_cTicks -= (pProfileAdv1)->tsStart; \
     848            (pProfileAdv1)->tsStart = 0; \
     849            (pProfileAdv1)->Core.cTicks += Prefix##_cTicks; \
     850            (pProfileAdv1)->Core.cPeriods++; \
     851            if ((pProfileAdv1)->Core.cTicksMax < Prefix##_cTicks) \
     852                (pProfileAdv1)->Core.cTicksMax = Prefix##_cTicks; \
     853            if ((pProfileAdv1)->Core.cTicksMin > Prefix##_cTicks) \
     854                (pProfileAdv1)->Core.cTicksMin = Prefix##_cTicks; \
     855        } \
     856    } while (0)
     857#else
     858# define STAM_REL_PROFILE_ADV_STOP_START(pProfileAdv1, pProfileAdv2, Prefix) \
     859    do { } while (0)
     860#endif
     861/** @def STAM_PROFILE_ADV_STOP_START
     862 * Samples the stop time of a profiling period (if running) and updates the
     863 * sample.
     864 *
     865 * @param   pProfileAdv Pointer to the STAMPROFILEADV structure to operate on.
     866 * @param   Prefix      Identifier prefix used to internal variables.
     867 */
     868#ifdef VBOX_WITH_STATISTICS
     869# define STAM_PROFILE_ADV_STOP_START(pProfileAdv1, pProfileAdv2, Prefix) \
     870    STAM_REL_PROFILE_ADV_STOP_START(pProfileAdv1, pProfileAdv2, Prefix)
     871#else
     872# define STAM_PROFILE_ADV_STOP_START(pProfileAdv1, pProfileAdv2, Prefix) \
     873    do { } while (0)
    825874#endif
    826875
     
    890939
    891940/** @def STAM_REL_PROFILE_ADV_STOP_EX
    892  * Samples the stop time of a profiling period and updates both the sample
    893  * and an attribution sample.
     941 * Samples the stop time of a profiling period (if running) and updates both
     942 * the sample and an attribution sample.
    894943 *
    895944 * @param   pProfileAdv Pointer to the STAMPROFILEADV structure to operate on.
     
    901950# define STAM_REL_PROFILE_ADV_STOP_EX(pProfileAdv, pProfile2, Prefix) \
    902951    do { \
    903         uint64_t Prefix##_tsStop; \
    904         STAM_GET_TS(Prefix##_tsStop); \
    905952        if ((pProfileAdv)->tsStart) \
    906953        { \
    907             uint64_t Prefix##_cTicks = Prefix##_tsStop - (pProfileAdv)->tsStart; \
     954            uint64_t Prefix##_cTicks; \
     955            STAM_GET_TS(Prefix##_cTicks); \
     956            Prefix##_cTicks -= (pProfileAdv)->tsStart; \
    908957            (pProfileAdv)->tsStart = 0; \
    909958            (pProfileAdv)->Core.cTicks += Prefix##_cTicks; \
     
    928977#endif
    929978/** @def STAM_PROFILE_ADV_STOP_EX
    930  * Samples the stop time of a profiling period and updates both the sample
    931  * and an attribution sample.
     979 * Samples the stop time of a profiling period (if running) and updates both
     980 * the sample and an attribution sample.
    932981 *
    933982 * @param   pProfileAdv Pointer to the STAMPROFILEADV structure to operate on.
     
    940989#else
    941990# define STAM_PROFILE_ADV_STOP_EX(pProfileAdv, pProfile2, Prefix) do { } while (0)
     991#endif
     992
     993/** @def STAM_REL_PROFILE_ADV_IS_RUNNING
     994 * Checks if it is running.
     995 *
     996 * @param   pProfileAdv Pointer to the STAMPROFILEADV structure to operate on.
     997 */
     998#ifndef VBOX_WITHOUT_RELEASE_STATISTICS
     999# define STAM_REL_PROFILE_ADV_IS_RUNNING(pProfileAdv)   (pProfileAdv)->tsStart
     1000#else
     1001# define STAM_REL_PROFILE_ADV_IS_RUNNING(pProfileAdv)   (false)
     1002#endif
     1003/** @def STAM_PROFILE_ADV_IS_RUNNING
     1004 * Checks if it is running.
     1005 *
     1006 * @param   pProfileAdv Pointer to the STAMPROFILEADV structure to operate on.
     1007 */
     1008#ifdef VBOX_WITH_STATISTICS
     1009# define STAM_PROFILE_ADV_IS_RUNNING(pProfileAdv) STAM_REL_PROFILE_ADV_IS_RUNNING(pProfileAdv)
     1010#else
     1011# define STAM_PROFILE_ADV_IS_RUNNING(pProfileAdv) (false)
     1012#endif
     1013
     1014/** @def STAM_REL_PROFILE_ADV_SET_STOPPED
     1015 * Marks the profile counter as stopped.
     1016 *
     1017 * This is for avoiding screwups in twisty code.
     1018 *
     1019 * @param   pProfileAdv Pointer to the STAMPROFILEADV structure to operate on.
     1020 */
     1021#ifndef VBOX_WITHOUT_RELEASE_STATISTICS
     1022# define STAM_REL_PROFILE_ADV_SET_STOPPED(pProfileAdv)   do { (pProfileAdv)->tsStart = 0; } while (0)
     1023#else
     1024# define STAM_REL_PROFILE_ADV_SET_STOPPED(pProfileAdv)   do { } while (0)
     1025#endif
     1026/** @def STAM_PROFILE_ADV_SET_STOPPED
     1027 * Marks the profile counter as stopped.
     1028 *
     1029 * This is for avoiding screwups in twisty code.
     1030 *
     1031 * @param   pProfileAdv Pointer to the STAMPROFILEADV structure to operate on.
     1032 */
     1033#ifdef VBOX_WITH_STATISTICS
     1034# define STAM_PROFILE_ADV_SET_STOPPED(pProfileAdv)      STAM_REL_PROFILE_ADV_SET_STOPPED(pProfileAdv)
     1035#else
     1036# define STAM_PROFILE_ADV_SET_STOPPED(pProfileAdv)      do { } while (0)
    9421037#endif
    9431038
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette