Index: trunk/src/VBox/Frontends/VBoxManage/VBoxManage.cpp
===================================================================
--- trunk/src/VBox/Frontends/VBoxManage/VBoxManage.cpp	(revision 13081)
+++ trunk/src/VBox/Frontends/VBoxManage/VBoxManage.cpp	(revision 13082)
@@ -7768,44 +7768,4 @@
 }
 
-static int countMatchingMetrics(ComPtr<IVirtualBox> aVirtualBox,
-                                ComPtr<IPerformanceCollector> performanceCollector,
-                                ComSafeArrayIn(INPTR BSTR, metrics),
-                                ComSafeArrayIn(IUnknown *, objects),
-                                bool listMatches)
-{
-    HRESULT rc;
-    com::SafeIfaceArray<IPerformanceMetric> metricInfo;
-
-    CHECK_ERROR(performanceCollector,
-        GetMetrics(ComSafeArrayInArg(metrics),
-                   ComSafeArrayInArg(objects),
-                   ComSafeArrayAsOutParam(metricInfo)));
-
-    if (metricInfo.size())
-    {
-        if (listMatches)
-        {
-            ComPtr<IUnknown> object;
-            Bstr metricName;
-            RTPrintf("The following metrics will be collected:\n\n"
-                     "Object     Metric\n"
-                     "---------- --------------------\n");
-            for (size_t i = 0; i < metricInfo.size(); i++)
-            {
-                CHECK_ERROR(metricInfo[i], COMGETTER(Object)(object.asOutParam()));
-                CHECK_ERROR(metricInfo[i], COMGETTER(MetricName)(metricName.asOutParam()));
-                RTPrintf("%-10ls %-20ls\n",
-                    getObjectName(aVirtualBox, object).raw(), metricName.raw());
-            }
-            RTPrintf("\n");
-        }
-    }
-    else
-    {
-        RTPrintf("No metrics match the specified filter!\n");
-    }
-    return metricInfo.size();
-}
-
 static void listAffectedMetrics(ComPtr<IVirtualBox> aVirtualBox,
                                 ComSafeArrayIn(IPerformanceMetric*, aMetrics))
@@ -7934,20 +7894,12 @@
         return 1;
 
+    com::SafeIfaceArray<IPerformanceMetric> affectedMetrics;
+    CHECK_ERROR(performanceCollector,
+        SetupMetrics(ComSafeArrayAsInParam(metrics),
+                     ComSafeArrayAsInParam(objects), period, samples,
+                     ComSafeArrayAsOutParam(affectedMetrics)));
     if (listMatches)
-    {
-        com::SafeIfaceArray<IPerformanceMetric> affectedMetrics;
-        CHECK_ERROR(performanceCollector,
-            SetupMetricsEx(ComSafeArrayAsInParam(metrics),
-                           ComSafeArrayAsInParam(objects), period, samples,
-                           ComSafeArrayAsOutParam(affectedMetrics)));
         listAffectedMetrics(aVirtualBox,
                             ComSafeArrayAsInParam(affectedMetrics));
-    }
-    else
-    {
-        CHECK_ERROR(performanceCollector,
-            SetupMetrics(ComSafeArrayAsInParam(metrics),
-                         ComSafeArrayAsInParam(objects), period, samples));
-    }
     
     return 0;
@@ -7975,4 +7927,7 @@
     com::SafeArray<BSTR>          retNames;
     com::SafeIfaceArray<IUnknown> retObjects;
+    com::SafeArray<BSTR>          retUnits;
+    com::SafeArray<ULONG>         retScales;
+    com::SafeArray<ULONG>         retSequenceNumbers;
     com::SafeArray<ULONG>         retIndices;
     com::SafeArray<ULONG>         retLengths;
@@ -7982,4 +7937,7 @@
                                              ComSafeArrayAsOutParam(retNames),
                                              ComSafeArrayAsOutParam(retObjects),
+                                             ComSafeArrayAsOutParam(retUnits),
+                                             ComSafeArrayAsOutParam(retScales),
+                                             ComSafeArrayAsOutParam(retSequenceNumbers),
                                              ComSafeArrayAsOutParam(retIndices),
                                              ComSafeArrayAsOutParam(retLengths),
@@ -7990,30 +7948,15 @@
     for (unsigned i = 0; i < retNames.size(); i++)
     {
-        // Get info for the metric
-        com::SafeArray<BSTR> nameOfMetric(1);
-        Bstr tmpName(retNames[i]);
-        tmpName.detachTo (&nameOfMetric[0]);
-        com::SafeIfaceArray<IUnknown> anObject(1);
-        ComPtr<IUnknown> tmpObject(retObjects[i]);
-        tmpObject.queryInterfaceTo(&anObject[0]);
-        com::SafeIfaceArray <IPerformanceMetric> metricInfo;
-        CHECK_RC_BREAK (performanceCollector->GetMetrics( ComSafeArrayAsInParam(nameOfMetric),
-                                               ComSafeArrayAsInParam(anObject),
-                                               ComSafeArrayAsOutParam(metricInfo) ));
-        BSTR metricUnitBSTR;
-        CHECK_RC_BREAK (metricInfo[0]->COMGETTER(Unit) (&metricUnitBSTR));
-        Bstr metricUnit(metricUnitBSTR);
+        Bstr metricUnit(retUnits[i]);
         Bstr metricName(retNames[i]);
-        LONG minVal, maxVal;
-        CHECK_RC_BREAK (metricInfo[0]->COMGETTER(MinimumValue) (&minVal));
-        CHECK_RC_BREAK (metricInfo[0]->COMGETTER(MaximumValue) (&maxVal));
         RTPrintf("%-10ls %-20ls ", getObjectName(aVirtualBox, retObjects[i]).raw(), metricName.raw());
         const char *separator = "";
         for (unsigned j = 0; j < retLengths[i]; j++)
         {
-            if (strcmp((const char *)metricUnit.raw(), "%"))
+            if (retScales[i] == 1)
                 RTPrintf("%s%d %ls", separator, retData[retIndices[i] + j], metricUnit.raw());
             else
-                RTPrintf("%s%d.%02d%%", separator, retData[retIndices[i] + j] / 1000, (retData[retIndices[i] + j] / 10) % 100);
+                RTPrintf("%s%d.%02d%ls", separator, retData[retIndices[i] + j] / retScales[i],
+                         (retData[retIndices[i] + j] * 100 / retScales[i]) % 100, metricUnit.raw());
             separator = ", ";
         }
@@ -8121,13 +8064,14 @@
 
 
-    if (countMatchingMetrics(aVirtualBox, performanceCollector,
-                             ComSafeArrayAsInParam(metrics),
-                             ComSafeArrayAsInParam(objects),
-                             listMatches) == 0)
-        return 1;
-
+    com::SafeIfaceArray<IPerformanceMetric> affectedMetrics;
     CHECK_ERROR(performanceCollector,
         SetupMetrics(ComSafeArrayAsInParam(baseMetrics),
-                     ComSafeArrayAsInParam(objects), period, samples));
+                     ComSafeArrayAsInParam(objects), period, samples,
+                     ComSafeArrayAsOutParam(affectedMetrics)));
+    if (listMatches)
+        listAffectedMetrics(aVirtualBox,
+                            ComSafeArrayAsInParam(affectedMetrics));
+    if (!affectedMetrics.size())
+        return 1;
 
     if (isDetached)
