VirtualBox

Changeset 11467 in vbox for trunk/src/VBox/Main


Ignore:
Timestamp:
Aug 18, 2008 2:52:12 PM (16 years ago)
Author:
vboxsync
Message:

Perf API: CPU/MHz counter re-introduced (Win implementation).

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

Legend:

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

    r11258 r11467  
    27392739    pm::SubMetric *cpuLoadKernel = new pm::SubMetric ("CPU/Load/Kernel");
    27402740    pm::SubMetric *cpuLoadIdle   = new pm::SubMetric ("CPU/Load/Idle");
     2741    pm::SubMetric *cpuMhzSM      = new pm::SubMetric ("CPU/MHZ");
    27412742    pm::SubMetric *ramUsageTotal = new pm::SubMetric ("RAM/Usage/Total");
    27422743    pm::SubMetric *ramUsageUsed  = new pm::SubMetric ("RAM/Usage/Used");
     
    27502751                                          cpuLoadIdle);
    27512752    aCollector->registerBaseMetric (cpuLoad);
     2753    pm::BaseMetric *cpuMhz =
     2754        metricFactory->createHostCpuMHz (objptr, cpuMhzSM);
     2755    aCollector->registerBaseMetric (cpuMhz);
    27522756    pm::BaseMetric *ramUsage =
    27532757        metricFactory->createHostRamUsage (objptr, ramUsageTotal, ramUsageUsed,
     
    27772781                                               new pm::AggregateMin()));
    27782782    aCollector->registerMetric (new pm::Metric(cpuLoad, cpuLoadIdle,
     2783                                               new pm::AggregateMax()));
     2784
     2785    aCollector->registerMetric (new pm::Metric(cpuMhz, cpuMhzSM, 0));
     2786    aCollector->registerMetric (new pm::Metric(cpuMhz, cpuMhzSM,
     2787                                               new pm::AggregateAvg()));
     2788    aCollector->registerMetric (new pm::Metric(cpuMhz, cpuMhzSM,
     2789                                               new pm::AggregateMin()));
     2790    aCollector->registerMetric (new pm::Metric(cpuMhz, cpuMhzSM,
    27792791                                               new pm::AggregateMax()));
    27802792
  • trunk/src/VBox/Main/Makefile.kmk

    r11086 r11467  
    276276VBoxSVC_SOURCES.win     +=     win/PerformanceWin.cpp
    277277VBoxSVC_LDFLAGS.solaris += -lkstat
    278 VBoxSVC_LDFLAGS.win     += wbemuuid.lib
     278VBoxSVC_LDFLAGS.win     += wbemuuid.lib powrprof.lib
    279279endif
    280280
  • trunk/src/VBox/Main/testcase/Makefile.kmk

    r11086 r11467  
    113113tstCollector_INCS     = ../include
    114114tstCollector_LDFLAGS.solaris += -lkstat
    115 tstCollector_LDFLAGS.win += wbemuuid.lib
     115tstCollector_LDFLAGS.win += wbemuuid.lib powrprof.lib
    116116
    117117
  • trunk/src/VBox/Main/win/PerformanceWin.cpp

    r11180 r11467  
    2323
    2424#include <Wbemidl.h>
     25extern "C" {
     26#include <powrprof.h>
     27}
    2528#include <iprt/err.h>
     29#include <iprt/mp.h>
    2630
    2731#include "Logging.h"
     
    334338}
    335339
     340typedef struct _PROCESSOR_POWER_INFORMATION {
     341  ULONG  Number;
     342  ULONG  MaxMhz;
     343  ULONG  CurrentMhz;
     344  ULONG  MhzLimit;
     345  ULONG  MaxIdleState;
     346  ULONG  CurrentIdleState;
     347} PROCESSOR_POWER_INFORMATION , *PPROCESSOR_POWER_INFORMATION;
     348
    336349int CollectorWin::getHostCpuMHz(ULONG *mhz)
    337350{
    338     return VERR_NOT_IMPLEMENTED;
     351    uint64_t uTotalMhz   = 0;
     352    RTCPUID  nProcessors = RTMpGetCount();
     353    PPROCESSOR_POWER_INFORMATION ppi = new PROCESSOR_POWER_INFORMATION[nProcessors];
     354    LONG ns = CallNtPowerInformation(ProcessorInformation, NULL, 0, ppi,
     355        nProcessors * sizeof(PROCESSOR_POWER_INFORMATION));
     356    if (ns)
     357    {
     358        Log(("CallNtPowerInformation() -> %x\n", ns));
     359        return VERR_INTERNAL_ERROR;
     360    }
     361
     362    /* Compute an average over all CPUs */
     363    for (unsigned i = 0; i < nProcessors;  i++)
     364        uTotalMhz += ppi[i].CurrentMhz;
     365    *mhz = (ULONG)(uTotalMhz / nProcessors);
     366
     367    LogFlowThisFunc(("mhz=%u\n", *mhz));
     368    LogFlowThisFuncLeave();
     369
     370    return VINF_SUCCESS;
    339371}
    340372
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