VirtualBox

Changeset 11498 in vbox for trunk


Ignore:
Timestamp:
Aug 19, 2008 6:50:33 PM (16 years ago)
Author:
vboxsync
Message:

PerfAPI: Moved linux implementation of CPU/MHz to CollectorHAL since it is generic. Windows implementation needs to be moved to RTMpGetCurFrequency.

Location:
trunk/src/VBox/Main
Files:
3 edited

Legend:

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

    r11481 r11498  
    2525 * @todo list:
    2626 *
    27  * 1) Solaris backend
    28  * 2) Linux backend
    29  * 3) Detection of erroneous metric names
    30  * 4) Min/max ranges for metrics
    31  * 5) Darwin backend
    32  * 6) [OS/2 backend]
     27 * 1) Detection of erroneous metric names
     28 * 2) Wildcards in metric names
     29 * 3) Darwin backend
     30 * 4) [OS/2 backend]
    3331 */
    3432
     
    3937#include <iprt/string.h>
    4038#include <iprt/mem.h>
     39#include <iprt/mp.h>
    4140
    4241#include "Logging.h"
     
    9392{
    9493    return E_NOTIMPL;
     94}
     95
     96/* Generic implementations */
     97
     98int CollectorHAL::getHostCpuMHz(ULONG *mhz)
     99{
     100    RTCPUID nProcessors = RTMpGetCount();
     101
     102    if (nProcessors == 0)
     103        return VERR_NOT_IMPLEMENTED;
     104
     105    uint64_t uTotalMHz  = 0;
     106
     107    for (RTCPUID i = 0; i < nProcessors; ++i)
     108        uTotalMHz += RTMpGetCurFrequency(RTMpCpuIdFromSetIndex(i));
     109
     110    *mhz = (ULONG)(uTotalMHz / nProcessors);
     111    return VINF_SUCCESS;
    95112}
    96113
  • trunk/src/VBox/Main/include/Performance.h

    r11377 r11498  
    6767    public:
    6868        virtual int getHostCpuLoad(ULONG *user, ULONG *kernel, ULONG *idle);
    69         virtual int getHostCpuMHz(ULONG *mhz) = 0;
     69        virtual int getHostCpuMHz(ULONG *mhz);
    7070        virtual int getHostMemoryUsage(ULONG *total, ULONG *used, ULONG *available) = 0;
    7171        virtual int getProcessCpuLoad(RTPROCESS process, ULONG *user, ULONG *kernel);
  • trunk/src/VBox/Main/linux/PerformanceLinux.cpp

    r11483 r11498  
    2525#include <iprt/alloc.h>
    2626#include <iprt/err.h>
    27 #include <iprt/mp.h>
    2827#include <iprt/param.h>
    2928#include <iprt/string.h>
     
    3534{
    3635public:
    37     virtual int getHostCpuMHz(ULONG *mhz);
    3836    virtual int getHostMemoryUsage(ULONG *total, ULONG *used, ULONG *available);
    3937    virtual int getProcessMemoryUsage(RTPROCESS process, ULONG *used);
     
    9391
    9492    return rc;
    95 }
    96 
    97 int CollectorLinux::getHostCpuMHz(ULONG *mhz)
    98 {
    99     RTCPUID nProcessors = RTMpGetCount();
    100     uint64_t uTotalMHz  = 0;
    101 
    102     for (RTCPUID i = 0; i < nProcessors; ++i)
    103         uTotalMHz += RTMpGetCurFrequency(RTMpCpuIdFromSetIndex(i));
    104 
    105     *mhz = (ULONG)(uTotalMHz / nProcessors);
    106     return VINF_SUCCESS;
    10793}
    10894
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