@@ -8153,4 +8097,7 @@
         com::SafeArray<BSTR>          retNames;
         com::SafeIfaceArray<IUnknown> retObjects;
+        com::SafeArray<BSTR>          retUnits;
+        com::SafeArray<ULONG>         retScales;
+        com::SafeArray<ULONG>         retSequenceNumbers;
         com::SafeArray<ULONG>         retIndices;
         com::SafeArray<ULONG>         retLengths;
@@ -8160,4 +8107,7 @@
                                                  ComSafeArrayAsOutParam(retNames),
                                                  ComSafeArrayAsOutParam(retObjects),
+                                                 ComSafeArrayAsOutParam(retUnits),
+                                                 ComSafeArrayAsOutParam(retScales),
+                                                 ComSafeArrayAsOutParam(retSequenceNumbers),
                                                  ComSafeArrayAsOutParam(retIndices),
                                                  ComSafeArrayAsOutParam(retLengths),
@@ -8165,31 +8115,15 @@
         for (unsigned i = 0; i < retNames.size(); i++)
         {
-
-            // Get info for the metric
-            com::SafeArray<BSTR> nameOfMetric(1);
-            Bstr tmpName(retNames[i]);
-            tmpName.detachTo (&nameOfMetric[0]);
-            com::SafeIfaceArray<IUnknown> anObject(1);
-            ComPtr<IUnknown> tmpObject(retObjects[i]);
-            tmpObject.queryInterfaceTo(&anObject[0]);
-            com::SafeIfaceArray <IPerformanceMetric> metricInfo;
-            CHECK_RC_BREAK (performanceCollector->GetMetrics( ComSafeArrayAsInParam(nameOfMetric),
-                                                   ComSafeArrayAsInParam(anObject),
-                                                   ComSafeArrayAsOutParam(metricInfo) ));
-            BSTR metricUnitBSTR;
-            CHECK_RC_BREAK (metricInfo[0]->COMGETTER(Unit) (&metricUnitBSTR));
-            Bstr metricUnit(metricUnitBSTR);
+            Bstr metricUnit(retUnits[i]);
             Bstr metricName(retNames[i]);
-            LONG minVal, maxVal;
-            CHECK_RC_BREAK (metricInfo[0]->COMGETTER(MinimumValue) (&minVal));
-            CHECK_RC_BREAK (metricInfo[0]->COMGETTER(MaximumValue) (&maxVal));
             RTPrintf("%-12s %-10ls %-20ls ", ts, getObjectName(aVirtualBox, retObjects[i]).raw(), metricName.raw());
             const char *separator = "";
             for (unsigned j = 0; j < retLengths[i]; j++)
             {
-                if (strcmp((const char *)metricUnit.raw(), "%"))
+                if (retScales[i] == 1)
                     RTPrintf("%s%d %ls", separator, retData[retIndices[i] + j], metricUnit.raw());
                 else
-                    RTPrintf("%s%d.%02d%%", separator, retData[retIndices[i] + j] / 1000, retData[retIndices[i] + j] % 100);
+                    RTPrintf("%s%d.%02d%ls", separator, retData[retIndices[i] + j] / retScales[i],
+                             (retData[retIndices[i] + j] * 100 / retScales[i]) % 100, metricUnit.raw());
                 separator = ", ";
             }
Index: trunk/src/VBox/Main/PerformanceImpl.cpp
===================================================================
--- trunk/src/VBox/Main/PerformanceImpl.cpp	(revision 13081)
+++ trunk/src/VBox/Main/PerformanceImpl.cpp	(revision 13082)
@@ -259,35 +259,7 @@
 PerformanceCollector::SetupMetrics (ComSafeArrayIn (INPTR BSTR, metricNames),
                                     ComSafeArrayIn (IUnknown *, objects),
-                                    ULONG aPeriod, ULONG aCount)
-{
-    LogFlowThisFuncEnter();
-    com::SafeIfaceArray <IPerformanceMetric> tmp;
-    return SetupMetricsInt(ComSafeArrayInArg(metricNames),
-                           ComSafeArrayInArg(objects),
-                           aPeriod, aCount,
-                           false, ComSafeArrayAsOutParam(tmp));
-}
-
-STDMETHODIMP
-PerformanceCollector::SetupMetricsEx (ComSafeArrayIn (INPTR BSTR, metricNames),
-                                      ComSafeArrayIn (IUnknown *, objects),
-                                      ULONG aPeriod, ULONG aCount,
-                                      ComSafeArrayOut (IPerformanceMetric *,
-                                                       outMetrics))
-{
-    LogFlowThisFuncEnter();
-    return SetupMetricsInt(ComSafeArrayInArg(metricNames),
-                           ComSafeArrayInArg(objects),
-                           aPeriod, aCount,
-                           true, ComSafeArrayOutArg(outMetrics));
-}
-
-HRESULT
-PerformanceCollector::SetupMetricsInt (ComSafeArrayIn (INPTR BSTR, metricNames),
-                                       ComSafeArrayIn (IUnknown *, objects),
-                                       ULONG aPeriod, ULONG aCount,
-                                       bool reportAffected,
-                                       ComSafeArrayOut (IPerformanceMetric *,
-                                                        outMetrics))
+                                    ULONG aPeriod, ULONG aCount,
+                                    ComSafeArrayOut (IPerformanceMetric *,
+                                                     outMetrics))
 {
     AutoCaller autoCaller (this);
@@ -320,17 +292,14 @@
                 (*it)->enable();
             }
