VirtualBox

Ignore:
Timestamp:
Apr 1, 2010 11:07:21 AM (15 years ago)
Author:
vboxsync
Message:

Metrics updates (untested)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/Performance.cpp

    r27885 r27930  
    135135    if (ASMAtomicIncU32(&cEnabled) == 1)
    136136    {
    137 #if 0
    138137        ComPtr<IInternalSessionControl> directControl;
    139138
     
    142141            return ret;
    143142
    144         /* get the associated console */
    145         ComPtr<IConsole> console;
    146         ret = directControl->COMGETTER(Console)(console.asOutParam()));
     143        /* get the associated console; this is a remote call (!) */
     144        ret = directControl->GetRemoteConsole(mConsole.asOutParam());
    147145        if (ret != S_OK)
    148146            return ret;
    149147
    150         ComPtr<IGuest> guest;
    151         ret = console->COMGETTER(Guest)(guest.asOutParam());
     148        ret = mConsole->COMGETTER(Guest)(mGuest.asOutParam());
    152149        if (ret == S_OK)
    153         {
    154         }
    155 #endif
     150            mGuest->COMSETTER(StatisticsUpdateInterval)(1000 /* 1000 ms */);
    156151    }
    157152    return ret;
     
    162157    if (ASMAtomicDecU32(&cEnabled) == 0)
    163158    {
     159        Assert(mGuest && mConsole);
     160        mGuest->COMSETTER(StatisticsUpdateInterval)(0 /* off */);
    164161    }
    165162    return S_OK;
    166163}
     164
     165int CollectorGuestHAL::preCollect(const CollectorHints& hints, uint64_t iTick)
     166{
     167    if (    mGuest
     168        &&  iTick != mLastTick)
     169    {
     170        mGuest->InternalGetStatistics(0, &mCpuUser, &mCpuKernel, &mCpuIdle,
     171                                      &mMemTotal, &mMemFree, &mMemBalloon, &mMemCache,
     172                                      &mPageTotal, &mPageFree);
     173        mLastTick = iTick;
     174    }
     175    return S_OK;
     176}
     177
    167178#endif /* VBOX_COLLECTOR_TEST_CASE */
    168179
     
    209220}
    210221
    211 void HostCpuLoadRaw::preCollect(CollectorHints& hints)
     222void HostCpuLoadRaw::preCollect(CollectorHints& hints, uint64_t iTick)
    212223{
    213224    hints.collectHostCpuLoad();
     
    273284}
    274285
    275 void HostRamUsage::preCollect(CollectorHints& hints)
     286void HostRamUsage::preCollect(CollectorHints& hints, uint64_t iTick)
    276287{
    277288    hints.collectHostRamUsage();
     
    311322}
    312323
    313 void MachineCpuLoadRaw::preCollect(CollectorHints& hints)
     324void MachineCpuLoadRaw::preCollect(CollectorHints& hints, uint64_t iTick)
    314325{
    315326    hints.collectProcessCpuLoad(mProcess);
     
    348359}
    349360
    350 void MachineRamUsage::preCollect(CollectorHints& hints)
     361void MachineRamUsage::preCollect(CollectorHints& hints, uint64_t iTick)
    351362{
    352363    hints.collectProcessRamUsage(mProcess);
     
    372383}
    373384
    374 void GuestCpuLoad::preCollect(CollectorHints& /* hints */)
    375 {
     385void GuestCpuLoad::preCollect(CollectorHints& hints, uint64_t iTick)
     386{
     387    mHAL->preCollect(hints, iTick);
    376388}
    377389
    378390void GuestCpuLoad::collect()
    379391{
    380 #if 0
    381     uint64_t processUser, processKernel, hostTotal;
    382 
    383     int rc = mHAL->getRawProcessCpuLoad(mProcess, &processUser, &processKernel, &hostTotal);
    384     if (RT_SUCCESS(rc))
    385     {
    386         if (hostTotal == mHostTotalPrev)
    387         {
    388             /* Nearly impossible, but... */
    389             mUser->put(0);
    390             mKernel->put(0);
    391         }
    392         else
    393         {
    394             mUser->put((ULONG)(PM_CPU_LOAD_MULTIPLIER * (processUser - mProcessUserPrev) / (hostTotal - mHostTotalPrev)));
    395             mKernel->put((ULONG)(PM_CPU_LOAD_MULTIPLIER * (processKernel - mProcessKernelPrev ) / (hostTotal - mHostTotalPrev)));
    396         }
    397 
    398         mHostTotalPrev     = hostTotal;
    399         mProcessUserPrev   = processUser;
    400         mProcessKernelPrev = processKernel;
    401     }
    402 #endif
     392    ULONG CpuUser = 0, CpuKernel = 0, CpuIdle = 0;
     393
     394    mGuestHAL->getGuestCpuLoad(&CpuUser, &CpuKernel, &CpuIdle);
     395    mUser->put((ULONG)(PM_CPU_LOAD_MULTIPLIER * CpuUser) / 100);
     396    mKernel->put((ULONG)(PM_CPU_LOAD_MULTIPLIER * CpuKernel) / 100);
     397    mIdle->put((ULONG)(PM_CPU_LOAD_MULTIPLIER * CpuIdle) / 100);
    403398}
    404399
     
    416411}
    417412
    418 void GuestRamUsage::preCollect(CollectorHints& /* hints */)
    419 {
     413void GuestRamUsage::preCollect(CollectorHints& hints,  uint64_t iTick)
     414{
     415    mHAL->preCollect(hints, iTick);
    420416}
    421417
    422418void GuestRamUsage::collect()
    423419{
    424 #if 0
    425     ULONG used;
    426     int rc = mHAL->getProcessMemoryUsage(mProcess, &used);
    427     if (RT_SUCCESS(rc))
    428         mUsed->put(used);
    429 #endif
     420    ULONG ulMemTotal = 0, ulMemFree = 0, ulMemBalloon = 0, ulMemCache = 0, ulPageTotal = 0, ulPageFree = 0;
     421
     422    mGuestHAL->getGuestMemLoad(&ulMemTotal, &ulMemFree, &ulMemBalloon, &ulMemCache, &ulPageTotal, &ulPageFree);
     423    mTotal->put(ulMemTotal);
     424    mFree->put(ulMemFree);
     425    mBallooned->put(ulMemBalloon);
     426    mCache->put(ulMemCache);
     427    mPagedTotal->put(ulPageTotal);
     428    mPagedFree->put(ulPageFree);
    430429}
    431430
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