VirtualBox

Changeset 1537 in vbox for trunk/src/VBox/Runtime


Ignore:
Timestamp:
Mar 16, 2007 5:02:13 PM (18 years ago)
Author:
vboxsync
Message:

min/max.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/testcase/tstTimer.cpp

    r1 r1537  
    3636*******************************************************************************/
    3737static volatile unsigned gcTicks;
     38static volatile uint64_t gu64Min;
     39static volatile uint64_t gu64Max;
     40static volatile uint64_t gu64Prev;
    3841
    3942static DECLCALLBACK(void) TimerCallback(PRTTIMER pTimer, void *pvUser)
    4043{
    4144    gcTicks++;
     45
     46    const uint64_t u64Now = RTTimeNanoTS();
     47    if (gu64Prev)
     48    {
     49        const uint64_t u64Delta = u64Now - gu64Prev;
     50        if (u64Delta < gu64Min)
     51            gu64Min = u64Delta;
     52        if (u64Delta > gu64Max)
     53            gu64Max = u64Delta;
     54    }
     55    gu64Prev = u64Now;
    4256}
    4357
     
    125139        gcTicks = 0;
    126140        PRTTIMER pTimer;
     141        gu64Max = 0;
     142        gu64Min = UINT64_MAX;
     143        gu64Prev = 0;
    127144        rc = RTTimerCreate(&pTimer, aTests[i].uMilliesInterval, TimerCallback, NULL);
    128145        if (RT_FAILURE(rc))
     
    134151
    135152        /*
    136          * Sleep for a while and then kill it.
     153         * Active waiting for 2 seconds and then destroy it.
    137154         */
    138155        uint64_t uTSBegin = RTTimeNanoTS();
    139 #if 1
    140156        while (RTTimeNanoTS() - uTSBegin < (uint64_t)aTests[i].uMilliesWait * 1000000)
    141157            /* nothing */;
    142 
    143 #else
    144         rc = RTThreadSleep(aTests[i].uMilliesWait);
    145 #endif
    146158        uint64_t uTSEnd = RTTimeNanoTS();
    147159        uint64_t uTSDiff = uTSEnd - uTSBegin;
     
    170182        if (gcTicks < aTests[i].cLower)
    171183        {
    172             RTPrintf("tstTimer: FAILURE - Too few ticks gcTicks=%d (expected %d-%d)\n", gcTicks, aTests[i].cUpper, aTests[i].cLower);
     184            RTPrintf("tstTimer: FAILURE - Too few ticks gcTicks=%d (expected %d-%d)", gcTicks, aTests[i].cUpper, aTests[i].cLower);
    173185            cErrors++;
    174186        }
    175187        else if (gcTicks > aTests[i].cUpper)
    176188        {
    177             RTPrintf("tstTimer: FAILURE - Too many ticks gcTicks=%d (expected %d-%d)\n", gcTicks, aTests[i].cUpper, aTests[i].cLower);
     189            RTPrintf("tstTimer: FAILURE - Too many ticks gcTicks=%d (expected %d-%d)", gcTicks, aTests[i].cUpper, aTests[i].cLower);
    178190            cErrors++;
    179191        }
    180192        else
    181             RTPrintf("tstTimer: OK      - gcTicks=%d\n",  gcTicks);
     193            RTPrintf("tstTimer: OK      - gcTicks=%d",  gcTicks);
     194        RTPrintf(" min=%RU64 max=%RU64\n", gu64Min, gu64Max);
    182195    }
    183196
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