-            if (reportAffected)
-                filteredMetrics.push_back(*it);
+            filteredMetrics.push_back(*it);
         }
         
-    if (reportAffected)
-    {
-        com::SafeIfaceArray<IPerformanceMetric> retMetrics (filteredMetrics.size());
-        int i = 0;
-        for (it = filteredMetrics.begin();
-             it != filteredMetrics.end() && SUCCEEDED (rc); ++it)
-            rc = toIPerformanceMetric(*it, &retMetrics [i++]);
-        retMetrics.detachTo (ComSafeArrayOutArg(outMetrics));
-    }
+    com::SafeIfaceArray<IPerformanceMetric> retMetrics (filteredMetrics.size());
+    int i = 0;
+    for (it = filteredMetrics.begin();
+         it != filteredMetrics.end() && SUCCEEDED (rc); ++it)
+        rc = toIPerformanceMetric(*it, &retMetrics [i++]);
+    retMetrics.detachTo (ComSafeArrayOutArg(outMetrics));
+
     LogFlowThisFuncLeave();
     return rc;
@@ -339,31 +308,7 @@
 STDMETHODIMP
 PerformanceCollector::EnableMetrics (ComSafeArrayIn (INPTR BSTR, metricNames),
-                                     ComSafeArrayIn (IUnknown *, objects))
-{
-    LogFlowThisFuncEnter();
-    com::SafeIfaceArray <IPerformanceMetric> tmp;
-    return EnableMetricsInt (ComSafeArrayInArg(metricNames),
-                             ComSafeArrayInArg(objects),
-                             false, ComSafeArrayAsOutParam(tmp));
-}
-
-STDMETHODIMP
-PerformanceCollector::EnableMetricsEx (ComSafeArrayIn (INPTR BSTR, metricNames),
-                                       ComSafeArrayIn (IUnknown *, objects),
-                                       ComSafeArrayOut (IPerformanceMetric *,
-                                                        outMetrics))
-{
-    LogFlowThisFuncEnter();
-    return EnableMetricsInt (ComSafeArrayInArg(metricNames),
-                             ComSafeArrayInArg(objects),
-                             true, ComSafeArrayOutArg(outMetrics));
-}
-
-HRESULT
-PerformanceCollector::EnableMetricsInt (ComSafeArrayIn (INPTR BSTR, metricNames),
-                                        ComSafeArrayIn (IUnknown *, objects),
-                                        bool reportAffected,
-                                        ComSafeArrayOut (IPerformanceMetric *,
-                                                         outMetrics))
+                                     ComSafeArrayIn (IUnknown *, objects),
+                                     ComSafeArrayOut (IPerformanceMetric *,
+                                                      outMetrics))
 {
     AutoCaller autoCaller (this);
@@ -384,17 +329,14 @@
         {
             (*it)->enable();
-            if (reportAffected)
-                filteredMetrics.push_back(*it);
+            filteredMetrics.push_back(*it);
         }
 
-    if (reportAffected)
-    {
-        com::SafeIfaceArray<IPerformanceMetric> retMetrics (filteredMetrics.size());
-        int i = 0;
-        for (it = filteredMetrics.begin();
-             it != filteredMetrics.end() && SUCCEEDED (rc); ++it)
-            rc = toIPerformanceMetric(*it, &retMetrics [i++]);
-        retMetrics.detachTo (ComSafeArrayOutArg(outMetrics));
-    }
+    com::SafeIfaceArray<IPerformanceMetric> retMetrics (filteredMetrics.size());
+    int i = 0;
+    for (it = filteredMetrics.begin();
+         it != filteredMetrics.end() && SUCCEEDED (rc); ++it)
+        rc = toIPerformanceMetric(*it, &retMetrics [i++]);
+    retMetrics.detachTo (ComSafeArrayOutArg(outMetrics));
+
     LogFlowThisFuncLeave();
     return rc;
@@ -403,31 +345,7 @@
 STDMETHODIMP
 PerformanceCollector::DisableMetrics (ComSafeArrayIn (INPTR BSTR, metricNames),
-                                      ComSafeArrayIn (IUnknown *, objects))
-{
-    LogFlowThisFuncEnter();
-    com::SafeIfaceArray <IPerformanceMetric> tmp;
-    return DisableMetricsInt (ComSafeArrayInArg(metricNames),
-                              ComSafeArrayInArg(objects),
-                              false, ComSafeArrayAsOutParam(tmp));
-}
-
-STDMETHODIMP
-PerformanceCollector::DisableMetricsEx (ComSafeArrayIn (INPTR BSTR, metricNames),
                                       ComSafeArrayIn (IUnknown *, objects),
                                       ComSafeArrayOut (IPerformanceMetric *,
                                                        outMetrics))
-{
-    LogFlowThisFuncEnter();
-    return DisableMetricsInt (ComSafeArrayInArg(metricNames),
-                              ComSafeArrayInArg(objects),
-                              true, ComSafeArrayOutArg(outMetrics));
-}
-
-HRESULT
-PerformanceCollector::DisableMetricsInt (ComSafeArrayIn (INPTR BSTR, metricNames),
-                                         ComSafeArrayIn (IUnknown *, objects),
-                                         bool reportAffected,
-                                         ComSafeArrayOut (IPerformanceMetric *,
-                                                          outMetrics))
 {
     AutoCaller autoCaller (this);
@@ -448,17 +366,14 @@
         {
             (*it)->disable();
-            if (reportAffected)
-                filteredMetrics.push_back(*it);
+            filteredMetrics.push_back(*it);
         }
 
-    if (reportAffected)
-    {
-        com::SafeIfaceArray<IPerformanceMetric> retMetrics (filteredMetrics.size());
-        int i = 0;
-        for (it = filteredMetrics.begin();
-             it != filteredMetrics.end() && SUCCEEDED (rc); ++it)
-            rc = toIPerformanceMetric(*it, &retMetrics [i++]);
-        retMetrics.detachTo (ComSafeArrayOutArg(outMetrics));
-    }
+    com::SafeIfaceArray<IPerformanceMetric> retMetrics (filteredMetrics.size());
+    int i = 0;
+    for (it = filteredMetrics.begin();
+         it != filteredMetrics.end() && SUCCEEDED (rc); ++it)
+        rc = toIPerformanceMetric(*it, &retMetrics [i++]);
+    retMetrics.detachTo (ComSafeArrayOutArg(outMetrics));
+
     LogFlowThisFuncLeave();
     return rc;
@@ -470,34 +385,10 @@
                                         ComSafeArrayOut (BSTR, outMetricNames),
                                         ComSafeArrayOut (IUnknown *, outObjects),
+                                        ComSafeArrayOut (BSTR, outUnits),
+                                        ComSafeArrayOut (ULONG, outScales),
+                                        ComSafeArrayOut (ULONG, outSequenceNumbers),
                                         ComSafeArrayOut (ULONG, outDataIndices),
                                         ComSafeArrayOut (ULONG, outDataLengths),
                                         ComSafeArrayOut (LONG, outData))
-{
-    com::SafeArray <BSTR> tmpUnits;
-    com::SafeArray <ULONG> tmpScales;
-    com::SafeArray <ULONG> tmpSequenceNumbers;
-    return QueryMetricsDataEx(ComSafeArrayInArg(metricNames),
-                              ComSafeArrayInArg(objects),
-                              ComSafeArrayOutArg(outMetricNames),
-                              ComSafeArrayOutArg(outObjects),
-                              ComSafeArrayAsOutParam(tmpUnits),
-                              ComSafeArrayAsOutParam(tmpScales),
-                              ComSafeArrayAsOutParam(tmpSequenceNumbers),
-                              ComSafeArrayOutArg(outDataIndices),
-                              ComSafeArrayOutArg(outDataLengths),
-                              ComSafeArrayOutArg(outData));
-}
-
-STDMETHODIMP
-PerformanceCollector::QueryMetricsDataEx (ComSafeArrayIn (INPTR BSTR, metricNames),
-                                          ComSafeArrayIn (IUnknown *, objects),
-                                          ComSafeArrayOut (BSTR, outMetricNames),
-                                          ComSafeArrayOut (IUnknown *, outObjects),
-                                          ComSafeArrayOut (BSTR, outUnits),
-                                          ComSafeArrayOut (ULONG, outScales),
-                                          ComSafeArrayOut (ULONG, outSequenceNumbers),
-                                          ComSafeArrayOut (ULONG, outDataIndices),
-                                          ComSafeArrayOut (ULONG, outDataLengths),
-                                          ComSafeArrayOut (LONG, outData))
 {
     AutoCaller autoCaller (this);
Index: trunk/src/VBox/Main/idl/VirtualBox.xidl
===================================================================
--- trunk/src/VBox/Main/idl/VirtualBox.xidl	(revision 13081)
+++ trunk/src/VBox/Main/idl/VirtualBox.xidl	(revision 13082)
@@ -10557,14 +10557,19 @@
     <method name="setupMetrics">
       <desc>
-        Sets parameters of specified base metrics for a set of objects.
-        <note>
-          @c Null metrics array means all metrics. @c Null object array means
-          all existing objects.
+        Sets parameters of specified base metrics for a set of objects. Returns 
+        an array of <link to="IPerformanceMetric" /> describing the metrics have 
+        been affected.
+        <note>
+          @c Null or empty metric name array means all metrics. @c Null or empty
+          object array means all existing objects. If metric name array contains 
+          a single element and object array contains many, the single metric 
+          name array element is applied to each object array element to form 
+          metric/object pairs.
         </note>
       </desc>
       <param name="metricNames" type="wstring" dir="in" safearray="yes">
         <desc>
-          Metric name filter. Currently, only a comma-separated list of metrics
-          is supported.
+          Metric name filter. Comma-separated list of metrics with wildcard 
+          support.
         </desc>
       </param>
@@ -10586,18 +10591,28 @@
         </desc>
       </param>
+      <param name="affectedMetrics" type="IPerformanceMetric" dir="return" safearray="yes">
+        <desc>
+          Array of metrics that have been modified by the call to this method.
+        </desc>
+      </param>
     </method>
 
     <method name="enableMetrics">
       <desc>
-        Turns on collecting specified base metrics.
-        <note>
-          @c Null metrics array means all metrics. @c Null object array means
-          all existing objects.
+        Turns on collecting specified base metrics. Returns an array of
+        <link to="IPerformanceMetric" /> describing the metrics have been
+        affected.
+        <note>
+          @c Null or empty metric name array means all metrics. @c Null or empty
+          object array means all existing objects. If metric name array contains 
+          a single element and object array contains many, the single metric 
+          name array element is applied to each object array element to form 
+          metric/object pairs.
         </note>
       </desc>
       <param name="metricNames" type="wstring" dir="in" safearray="yes">
         <desc>
-          Metric name filter. Currently, only a comma-separated list of metrics
-          is supported.
+          Metric name filter. Comma-separated list of metrics with wildcard 
+          support.
         </desc>
       </param>
@@ -10607,18 +10622,28 @@
         </desc>
       </param>
+      <param name="affectedMetrics" type="IPerformanceMetric" dir="return" safearray="yes">
+        <desc>
+          Array of metrics that have been modified by the call to this method.
+        </desc>
+      </param>
     </method>
 
     <method name="disableMetrics">
       <desc>
-        Turns off collecting specified base metrics.
-        <note>
-          @c Null metrics array means all metrics. @c Null object array means
-          all existing objects.
+        Turns off collecting specified base metrics. Returns an array of
+        <link to="IPerformanceMetric" /> describing the metrics have been
+        affected.
+        <note>
+          @c Null or empty metric name array means all metrics. @c Null or empty
+          object array means all existing objects. If metric name array contains 
+          a single element and object array contains many, the single metric 
+          name array element is applied to each object array element to form 
+          metric/object pairs.
         </note>
       </desc>
       <param name="metricNames" type="wstring" dir="in" safearray="yes">
         <desc>
-          Metric name filter. Currently, only a comma-separated list of metrics
-          is supported.
+          Metric name filter. Comma-separated list of metrics with wildcard 
+          support.
         </desc>
       </param>
@@ -10628,40 +10653,4 @@
         </desc>
       </param>
-    </method>
-
-    <method name="setupMetricsEx">
-      <desc>
-        Sets parameters of specified base metrics for a set of objects.
-        Indentical to <link to="IPerformanceCollector::setupMetrics" /> except
-        that it returns an array of <link to="IPerformanceMetric" /> describing
-        the metrics have been affected.
-        <note>
-          @c Null metrics array means all metrics. @c Null object array means
-          all existing objects.
-        </note>
-      </desc>
-      <param name="metricNames" type="wstring" dir="in" safearray="yes">
-        <desc>
-          Metric name filter. Currently, only a comma-separated list of metrics
-          is supported.
-        </desc>
-      </param>
-      <param name="objects" type="$unknown" dir="in" safearray="yes">
-        <desc>
-          Set of objects to setup metric parameters for.
-        </desc>
-      </param>
-      <param name="period" type="unsigned long" dir="in">
-        <desc>
-          Time interval in seconds between two consecutive samples of performace
-          data.
-        </desc>
-      </param>
-      <param name="count" type="unsigned long" dir="in">
-        <desc>
-          Number of samples to retain in performance data history. Older samples
-          get discarded.
-        </desc>
-      </param>
       <param name="affectedMetrics" type="IPerformanceMetric" dir="return" safearray="yes">
         <desc>
@@ -10671,80 +10660,27 @@
     </method>
 
-    <method name="enableMetricsEx">
-      <desc>
-        Turns on collecting specified base metrics.
-        Indentical to <link to="IPerformanceCollector::enableMetrics" /> except
-        that it returns an array of <link to="IPerformanceMetric" /> describing
-        the metrics have been affected.
-        <note>
-          @c Null metrics array means all metrics. @c Null object array means
-          all existing objects.
-        </note>
-      </desc>
-      <param name="metricNames" type="wstring" dir="in" safearray="yes">
-        <desc>
-          Metric name filter. Currently, only a comma-separated list of metrics
-          is supported.
-        </desc>
-      </param>
-      <param name="objects" type="$unknown" dir="in" safearray="yes">
-        <desc>
-          Set of objects to enable metrics for.
-        </desc>
-      </param>
-      <param name="affectedMetrics" type="IPerformanceMetric" dir="return" safearray="yes">
-        <desc>
-          Array of metrics that have been modified by the call to this method.
-        </desc>
-      </param>
-    </method>
-
-    <method name="disableMetricsEx">
-      <desc>
-        Turns off collecting specified base metrics.
-        Indentical to <link to="IPerformanceCollector::disableMetrics" /> except
-        that it returns an array of <link to="IPerformanceMetric" /> describing
-        the metrics have been affected.
-        <note>
-          @c Null metrics array means all metrics. @c Null object array means
-          all existing objects.
-        </note>
-      </desc>
-      <param name="metricNames" type="wstring" dir="in" safearray="yes">
-        <desc>
-          Metric name filter. Currently, only a comma-separated list of metrics
-          is supported.
-        </desc>
-      </param>
-      <param name="objects" type="$unknown" dir="in" safearray="yes">
-        <desc>
-          Set of objects to disable metrics for.
-        </desc>
-      </param>
-      <param name="affectedMetrics" type="IPerformanceMetric" dir="return" safearray="yes">
-        <desc>
-          Array of metrics that have been modified by the call to this method.
-        </desc>
-      </param>
-    </method>
-
     <method name="queryMetricsData">
       <desc>
         Queries collected metrics data for a set of objects.
 
-        The data itself and related metric information are returned in four
-        parallel and one flattened array of arrays. Elements of @c
-        returnMetricNames, @c returnObjects, @c returnDataIndices and @c
-        returnDataLengths with the same index describe one set of values
-        corresponding to a single metric.
-
-        The @a returnData parameter is a flattened array of arrays. Each start
-        and length of a sub-array is indicated by @a returnDataIndices and @a
-        returnDataLengths. The first value for metric <tt>metricNames[i]</tt> is at
-        <tt> returnData[returnIndices[i]]</tt>.
-
-        <note>
-          @c Null metrics array means all applicable metrics. @c Null object
-          array means all existing objects.
+        The data itself and related metric information are returned in seven
+        parallel and one flattened array of arrays. Elements of 
+        <tt>returnMetricNames, returnObjects, returnUnits, returnScales,
+        returnSequenceNumbers, returnDataIndices and returnDataLengths</tt> with 
+        the same index describe one set of values corresponding to a single 
+        metric.
+
+        The <tt>returnData</tt> parameter is a flattened array of arrays. Each 
+        start and length of a sub-array is indicated by 
+        <tt>returnDataIndices</tt> and <tt>returnDataLengths</tt>. The first 
+        value for metric <tt>metricNames[i]</tt> is at 
+        <tt>returnData[returnIndices[i]]</tt>.
+
+        <note>
+          @c Null or empty metric name array means all metrics. @c Null or empty
+          object array means all existing objects. If metric name array contains 
+          a single element and object array contains many, the single metric 
+          name array element is applied to each object array element to form 
+          metric/object pairs.
         </note>
         <note>
@@ -10762,6 +10698,6 @@
       <param name="metricNames" type="wstring" dir="in" safearray="yes">
         <desc>
-          Metric name filter. Currently, only a comma-separated list of metrics
-          is supported.
+          Metric name filter. Comma-separated list of metrics with wildcard 
+          support.
         </desc>
       </param>
@@ -10781,4 +10717,25 @@
         </desc>
       </param>
+      <param name="returnUnits" type="wstring" dir="out" safearray="yes">
+         <desc>
+           Units of measurement for each returned metric.
+         </desc>
+       </param>
+       <param name="returnScales" type="unsigned long" dir="out" safearray="yes">
+         <desc>
+           Divisor that should be applied to return values in order to get
+           floating point values. For example:
+           <tt>(double)returnData[returnDataIndices[0]+i] / returnScales[0]</tt>
+           will retrieve the floating point value of i-th sample of the first
+           metric.
+         </desc>
+       </param>
+       <param name="returnSequenceNumbers" type="unsigned long" dir="out" safearray="yes">
+         <desc>
+           Sequence numbers of the first elements of value sequences of particular metrics
+           returned in @c returnData. For aggregate metrics it is the sequence number of
+           the sample the aggregate started calculation from.
+         </desc>
+       </param>
       <param name="returnDataIndices" type="unsigned long" dir="out" safearray="yes">
         <desc>
@@ -10799,79 +10756,4 @@
       </param>
     </method>
-
-    <method name="queryMetricsDataEx">
-      <desc>
-        Queries collected metrics data for a set of objects.
-
-        Indentical to <link to="IPerformanceCollector::queryMetricsData" /> except
-        that it returns three additional arrays: <tt>returnUnits</tt>,
-        <tt>returnScales</tt>, <tt>returnSequenceNumbers</tt>. All additional
-        arrays have the same size as <tt>returnMetricNames</tt>.
-        <note>
-          @c Null metrics array means all applicable metrics. @c Null object
-          array means all existing objects.
-        </note>
-      </desc>
-      <param name="metricNames" type="wstring" dir="in" safearray="yes">
-        <desc>
-          Metric name filter. Currently, only a comma-separated list of metrics
-          is supported.
-        </desc>
-      </param>
-      <param name="objects" type="$unknown" dir="in" safearray="yes">
-        <desc>
-          Set of objects to query metrics for.
-        </desc>
-      </param>
-      <param name="returnMetricNames" type="wstring" dir="out" safearray="yes">
-        <desc>
-          Names of metrics returned in @c returnData.
-        </desc>
-      </param>
-      <param name="returnObjects" type="$unknown" dir="out" safearray="yes">
-        <desc>
-          Objects associated with metrics returned in @c returnData.
-        </desc>
-      </param>
-     <param name="returnUnits" type="wstring" dir="out" safearray="yes">
-        <desc>
-          Units of measurement for each returned metric.
-        </desc>
-      </param>
-      <param name="returnScales" type="unsigned long" dir="out" safearray="yes">
-        <desc>
-          Divisor that should be applied to return values in order to get
-          floating point values. For example:
-          <tt>(double)returnData[returnDataIndices[0]+i] / returnScales[0]</tt>
-          will retrieve the floating point value of i-th sample of the first
-          metric.
-        </desc>
-      </param>
-      <param name="returnSequenceNumbers" type="unsigned long" dir="out" safearray="yes">
-        <desc>
-          Sequence numbers of the first elements of value sequences of particular metrics
-          returned in @c returnData. For aggregate metrics it is the sequence number of
-          the sample the aggregate started calculation from.
-        </desc>
-      </param>
-      <param name="returnDataIndices" type="unsigned long" dir="out" safearray="yes">
-        <desc>
-          Indices of the first elements of value sequences of particular metrics
-          returned in @c returnData.
-        </desc>
-      </param>
-      <param name="returnDataLengths" type="unsigned long" dir="out" safearray="yes">
-        <desc>
-          Lengths of value sequences of particular metrics.
-        </desc>
-      </param>
-      <param name="returnData" type="long" dir="return" safearray="yes">
-        <desc>
-          Flattened array of all metric data containing sequences of values for
-          each metric.
-        </desc>
-      </param>
-   </method>
-
 
   </interface>
Index: trunk/src/VBox/Main/include/PerformanceImpl.h
===================================================================
--- trunk/src/VBox/Main/include/PerformanceImpl.h	(revision 13081)
+++ trunk/src/VBox/Main/include/PerformanceImpl.h	(revision 13082)
@@ -148,40 +148,25 @@
     STDMETHOD(SetupMetrics) (ComSafeArrayIn (INPTR BSTR, metricNames),
                              ComSafeArrayIn (IUnknown *, objects),
-                             ULONG aPeriod, ULONG aCount);
+                             ULONG aPeriod, ULONG aCount,
+                             ComSafeArrayOut (IPerformanceMetric *,
+                                              outMetrics));
     STDMETHOD(EnableMetrics) (ComSafeArrayIn (INPTR BSTR, metricNames),
-                              ComSafeArrayIn (IUnknown *, objects));
+                              ComSafeArrayIn (IUnknown *, objects),
+                              ComSafeArrayOut (IPerformanceMetric *,
+                                               outMetrics));
     STDMETHOD(DisableMetrics) (ComSafeArrayIn (INPTR BSTR, metricNames),
-                               ComSafeArrayIn (IUnknown *, objects));
+                               ComSafeArrayIn (IUnknown *, objects),
+                               ComSafeArrayOut (IPerformanceMetric *,
+                                                outMetrics));
     STDMETHOD(QueryMetricsData) (ComSafeArrayIn (INPTR BSTR, metricNames),
                                  ComSafeArrayIn (IUnknown *, objects),
                                  ComSafeArrayOut (BSTR, outMetricNames),
                                  ComSafeArrayOut (IUnknown *, outObjects),
+                                 ComSafeArrayOut (BSTR, outUnits),
+                                 ComSafeArrayOut (ULONG, outScales),
+                                 ComSafeArrayOut (ULONG, outSequenceNumbers),
                                  ComSafeArrayOut (ULONG, outDataIndices),
                                  ComSafeArrayOut (ULONG, outDataLengths),
                                  ComSafeArrayOut (LONG, outData));
-
-    STDMETHOD(SetupMetricsEx) (ComSafeArrayIn (INPTR BSTR, metricNames),
-                               ComSafeArrayIn (IUnknown *, objects),
-                               ULONG aPeriod, ULONG aCount,
-                               ComSafeArrayOut (IPerformanceMetric *,
-                                                outMetrics));
-    STDMETHOD(EnableMetricsEx) (ComSafeArrayIn (INPTR BSTR, metricNames),
-                                ComSafeArrayIn (IUnknown *, objects),
-                                ComSafeArrayOut (IPerformanceMetric *,
-                                                 outMetrics));
-    STDMETHOD(DisableMetricsEx) (ComSafeArrayIn (INPTR BSTR, metricNames),
-                                 ComSafeArrayIn (IUnknown *, objects),
-                                 ComSafeArrayOut (IPerformanceMetric *,
-                                                  outMetrics));
-    STDMETHOD(QueryMetricsDataEx) (ComSafeArrayIn (INPTR BSTR, metricNames),
-                                   ComSafeArrayIn (IUnknown *, objects),
-                                   ComSafeArrayOut (BSTR, outMetricNames),
-                                   ComSafeArrayOut (IUnknown *, outObjects),
-                                   ComSafeArrayOut (BSTR, outUnits),
-                                   ComSafeArrayOut (ULONG, outScales),
-                                   ComSafeArrayOut (ULONG, outSequenceNumbers),
-                                   ComSafeArrayOut (ULONG, outDataIndices),
-                                   ComSafeArrayOut (ULONG, outDataLengths),
-                                   ComSafeArrayOut (LONG, outData));
 
     // public methods only for internal purposes
@@ -203,18 +188,4 @@
     HRESULT toIPerformanceMetric(pm::Metric *src, IPerformanceMetric **dst);
     HRESULT toIPerformanceMetric(pm::BaseMetric *src, IPerformanceMetric **dst);
-    HRESULT SetupMetricsInt(ComSafeArrayIn (INPTR BSTR, metricNames),
-                            ComSafeArrayIn (IUnknown *, objects),
-                            ULONG aPeriod, ULONG aCount, bool reportAffected,
-                            ComSafeArrayOut (IPerformanceMetric *, outMetrics));
-    HRESULT EnableMetricsInt (ComSafeArrayIn (INPTR BSTR, metricNames),
-                              ComSafeArrayIn (IUnknown *, objects),
-                              bool reportAffected,
-                              ComSafeArrayOut (IPerformanceMetric *,
-                                               outMetrics));
-    HRESULT DisableMetricsInt (ComSafeArrayIn (INPTR BSTR, metricNames),
-                               ComSafeArrayIn (IUnknown *, objects),
-                               bool reportAffected,
-                               ComSafeArrayOut (IPerformanceMetric *,
-                                                outMetrics));
                             
     static void staticSamplerCallback (RTTIMERLR hTimerLR, void *pvUser, uint64_t iTick);
Index: trunk/src/VBox/Main/testcase/tstAPI.cpp
===================================================================
--- trunk/src/VBox/Main/testcase/tstAPI.cpp	(revision 13081)
+++ trunk/src/VBox/Main/testcase/tstAPI.cpp	(revision 13082)
@@ -970,9 +970,14 @@
         // Setup base metrics
         // Note that one needs to set up metrics after a session is open for a machine.
+        com::SafeIfaceArray<IPerformanceMetric> affectedMetrics;
         com::SafeIfaceArray<IUnknown> objects(2);
         host.queryInterfaceTo(&objects[0]);
         machine.queryInterfaceTo(&objects[1]);
         CHECK_ERROR_BREAK (collector, SetupMetrics(ComSafeArrayAsInParam(baseMetrics),
-                                                   ComSafeArrayAsInParam(objects), 1u, 10u) );
+                                                   ComSafeArrayAsInParam(objects), 1u, 10u,
+                                                   ComSafeArrayAsOutParam(affectedMetrics)) );
+        listAffectedMetrics(virtualBox,
+                            ComSafeArrayAsInParam(affectedMetrics));
+        affectedMetrics.setNull();
 
         // Get console
@@ -996,10 +1001,9 @@
         queryMetrics(virtualBox, collector, ComSafeArrayAsInParam(objects));
 
-        com::SafeIfaceArray<IPerformanceMetric> affectedMetrics;
         printf("\nDrop collected metrics: ----------------------------------------\n");
         CHECK_ERROR_BREAK (collector,
-            SetupMetricsEx(ComSafeArrayAsInParam(baseMetrics),
-                           ComSafeArrayAsInParam(objects),
-                           1u, 5u, ComSafeArrayAsOutParam(affectedMetrics)) );
+            SetupMetrics(ComSafeArrayAsInParam(baseMetrics),
+                         ComSafeArrayAsInParam(objects),
+                         1u, 5u, ComSafeArrayAsOutParam(affectedMetrics)) );
         listAffectedMetrics(virtualBox,
                             ComSafeArrayAsInParam(affectedMetrics));
@@ -1012,7 +1016,7 @@
         printf("\nDisable collection of VM metrics: ------------------------------\n");
         CHECK_ERROR_BREAK (collector,
-            DisableMetricsEx(ComSafeArrayAsInParam(baseMetrics),
-                             ComSafeArrayAsInParam(vmObject),
-                             ComSafeArrayAsOutParam(affectedMetrics)) );
+            DisableMetrics(ComSafeArrayAsInParam(baseMetrics),
+                           ComSafeArrayAsInParam(vmObject),
+                           ComSafeArrayAsOutParam(affectedMetrics)) );
         listAffectedMetrics(virtualBox,
                             ComSafeArrayAsInParam(affectedMetrics));
@@ -1023,7 +1027,7 @@
         printf("\nRe-enable collection of all metrics: ---------------------------\n");
         CHECK_ERROR_BREAK (collector,
-            EnableMetricsEx(ComSafeArrayAsInParam(baseMetrics),
-                            ComSafeArrayAsInParam(objects),
-                            ComSafeArrayAsOutParam(affectedMetrics)) );
+            EnableMetrics(ComSafeArrayAsInParam(baseMetrics),
+                          ComSafeArrayAsInParam(objects),
+                          ComSafeArrayAsOutParam(affectedMetrics)) );
         listAffectedMetrics(virtualBox,
                             ComSafeArrayAsInParam(affectedMetrics));
@@ -1073,4 +1077,7 @@
     com::SafeArray<BSTR>          retNames;
     com::SafeIfaceArray<IUnknown> retObjects;
+    com::SafeArray<BSTR>          retUnits;
+    com::SafeArray<ULONG>         retScales;
+    com::SafeArray<ULONG>         retSequenceNumbers;
     com::SafeArray<ULONG>         retIndices;
     com::SafeArray<ULONG>         retLengths;
@@ -1080,4 +1087,7 @@
                                              ComSafeArrayAsOutParam(retNames),
                                              ComSafeArrayAsOutParam(retObjects),
+                                             ComSafeArrayAsOutParam(retUnits),
+                                             ComSafeArrayAsOutParam(retScales),
+                                             ComSafeArrayAsOutParam(retSequenceNumbers),
                                              ComSafeArrayAsOutParam(retIndices),
                                              ComSafeArrayAsOutParam(retLengths),
@@ -1087,30 +1097,15 @@
     for (unsigned i = 0; i < retNames.size(); i++)
     {
-        // Get info for the metric
-        com::SafeArray<BSTR> nameOfMetric(1);
-        Bstr tmpName(retNames[i]);
-        tmpName.detachTo (&nameOfMetric[0]);
-        com::SafeIfaceArray<IUnknown> anObject(1);
-        ComPtr<IUnknown> tmpObject(retObjects[i]);
-        tmpObject.queryInterfaceTo(&anObject[0]);
-        com::SafeIfaceArray <IPerformanceMetric> metricInfo;
-        CHECK_RC_BREAK (collector->GetMetrics( ComSafeArrayAsInParam(nameOfMetric),
-                                               ComSafeArrayAsInParam(anObject),
-                                               ComSafeArrayAsOutParam(metricInfo) ));
-        BSTR metricUnitBSTR;
-        CHECK_RC_BREAK (metricInfo[0]->COMGETTER(Unit) (&metricUnitBSTR));
-        Bstr metricUnit(metricUnitBSTR);
+        Bstr metricUnit(retUnits[i]);
         Bstr metricName(retNames[i]);
-        LONG minVal, maxVal;
-        CHECK_RC_BREAK (metricInfo[0]->COMGETTER(MinimumValue) (&minVal));
-        CHECK_RC_BREAK (metricInfo[0]->COMGETTER(MaximumValue) (&maxVal));
-        RTPrintf("%-10ls %-20ls ", getObjectName(aVirtualBox, anObject[0]).raw(), metricName.raw());
+        RTPrintf("%-10ls %-20ls ", getObjectName(aVirtualBox, retObjects[i]).raw(), metricName.raw());
         const char *separator = "";
         for (unsigned j = 0; j < retLengths[i]; j++)
         {
-            if (strcmp((const char *)metricUnit.raw(), "%"))
+            if (retScales[i] == 1)
                 RTPrintf("%s%d %ls", separator, retData[retIndices[i] + j], metricUnit.raw());
             else
-                RTPrintf("%s%d.%02d%%", separator, retData[retIndices[i] + j] / 1000, (retData[retIndices[i] + j] / 10) % 100);
+                RTPrintf("%s%d.%02d%ls", separator, retData[retIndices[i] + j] / retScales[i],
+                         (retData[retIndices[i] + j] * 100 / retScales[i]) % 100, metricUnit.raw());
             separator = ", ";
         }
Index: trunk/src/libs/xpcom18a4/python/sample/shellcommon.py
===================================================================
--- trunk/src/libs/xpcom18a4/python/sample/shellcommon.py	(revision 13081)
+++ trunk/src/libs/xpcom18a4/python/sample/shellcommon.py	(revision 13082)
@@ -23,10 +23,4 @@
         self.collector = vb.performanceCollector 
 
-    def _update_metric_params(self):
-        metrics = self.collector.getMetrics(['*'], None)
-        self.metrics = {}
-        for m in metrics:
-            self.metrics[str(m.object) + "/" + str(m.metricName)] = m
-
     def setup(self, names, objects, period, nsamples):
         """ Discards all previously collected values for the specified
@@ -35,5 +29,4 @@
         """
         self.collector.setupMetrics(names, objects, period, nsamples)
-        self._update_metric_params()
 
     def enable(self, names, objects):
@@ -58,22 +51,20 @@
         'values_as_string': pre-processed values ready for 'print' statement
         """
-        (values, names_out, objects_out, indices, lengths) = self.collector.queryMetricsData(names, objects)
+        (values, names_out, objects_out, units, scales, sequence_numbers,
+            indices, lengths) = self.collector.queryMetricsData(names, objects)
         out = []
         for i in xrange(0, len(names_out)):
-            metric = self.metrics[str(objects_out[i]) + "/" + str(names_out[i])]
-            unit = str(metric.getUnit())
-            if unit == '%':
-                scale = 1000.
+            scale = int(scales[i])
+            if scale != 1:
                 fmt = '%.2f%s'
             else:
-                scale = 1
                 fmt = '%d %s'
             out.append({
                 'name':str(names_out[i]),
                 'object':str(objects_out[i]),
-                'unit':str(metric.getUnit()),
+                'unit':str(units[i]),
                 'scale':scale,
                 'values':[int(values[j]) for j in xrange(int(indices[i]), int(indices[i])+int(lengths[i]))],
-                'values_as_string':'['+', '.join([fmt % (int(values[j])/scale, unit) for j in xrange(int(indices[i]), int(indices[i])+int(lengths[i]))])+']'
+                'values_as_string':'['+', '.join([fmt % (int(values[j])/scale, units[i]) for j in xrange(int(indices[i]), int(indices[i])+int(lengths[i]))])+']'
             })
         return out
