- Timestamp:
- Oct 8, 2008 2:36:19 PM (16 years ago)
- svn:sync-xref-src-repo-rev:
- 37570
- Location:
- trunk/src
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VBoxManage/VBoxManage.cpp
r12668 r13082 7768 7768 } 7769 7769 7770 static int countMatchingMetrics(ComPtr<IVirtualBox> aVirtualBox,7771 ComPtr<IPerformanceCollector> performanceCollector,7772 ComSafeArrayIn(INPTR BSTR, metrics),7773 ComSafeArrayIn(IUnknown *, objects),7774 bool listMatches)7775 {7776 HRESULT rc;7777 com::SafeIfaceArray<IPerformanceMetric> metricInfo;7778 7779 CHECK_ERROR(performanceCollector,7780 GetMetrics(ComSafeArrayInArg(metrics),7781 ComSafeArrayInArg(objects),7782 ComSafeArrayAsOutParam(metricInfo)));7783 7784 if (metricInfo.size())7785 {7786 if (listMatches)7787 {7788 ComPtr<IUnknown> object;7789 Bstr metricName;7790 RTPrintf("The following metrics will be collected:\n\n"7791 "Object Metric\n"7792 "---------- --------------------\n");7793 for (size_t i = 0; i < metricInfo.size(); i++)7794 {7795 CHECK_ERROR(metricInfo[i], COMGETTER(Object)(object.asOutParam()));7796 CHECK_ERROR(metricInfo[i], COMGETTER(MetricName)(metricName.asOutParam()));7797 RTPrintf("%-10ls %-20ls\n",7798 getObjectName(aVirtualBox, object).raw(), metricName.raw());7799 }7800 RTPrintf("\n");7801 }7802 }7803 else7804 {7805 RTPrintf("No metrics match the specified filter!\n");7806 }7807 return metricInfo.size();7808 }7809 7810 7770 static void listAffectedMetrics(ComPtr<IVirtualBox> aVirtualBox, 7811 7771 ComSafeArrayIn(IPerformanceMetric*, aMetrics)) … … 7934 7894 return 1; 7935 7895 7896 com::SafeIfaceArray<IPerformanceMetric> affectedMetrics; 7897 CHECK_ERROR(performanceCollector, 7898 SetupMetrics(ComSafeArrayAsInParam(metrics), 7899 ComSafeArrayAsInParam(objects), period, samples, 7900 ComSafeArrayAsOutParam(affectedMetrics))); 7936 7901 if (listMatches) 7937 {7938 com::SafeIfaceArray<IPerformanceMetric> affectedMetrics;7939 CHECK_ERROR(performanceCollector,7940 SetupMetricsEx(ComSafeArrayAsInParam(metrics),7941 ComSafeArrayAsInParam(objects), period, samples,7942 ComSafeArrayAsOutParam(affectedMetrics)));7943 7902 listAffectedMetrics(aVirtualBox, 7944 7903 ComSafeArrayAsInParam(affectedMetrics)); 7945 }7946 else7947 {7948 CHECK_ERROR(performanceCollector,7949 SetupMetrics(ComSafeArrayAsInParam(metrics),7950 ComSafeArrayAsInParam(objects), period, samples));7951 }7952 7904 7953 7905 return 0; … … 7975 7927 com::SafeArray<BSTR> retNames; 7976 7928 com::SafeIfaceArray<IUnknown> retObjects; 7929 com::SafeArray<BSTR> retUnits; 7930 com::SafeArray<ULONG> retScales; 7931 com::SafeArray<ULONG> retSequenceNumbers; 7977 7932 com::SafeArray<ULONG> retIndices; 7978 7933 com::SafeArray<ULONG> retLengths; … … 7982 7937 ComSafeArrayAsOutParam(retNames), 7983 7938 ComSafeArrayAsOutParam(retObjects), 7939 ComSafeArrayAsOutParam(retUnits), 7940 ComSafeArrayAsOutParam(retScales), 7941 ComSafeArrayAsOutParam(retSequenceNumbers), 7984 7942 ComSafeArrayAsOutParam(retIndices), 7985 7943 ComSafeArrayAsOutParam(retLengths), … … 7990 7948 for (unsigned i = 0; i < retNames.size(); i++) 7991 7949 { 7992 // Get info for the metric 7993 com::SafeArray<BSTR> nameOfMetric(1); 7994 Bstr tmpName(retNames[i]); 7995 tmpName.detachTo (&nameOfMetric[0]); 7996 com::SafeIfaceArray<IUnknown> anObject(1); 7997 ComPtr<IUnknown> tmpObject(retObjects[i]); 7998 tmpObject.queryInterfaceTo(&anObject[0]); 7999 com::SafeIfaceArray <IPerformanceMetric> metricInfo; 8000 CHECK_RC_BREAK (performanceCollector->GetMetrics( ComSafeArrayAsInParam(nameOfMetric), 8001 ComSafeArrayAsInParam(anObject), 8002 ComSafeArrayAsOutParam(metricInfo) )); 8003 BSTR metricUnitBSTR; 8004 CHECK_RC_BREAK (metricInfo[0]->COMGETTER(Unit) (&metricUnitBSTR)); 8005 Bstr metricUnit(metricUnitBSTR); 7950 Bstr metricUnit(retUnits[i]); 8006 7951 Bstr metricName(retNames[i]); 8007 LONG minVal, maxVal;8008 CHECK_RC_BREAK (metricInfo[0]->COMGETTER(MinimumValue) (&minVal));8009 CHECK_RC_BREAK (metricInfo[0]->COMGETTER(MaximumValue) (&maxVal));8010 7952 RTPrintf("%-10ls %-20ls ", getObjectName(aVirtualBox, retObjects[i]).raw(), metricName.raw()); 8011 7953 const char *separator = ""; 8012 7954 for (unsigned j = 0; j < retLengths[i]; j++) 8013 7955 { 8014 if ( strcmp((const char *)metricUnit.raw(), "%"))7956 if (retScales[i] == 1) 8015 7957 RTPrintf("%s%d %ls", separator, retData[retIndices[i] + j], metricUnit.raw()); 8016 7958 else 8017 RTPrintf("%s%d.%02d%%", separator, retData[retIndices[i] + j] / 1000, (retData[retIndices[i] + j] / 10) % 100); 7959 RTPrintf("%s%d.%02d%ls", separator, retData[retIndices[i] + j] / retScales[i], 7960 (retData[retIndices[i] + j] * 100 / retScales[i]) % 100, metricUnit.raw()); 8018 7961 separator = ", "; 8019 7962 } … … 8121 8064 8122 8065 8123 if (countMatchingMetrics(aVirtualBox, performanceCollector, 8124 ComSafeArrayAsInParam(metrics), 8125 ComSafeArrayAsInParam(objects), 8126 listMatches) == 0) 8127 return 1; 8128 8066 com::SafeIfaceArray<IPerformanceMetric> affectedMetrics; 8129 8067 CHECK_ERROR(performanceCollector, 8130 8068 SetupMetrics(ComSafeArrayAsInParam(baseMetrics), 8131 ComSafeArrayAsInParam(objects), period, samples)); 8069 ComSafeArrayAsInParam(objects), period, samples, 8070 ComSafeArrayAsOutParam(affectedMetrics))); 8071 if (listMatches) 8072 listAffectedMetrics(aVirtualBox, 8073 ComSafeArrayAsInParam(affectedMetrics)); 8074 if (!affectedMetrics.size()) 8075 return 1; 8132 8076 8133 8077 if (isDetached) … … 8153 8097 com::SafeArray<BSTR> retNames; 8154 8098 com::SafeIfaceArray<IUnknown> retObjects; 8099 com::SafeArray<BSTR> retUnits; 8100 com::SafeArray<ULONG> retScales; 8101 com::SafeArray<ULONG> retSequenceNumbers; 8155 8102 com::SafeArray<ULONG> retIndices; 8156 8103 com::SafeArray<ULONG> retLengths; … … 8160 8107 ComSafeArrayAsOutParam(retNames), 8161 8108 ComSafeArrayAsOutParam(retObjects), 8109 ComSafeArrayAsOutParam(retUnits), 8110 ComSafeArrayAsOutParam(retScales), 8111 ComSafeArrayAsOutParam(retSequenceNumbers), 8162 8112 ComSafeArrayAsOutParam(retIndices), 8163 8113 ComSafeArrayAsOutParam(retLengths), … … 8165 8115 for (unsigned i = 0; i < retNames.size(); i++) 8166 8116 { 8167 8168 // Get info for the metric 8169 com::SafeArray<BSTR> nameOfMetric(1); 8170 Bstr tmpName(retNames[i]); 8171 tmpName.detachTo (&nameOfMetric[0]); 8172 com::SafeIfaceArray<IUnknown> anObject(1); 8173 ComPtr<IUnknown> tmpObject(retObjects[i]); 8174 tmpObject.queryInterfaceTo(&anObject[0]); 8175 com::SafeIfaceArray <IPerformanceMetric> metricInfo; 8176 CHECK_RC_BREAK (performanceCollector->GetMetrics( ComSafeArrayAsInParam(nameOfMetric), 8177 ComSafeArrayAsInParam(anObject), 8178 ComSafeArrayAsOutParam(metricInfo) )); 8179 BSTR metricUnitBSTR; 8180 CHECK_RC_BREAK (metricInfo[0]->COMGETTER(Unit) (&metricUnitBSTR)); 8181 Bstr metricUnit(metricUnitBSTR); 8117 Bstr metricUnit(retUnits[i]); 8182 8118 Bstr metricName(retNames[i]); 8183 LONG minVal, maxVal;8184 CHECK_RC_BREAK (metricInfo[0]->COMGETTER(MinimumValue) (&minVal));8185 CHECK_RC_BREAK (metricInfo[0]->COMGETTER(MaximumValue) (&maxVal));8186 8119 RTPrintf("%-12s %-10ls %-20ls ", ts, getObjectName(aVirtualBox, retObjects[i]).raw(), metricName.raw()); 8187 8120 const char *separator = ""; 8188 8121 for (unsigned j = 0; j < retLengths[i]; j++) 8189 8122 { 8190 if ( strcmp((const char *)metricUnit.raw(), "%"))8123 if (retScales[i] == 1) 8191 8124 RTPrintf("%s%d %ls", separator, retData[retIndices[i] + j], metricUnit.raw()); 8192 8125 else 8193 RTPrintf("%s%d.%02d%%", separator, retData[retIndices[i] + j] / 1000, retData[retIndices[i] + j] % 100); 8126 RTPrintf("%s%d.%02d%ls", separator, retData[retIndices[i] + j] / retScales[i], 8127 (retData[retIndices[i] + j] * 100 / retScales[i]) % 100, metricUnit.raw()); 8194 8128 separator = ", "; 8195 8129 } -
trunk/src/VBox/Main/PerformanceImpl.cpp
r12973 r13082 259 259 PerformanceCollector::SetupMetrics (ComSafeArrayIn (INPTR BSTR, metricNames), 260 260 ComSafeArrayIn (IUnknown *, objects), 261 ULONG aPeriod, ULONG aCount) 262 { 263 LogFlowThisFuncEnter(); 264 com::SafeIfaceArray <IPerformanceMetric> tmp; 265 return SetupMetricsInt(ComSafeArrayInArg(metricNames), 266 ComSafeArrayInArg(objects), 267 aPeriod, aCount, 268 false, ComSafeArrayAsOutParam(tmp)); 269 } 270 271 STDMETHODIMP 272 PerformanceCollector::SetupMetricsEx (ComSafeArrayIn (INPTR BSTR, metricNames), 273 ComSafeArrayIn (IUnknown *, objects), 274 ULONG aPeriod, ULONG aCount, 275 ComSafeArrayOut (IPerformanceMetric *, 276 outMetrics)) 277 { 278 LogFlowThisFuncEnter(); 279 return SetupMetricsInt(ComSafeArrayInArg(metricNames), 280 ComSafeArrayInArg(objects), 281 aPeriod, aCount, 282 true, ComSafeArrayOutArg(outMetrics)); 283 } 284 285 HRESULT 286 PerformanceCollector::SetupMetricsInt (ComSafeArrayIn (INPTR BSTR, metricNames), 287 ComSafeArrayIn (IUnknown *, objects), 288 ULONG aPeriod, ULONG aCount, 289 bool reportAffected, 290 ComSafeArrayOut (IPerformanceMetric *, 291 outMetrics)) 261 ULONG aPeriod, ULONG aCount, 262 ComSafeArrayOut (IPerformanceMetric *, 263 outMetrics)) 292 264 { 293 265 AutoCaller autoCaller (this); … … 320 292 (*it)->enable(); 321 293 } 322 if (reportAffected) 323 filteredMetrics.push_back(*it); 294 filteredMetrics.push_back(*it); 324 295 } 325 296 326 if (reportAffected) 327 { 328 com::SafeIfaceArray<IPerformanceMetric> retMetrics (filteredMetrics.size()); 329 int i = 0; 330 for (it = filteredMetrics.begin(); 331 it != filteredMetrics.end() && SUCCEEDED (rc); ++it) 332 rc = toIPerformanceMetric(*it, &retMetrics [i++]); 333 retMetrics.detachTo (ComSafeArrayOutArg(outMetrics)); 334 } 297 com::SafeIfaceArray<IPerformanceMetric> retMetrics (filteredMetrics.size()); 298 int i = 0; 299 for (it = filteredMetrics.begin(); 300 it != filteredMetrics.end() && SUCCEEDED (rc); ++it) 301 rc = toIPerformanceMetric(*it, &retMetrics [i++]); 302 retMetrics.detachTo (ComSafeArrayOutArg(outMetrics)); 303 335 304 LogFlowThisFuncLeave(); 336 305 return rc; … … 339 308 STDMETHODIMP 340 309 PerformanceCollector::EnableMetrics (ComSafeArrayIn (INPTR BSTR, metricNames), 341 ComSafeArrayIn (IUnknown *, objects)) 342 { 343 LogFlowThisFuncEnter(); 344 com::SafeIfaceArray <IPerformanceMetric> tmp; 345 return EnableMetricsInt (ComSafeArrayInArg(metricNames), 346 ComSafeArrayInArg(objects), 347 false, ComSafeArrayAsOutParam(tmp)); 348 } 349 350 STDMETHODIMP 351 PerformanceCollector::EnableMetricsEx (ComSafeArrayIn (INPTR BSTR, metricNames), 352 ComSafeArrayIn (IUnknown *, objects), 353 ComSafeArrayOut (IPerformanceMetric *, 354 outMetrics)) 355 { 356 LogFlowThisFuncEnter(); 357 return EnableMetricsInt (ComSafeArrayInArg(metricNames), 358 ComSafeArrayInArg(objects), 359 true, ComSafeArrayOutArg(outMetrics)); 360 } 361 362 HRESULT 363 PerformanceCollector::EnableMetricsInt (ComSafeArrayIn (INPTR BSTR, metricNames), 364 ComSafeArrayIn (IUnknown *, objects), 365 bool reportAffected, 366 ComSafeArrayOut (IPerformanceMetric *, 367 outMetrics)) 310 ComSafeArrayIn (IUnknown *, objects), 311 ComSafeArrayOut (IPerformanceMetric *, 312 outMetrics)) 368 313 { 369 314 AutoCaller autoCaller (this); … … 384 329 { 385 330 (*it)->enable(); 386 if (reportAffected) 387 filteredMetrics.push_back(*it); 331 filteredMetrics.push_back(*it); 388 332 } 389 333 390 if (reportAffected) 391 { 392 com::SafeIfaceArray<IPerformanceMetric> retMetrics (filteredMetrics.size()); 393 int i = 0; 394 for (it = filteredMetrics.begin(); 395 it != filteredMetrics.end() && SUCCEEDED (rc); ++it) 396 rc = toIPerformanceMetric(*it, &retMetrics [i++]); 397 retMetrics.detachTo (ComSafeArrayOutArg(outMetrics)); 398 } 334 com::SafeIfaceArray<IPerformanceMetric> retMetrics (filteredMetrics.size()); 335 int i = 0; 336 for (it = filteredMetrics.begin(); 337 it != filteredMetrics.end() && SUCCEEDED (rc); ++it) 338 rc = toIPerformanceMetric(*it, &retMetrics [i++]); 339 retMetrics.detachTo (ComSafeArrayOutArg(outMetrics)); 340 399 341 LogFlowThisFuncLeave(); 400 342 return rc; … … 403 345 STDMETHODIMP 404 346 PerformanceCollector::DisableMetrics (ComSafeArrayIn (INPTR BSTR, metricNames), 405 ComSafeArrayIn (IUnknown *, objects))406 {407 LogFlowThisFuncEnter();408 com::SafeIfaceArray <IPerformanceMetric> tmp;409 return DisableMetricsInt (ComSafeArrayInArg(metricNames),410 ComSafeArrayInArg(objects),411 false, ComSafeArrayAsOutParam(tmp));412 }413 414 STDMETHODIMP415 PerformanceCollector::DisableMetricsEx (ComSafeArrayIn (INPTR BSTR, metricNames),416 347 ComSafeArrayIn (IUnknown *, objects), 417 348 ComSafeArrayOut (IPerformanceMetric *, 418 349 outMetrics)) 419 {420 LogFlowThisFuncEnter();421 return DisableMetricsInt (ComSafeArrayInArg(metricNames),422 ComSafeArrayInArg(objects),423 true, ComSafeArrayOutArg(outMetrics));424 }425 426 HRESULT427 PerformanceCollector::DisableMetricsInt (ComSafeArrayIn (INPTR BSTR, metricNames),428 ComSafeArrayIn (IUnknown *, objects),429 bool reportAffected,430 ComSafeArrayOut (IPerformanceMetric *,431 outMetrics))432 350 { 433 351 AutoCaller autoCaller (this); … … 448 366 { 449 367 (*it)->disable(); 450 if (reportAffected) 451 filteredMetrics.push_back(*it); 368 filteredMetrics.push_back(*it); 452 369 } 453 370 454 if (reportAffected) 455 { 456 com::SafeIfaceArray<IPerformanceMetric> retMetrics (filteredMetrics.size()); 457 int i = 0; 458 for (it = filteredMetrics.begin(); 459 it != filteredMetrics.end() && SUCCEEDED (rc); ++it) 460 rc = toIPerformanceMetric(*it, &retMetrics [i++]); 461 retMetrics.detachTo (ComSafeArrayOutArg(outMetrics)); 462 } 371 com::SafeIfaceArray<IPerformanceMetric> retMetrics (filteredMetrics.size()); 372 int i = 0; 373 for (it = filteredMetrics.begin(); 374 it != filteredMetrics.end() && SUCCEEDED (rc); ++it) 375 rc = toIPerformanceMetric(*it, &retMetrics [i++]); 376 retMetrics.detachTo (ComSafeArrayOutArg(outMetrics)); 377 463 378 LogFlowThisFuncLeave(); 464 379 return rc; … … 470 385 ComSafeArrayOut (BSTR, outMetricNames), 471 386 ComSafeArrayOut (IUnknown *, outObjects), 387 ComSafeArrayOut (BSTR, outUnits), 388 ComSafeArrayOut (ULONG, outScales), 389 ComSafeArrayOut (ULONG, outSequenceNumbers), 472 390 ComSafeArrayOut (ULONG, outDataIndices), 473 391 ComSafeArrayOut (ULONG, outDataLengths), 474 392 ComSafeArrayOut (LONG, outData)) 475 {476 com::SafeArray <BSTR> tmpUnits;477 com::SafeArray <ULONG> tmpScales;478 com::SafeArray <ULONG> tmpSequenceNumbers;479 return QueryMetricsDataEx(ComSafeArrayInArg(metricNames),480 ComSafeArrayInArg(objects),481 ComSafeArrayOutArg(outMetricNames),482 ComSafeArrayOutArg(outObjects),483 ComSafeArrayAsOutParam(tmpUnits),484 ComSafeArrayAsOutParam(tmpScales),485 ComSafeArrayAsOutParam(tmpSequenceNumbers),486 ComSafeArrayOutArg(outDataIndices),487 ComSafeArrayOutArg(outDataLengths),488 ComSafeArrayOutArg(outData));489 }490 491 STDMETHODIMP492 PerformanceCollector::QueryMetricsDataEx (ComSafeArrayIn (INPTR BSTR, metricNames),493 ComSafeArrayIn (IUnknown *, objects),494 ComSafeArrayOut (BSTR, outMetricNames),495 ComSafeArrayOut (IUnknown *, outObjects),496 ComSafeArrayOut (BSTR, outUnits),497 ComSafeArrayOut (ULONG, outScales),498 ComSafeArrayOut (ULONG, outSequenceNumbers),499 ComSafeArrayOut (ULONG, outDataIndices),500 ComSafeArrayOut (ULONG, outDataLengths),501 ComSafeArrayOut (LONG, outData))502 393 { 503 394 AutoCaller autoCaller (this); -
trunk/src/VBox/Main/idl/VirtualBox.xidl
r13079 r13082 10557 10557 <method name="setupMetrics"> 10558 10558 <desc> 10559 Sets parameters of specified base metrics for a set of objects. 10560 <note> 10561 @c Null metrics array means all metrics. @c Null object array means 10562 all existing objects. 10559 Sets parameters of specified base metrics for a set of objects. Returns 10560 an array of <link to="IPerformanceMetric" /> describing the metrics have 10561 been affected. 10562 <note> 10563 @c Null or empty metric name array means all metrics. @c Null or empty 10564 object array means all existing objects. If metric name array contains 10565 a single element and object array contains many, the single metric 10566 name array element is applied to each object array element to form 10567 metric/object pairs. 10563 10568 </note> 10564 10569 </desc> 10565 10570 <param name="metricNames" type="wstring" dir="in" safearray="yes"> 10566 10571 <desc> 10567 Metric name filter. C urrently, only a comma-separated list of metrics10568 is supported.10572 Metric name filter. Comma-separated list of metrics with wildcard 10573 support. 10569 10574 </desc> 10570 10575 </param> … … 10586 10591 </desc> 10587 10592 </param> 10593 <param name="affectedMetrics" type="IPerformanceMetric" dir="return" safearray="yes"> 10594 <desc> 10595 Array of metrics that have been modified by the call to this method. 10596 </desc> 10597 </param> 10588 10598 </method> 10589 10599 10590 10600 <method name="enableMetrics"> 10591 10601 <desc> 10592 Turns on collecting specified base metrics. 10593 <note> 10594 @c Null metrics array means all metrics. @c Null object array means 10595 all existing objects. 10602 Turns on collecting specified base metrics. Returns an array of 10603 <link to="IPerformanceMetric" /> describing the metrics have been 10604 affected. 10605 <note> 10606 @c Null or empty metric name array means all metrics. @c Null or empty 10607 object array means all existing objects. If metric name array contains 10608 a single element and object array contains many, the single metric 10609 name array element is applied to each object array element to form 10610 metric/object pairs. 10596 10611 </note> 10597 10612 </desc> 10598 10613 <param name="metricNames" type="wstring" dir="in" safearray="yes"> 10599 10614 <desc> 10600 Metric name filter. C urrently, only a comma-separated list of metrics10601 is supported.10615 Metric name filter. Comma-separated list of metrics with wildcard 10616 support. 10602 10617 </desc> 10603 10618 </param> … … 10607 10622 </desc> 10608 10623 </param> 10624 <param name="affectedMetrics" type="IPerformanceMetric" dir="return" safearray="yes"> 10625 <desc> 10626 Array of metrics that have been modified by the call to this method. 10627 </desc> 10628 </param> 10609 10629 </method> 10610 10630 10611 10631 <method name="disableMetrics"> 10612 10632 <desc> 10613 Turns off collecting specified base metrics. 10614 <note> 10615 @c Null metrics array means all metrics. @c Null object array means 10616 all existing objects. 10633 Turns off collecting specified base metrics. Returns an array of 10634 <link to="IPerformanceMetric" /> describing the metrics have been 10635 affected. 10636 <note> 10637 @c Null or empty metric name array means all metrics. @c Null or empty 10638 object array means all existing objects. If metric name array contains 10639 a single element and object array contains many, the single metric 10640 name array element is applied to each object array element to form 10641 metric/object pairs. 10617 10642 </note> 10618 10643 </desc> 10619 10644 <param name="metricNames" type="wstring" dir="in" safearray="yes"> 10620 10645 <desc> 10621 Metric name filter. C urrently, only a comma-separated list of metrics10622 is supported.10646 Metric name filter. Comma-separated list of metrics with wildcard 10647 support. 10623 10648 </desc> 10624 10649 </param> … … 10628 10653 </desc> 10629 10654 </param> 10630 </method>10631 10632 <method name="setupMetricsEx">10633 <desc>10634 Sets parameters of specified base metrics for a set of objects.10635 Indentical to <link to="IPerformanceCollector::setupMetrics" /> except10636 that it returns an array of <link to="IPerformanceMetric" /> describing10637 the metrics have been affected.10638 <note>10639 @c Null metrics array means all metrics. @c Null object array means10640 all existing objects.10641 </note>10642 </desc>10643 <param name="metricNames" type="wstring" dir="in" safearray="yes">10644 <desc>10645 Metric name filter. Currently, only a comma-separated list of metrics10646 is supported.10647 </desc>10648 </param>10649 <param name="objects" type="$unknown" dir="in" safearray="yes">10650 <desc>10651 Set of objects to setup metric parameters for.10652 </desc>10653 </param>10654 <param name="period" type="unsigned long" dir="in">10655 <desc>10656 Time interval in seconds between two consecutive samples of performace10657 data.10658 </desc>10659 </param>10660 <param name="count" type="unsigned long" dir="in">10661 <desc>10662 Number of samples to retain in performance data history. Older samples10663 get discarded.10664 </desc>10665 </param>10666 10655 <param name="affectedMetrics" type="IPerformanceMetric" dir="return" safearray="yes"> 10667 10656 <desc> … … 10671 10660 </method> 10672 10661 10673 <method name="enableMetricsEx">10674 <desc>10675 Turns on collecting specified base metrics.10676 Indentical to <link to="IPerformanceCollector::enableMetrics" /> except10677 that it returns an array of <link to="IPerformanceMetric" /> describing10678 the metrics have been affected.10679 <note>10680 @c Null metrics array means all metrics. @c Null object array means10681 all existing objects.10682 </note>10683 </desc>10684 <param name="metricNames" type="wstring" dir="in" safearray="yes">10685 <desc>10686 Metric name filter. Currently, only a comma-separated list of metrics10687 is supported.10688 </desc>10689 </param>10690 <param name="objects" type="$unknown" dir="in" safearray="yes">10691 <desc>10692 Set of objects to enable metrics for.10693 </desc>10694 </param>10695 <param name="affectedMetrics" type="IPerformanceMetric" dir="return" safearray="yes">10696 <desc>10697 Array of metrics that have been modified by the call to this method.10698 </desc>10699 </param>10700 </method>10701 10702 <method name="disableMetricsEx">10703 <desc>10704 Turns off collecting specified base metrics.10705 Indentical to <link to="IPerformanceCollector::disableMetrics" /> except10706 that it returns an array of <link to="IPerformanceMetric" /> describing10707 the metrics have been affected.10708 <note>10709 @c Null metrics array means all metrics. @c Null object array means10710 all existing objects.10711 </note>10712 </desc>10713 <param name="metricNames" type="wstring" dir="in" safearray="yes">10714 <desc>10715 Metric name filter. Currently, only a comma-separated list of metrics10716 is supported.10717 </desc>10718 </param>10719 <param name="objects" type="$unknown" dir="in" safearray="yes">10720 <desc>10721 Set of objects to disable metrics for.10722 </desc>10723 </param>10724 <param name="affectedMetrics" type="IPerformanceMetric" dir="return" safearray="yes">10725 <desc>10726 Array of metrics that have been modified by the call to this method.10727 </desc>10728 </param>10729 </method>10730 10731 10662 <method name="queryMetricsData"> 10732 10663 <desc> 10733 10664 Queries collected metrics data for a set of objects. 10734 10665 10735 The data itself and related metric information are returned in four 10736 parallel and one flattened array of arrays. Elements of @c 10737 returnMetricNames, @c returnObjects, @c returnDataIndices and @c 10738 returnDataLengths with the same index describe one set of values 10739 corresponding to a single metric. 10740 10741 The @a returnData parameter is a flattened array of arrays. Each start 10742 and length of a sub-array is indicated by @a returnDataIndices and @a 10743 returnDataLengths. The first value for metric <tt>metricNames[i]</tt> is at 10744 <tt> returnData[returnIndices[i]]</tt>. 10745 10746 <note> 10747 @c Null metrics array means all applicable metrics. @c Null object 10748 array means all existing objects. 10666 The data itself and related metric information are returned in seven 10667 parallel and one flattened array of arrays. Elements of 10668 <tt>returnMetricNames, returnObjects, returnUnits, returnScales, 10669 returnSequenceNumbers, returnDataIndices and returnDataLengths</tt> with 10670 the same index describe one set of values corresponding to a single 10671 metric. 10672 10673 The <tt>returnData</tt> parameter is a flattened array of arrays. Each 10674 start and length of a sub-array is indicated by 10675 <tt>returnDataIndices</tt> and <tt>returnDataLengths</tt>. The first 10676 value for metric <tt>metricNames[i]</tt> is at 10677 <tt>returnData[returnIndices[i]]</tt>. 10678 10679 <note> 10680 @c Null or empty metric name array means all metrics. @c Null or empty 10681 object array means all existing objects. If metric name array contains 10682 a single element and object array contains many, the single metric 10683 name array element is applied to each object array element to form 10684 metric/object pairs. 10749 10685 </note> 10750 10686 <note> … … 10762 10698 <param name="metricNames" type="wstring" dir="in" safearray="yes"> 10763 10699 <desc> 10764 Metric name filter. C urrently, only a comma-separated list of metrics10765 is supported.10700 Metric name filter. Comma-separated list of metrics with wildcard 10701 support. 10766 10702 </desc> 10767 10703 </param> … … 10781 10717 </desc> 10782 10718 </param> 10719 <param name="returnUnits" type="wstring" dir="out" safearray="yes"> 10720 <desc> 10721 Units of measurement for each returned metric. 10722 </desc> 10723 </param> 10724 <param name="returnScales" type="unsigned long" dir="out" safearray="yes"> 10725 <desc> 10726 Divisor that should be applied to return values in order to get 10727 floating point values. For example: 10728 <tt>(double)returnData[returnDataIndices[0]+i] / returnScales[0]</tt> 10729 will retrieve the floating point value of i-th sample of the first 10730 metric. 10731 </desc> 10732 </param> 10733 <param name="returnSequenceNumbers" type="unsigned long" dir="out" safearray="yes"> 10734 <desc> 10735 Sequence numbers of the first elements of value sequences of particular metrics 10736 returned in @c returnData. For aggregate metrics it is the sequence number of 10737 the sample the aggregate started calculation from. 10738 </desc> 10739 </param> 10783 10740 <param name="returnDataIndices" type="unsigned long" dir="out" safearray="yes"> 10784 10741 <desc> … … 10799 10756 </param> 10800 10757 </method> 10801 10802 <method name="queryMetricsDataEx">10803 <desc>10804 Queries collected metrics data for a set of objects.10805 10806 Indentical to <link to="IPerformanceCollector::queryMetricsData" /> except10807 that it returns three additional arrays: <tt>returnUnits</tt>,10808 <tt>returnScales</tt>, <tt>returnSequenceNumbers</tt>. All additional10809 arrays have the same size as <tt>returnMetricNames</tt>.10810 <note>10811 @c Null metrics array means all applicable metrics. @c Null object10812 array means all existing objects.10813 </note>10814 </desc>10815 <param name="metricNames" type="wstring" dir="in" safearray="yes">10816 <desc>10817 Metric name filter. Currently, only a comma-separated list of metrics10818 is supported.10819 </desc>10820 </param>10821 <param name="objects" type="$unknown" dir="in" safearray="yes">10822 <desc>10823 Set of objects to query metrics for.10824 </desc>10825 </param>10826 <param name="returnMetricNames" type="wstring" dir="out" safearray="yes">10827 <desc>10828 Names of metrics returned in @c returnData.10829 </desc>10830 </param>10831 <param name="returnObjects" type="$unknown" dir="out" safearray="yes">10832 <desc>10833 Objects associated with metrics returned in @c returnData.10834 </desc>10835 </param>10836 <param name="returnUnits" type="wstring" dir="out" safearray="yes">10837 <desc>10838 Units of measurement for each returned metric.10839 </desc>10840 </param>10841 <param name="returnScales" type="unsigned long" dir="out" safearray="yes">10842 <desc>10843 Divisor that should be applied to return values in order to get10844 floating point values. For example:10845 <tt>(double)returnData[returnDataIndices[0]+i] / returnScales[0]</tt>10846 will retrieve the floating point value of i-th sample of the first10847 metric.10848 </desc>10849 </param>10850 <param name="returnSequenceNumbers" type="unsigned long" dir="out" safearray="yes">10851 <desc>10852 Sequence numbers of the first elements of value sequences of particular metrics10853 returned in @c returnData. For aggregate metrics it is the sequence number of10854 the sample the aggregate started calculation from.10855 </desc>10856 </param>10857 <param name="returnDataIndices" type="unsigned long" dir="out" safearray="yes">10858 <desc>10859 Indices of the first elements of value sequences of particular metrics10860 returned in @c returnData.10861 </desc>10862 </param>10863 <param name="returnDataLengths" type="unsigned long" dir="out" safearray="yes">10864 <desc>10865 Lengths of value sequences of particular metrics.10866 </desc>10867 </param>10868 <param name="returnData" type="long" dir="return" safearray="yes">10869 <desc>10870 Flattened array of all metric data containing sequences of values for10871 each metric.10872 </desc>10873 </param>10874 </method>10875 10876 10758 10877 10759 </interface> -
trunk/src/VBox/Main/include/PerformanceImpl.h
r12973 r13082 148 148 STDMETHOD(SetupMetrics) (ComSafeArrayIn (INPTR BSTR, metricNames), 149 149 ComSafeArrayIn (IUnknown *, objects), 150 ULONG aPeriod, ULONG aCount); 150 ULONG aPeriod, ULONG aCount, 151 ComSafeArrayOut (IPerformanceMetric *, 152 outMetrics)); 151 153 STDMETHOD(EnableMetrics) (ComSafeArrayIn (INPTR BSTR, metricNames), 152 ComSafeArrayIn (IUnknown *, objects)); 154 ComSafeArrayIn (IUnknown *, objects), 155 ComSafeArrayOut (IPerformanceMetric *, 156 outMetrics)); 153 157 STDMETHOD(DisableMetrics) (ComSafeArrayIn (INPTR BSTR, metricNames), 154 ComSafeArrayIn (IUnknown *, objects)); 158 ComSafeArrayIn (IUnknown *, objects), 159 ComSafeArrayOut (IPerformanceMetric *, 160 outMetrics)); 155 161 STDMETHOD(QueryMetricsData) (ComSafeArrayIn (INPTR BSTR, metricNames), 156 162 ComSafeArrayIn (IUnknown *, objects), 157 163 ComSafeArrayOut (BSTR, outMetricNames), 158 164 ComSafeArrayOut (IUnknown *, outObjects), 165 ComSafeArrayOut (BSTR, outUnits), 166 ComSafeArrayOut (ULONG, outScales), 167 ComSafeArrayOut (ULONG, outSequenceNumbers), 159 168 ComSafeArrayOut (ULONG, outDataIndices), 160 169 ComSafeArrayOut (ULONG, outDataLengths), 161 170 ComSafeArrayOut (LONG, outData)); 162 163 STDMETHOD(SetupMetricsEx) (ComSafeArrayIn (INPTR BSTR, metricNames),164 ComSafeArrayIn (IUnknown *, objects),165 ULONG aPeriod, ULONG aCount,166 ComSafeArrayOut (IPerformanceMetric *,167 outMetrics));168 STDMETHOD(EnableMetricsEx) (ComSafeArrayIn (INPTR BSTR, metricNames),169 ComSafeArrayIn (IUnknown *, objects),170 ComSafeArrayOut (IPerformanceMetric *,171 outMetrics));172 STDMETHOD(DisableMetricsEx) (ComSafeArrayIn (INPTR BSTR, metricNames),173 ComSafeArrayIn (IUnknown *, objects),174 ComSafeArrayOut (IPerformanceMetric *,175 outMetrics));176 STDMETHOD(QueryMetricsDataEx) (ComSafeArrayIn (INPTR BSTR, metricNames),177 ComSafeArrayIn (IUnknown *, objects),178 ComSafeArrayOut (BSTR, outMetricNames),179 ComSafeArrayOut (IUnknown *, outObjects),180 ComSafeArrayOut (BSTR, outUnits),181 ComSafeArrayOut (ULONG, outScales),182 ComSafeArrayOut (ULONG, outSequenceNumbers),183 ComSafeArrayOut (ULONG, outDataIndices),184 ComSafeArrayOut (ULONG, outDataLengths),185 ComSafeArrayOut (LONG, outData));186 171 187 172 // public methods only for internal purposes … … 203 188 HRESULT toIPerformanceMetric(pm::Metric *src, IPerformanceMetric **dst); 204 189 HRESULT toIPerformanceMetric(pm::BaseMetric *src, IPerformanceMetric **dst); 205 HRESULT SetupMetricsInt(ComSafeArrayIn (INPTR BSTR, metricNames),206 ComSafeArrayIn (IUnknown *, objects),207 ULONG aPeriod, ULONG aCount, bool reportAffected,208 ComSafeArrayOut (IPerformanceMetric *, outMetrics));209 HRESULT EnableMetricsInt (ComSafeArrayIn (INPTR BSTR, metricNames),210 ComSafeArrayIn (IUnknown *, objects),211 bool reportAffected,212 ComSafeArrayOut (IPerformanceMetric *,213 outMetrics));214 HRESULT DisableMetricsInt (ComSafeArrayIn (INPTR BSTR, metricNames),215 ComSafeArrayIn (IUnknown *, objects),216 bool reportAffected,217 ComSafeArrayOut (IPerformanceMetric *,218 outMetrics));219 190 220 191 static void staticSamplerCallback (RTTIMERLR hTimerLR, void *pvUser, uint64_t iTick); -
trunk/src/VBox/Main/testcase/tstAPI.cpp
r12668 r13082 970 970 // Setup base metrics 971 971 // Note that one needs to set up metrics after a session is open for a machine. 972 com::SafeIfaceArray<IPerformanceMetric> affectedMetrics; 972 973 com::SafeIfaceArray<IUnknown> objects(2); 973 974 host.queryInterfaceTo(&objects[0]); 974 975 machine.queryInterfaceTo(&objects[1]); 975 976 CHECK_ERROR_BREAK (collector, SetupMetrics(ComSafeArrayAsInParam(baseMetrics), 976 ComSafeArrayAsInParam(objects), 1u, 10u) ); 977 ComSafeArrayAsInParam(objects), 1u, 10u, 978 ComSafeArrayAsOutParam(affectedMetrics)) ); 979 listAffectedMetrics(virtualBox, 980 ComSafeArrayAsInParam(affectedMetrics)); 981 affectedMetrics.setNull(); 977 982 978 983 // Get console … … 996 1001 queryMetrics(virtualBox, collector, ComSafeArrayAsInParam(objects)); 997 1002 998 com::SafeIfaceArray<IPerformanceMetric> affectedMetrics;999 1003 printf("\nDrop collected metrics: ----------------------------------------\n"); 1000 1004 CHECK_ERROR_BREAK (collector, 1001 SetupMetrics Ex(ComSafeArrayAsInParam(baseMetrics),1002 1003 1005 SetupMetrics(ComSafeArrayAsInParam(baseMetrics), 1006 ComSafeArrayAsInParam(objects), 1007 1u, 5u, ComSafeArrayAsOutParam(affectedMetrics)) ); 1004 1008 listAffectedMetrics(virtualBox, 1005 1009 ComSafeArrayAsInParam(affectedMetrics)); … … 1012 1016 printf("\nDisable collection of VM metrics: ------------------------------\n"); 1013 1017 CHECK_ERROR_BREAK (collector, 1014 DisableMetrics Ex(ComSafeArrayAsInParam(baseMetrics),1015 1016 1018 DisableMetrics(ComSafeArrayAsInParam(baseMetrics), 1019 ComSafeArrayAsInParam(vmObject), 1020 ComSafeArrayAsOutParam(affectedMetrics)) ); 1017 1021 listAffectedMetrics(virtualBox, 1018 1022 ComSafeArrayAsInParam(affectedMetrics)); … … 1023 1027 printf("\nRe-enable collection of all metrics: ---------------------------\n"); 1024 1028 CHECK_ERROR_BREAK (collector, 1025 EnableMetrics Ex(ComSafeArrayAsInParam(baseMetrics),1026 1027 1029 EnableMetrics(ComSafeArrayAsInParam(baseMetrics), 1030 ComSafeArrayAsInParam(objects), 1031 ComSafeArrayAsOutParam(affectedMetrics)) ); 1028 1032 listAffectedMetrics(virtualBox, 1029 1033 ComSafeArrayAsInParam(affectedMetrics)); … … 1073 1077 com::SafeArray<BSTR> retNames; 1074 1078 com::SafeIfaceArray<IUnknown> retObjects; 1079 com::SafeArray<BSTR> retUnits; 1080 com::SafeArray<ULONG> retScales; 1081 com::SafeArray<ULONG> retSequenceNumbers; 1075 1082 com::SafeArray<ULONG> retIndices; 1076 1083 com::SafeArray<ULONG> retLengths; … … 1080 1087 ComSafeArrayAsOutParam(retNames), 1081 1088 ComSafeArrayAsOutParam(retObjects), 1089 ComSafeArrayAsOutParam(retUnits), 1090 ComSafeArrayAsOutParam(retScales), 1091 ComSafeArrayAsOutParam(retSequenceNumbers), 1082 1092 ComSafeArrayAsOutParam(retIndices), 1083 1093 ComSafeArrayAsOutParam(retLengths), … … 1087 1097 for (unsigned i = 0; i < retNames.size(); i++) 1088 1098 { 1089 // Get info for the metric 1090 com::SafeArray<BSTR> nameOfMetric(1); 1091 Bstr tmpName(retNames[i]); 1092 tmpName.detachTo (&nameOfMetric[0]); 1093 com::SafeIfaceArray<IUnknown> anObject(1); 1094 ComPtr<IUnknown> tmpObject(retObjects[i]); 1095 tmpObject.queryInterfaceTo(&anObject[0]); 1096 com::SafeIfaceArray <IPerformanceMetric> metricInfo; 1097 CHECK_RC_BREAK (collector->GetMetrics( ComSafeArrayAsInParam(nameOfMetric), 1098 ComSafeArrayAsInParam(anObject), 1099 ComSafeArrayAsOutParam(metricInfo) )); 1100 BSTR metricUnitBSTR; 1101 CHECK_RC_BREAK (metricInfo[0]->COMGETTER(Unit) (&metricUnitBSTR)); 1102 Bstr metricUnit(metricUnitBSTR); 1099 Bstr metricUnit(retUnits[i]); 1103 1100 Bstr metricName(retNames[i]); 1104 LONG minVal, maxVal; 1105 CHECK_RC_BREAK (metricInfo[0]->COMGETTER(MinimumValue) (&minVal)); 1106 CHECK_RC_BREAK (metricInfo[0]->COMGETTER(MaximumValue) (&maxVal)); 1107 RTPrintf("%-10ls %-20ls ", getObjectName(aVirtualBox, anObject[0]).raw(), metricName.raw()); 1101 RTPrintf("%-10ls %-20ls ", getObjectName(aVirtualBox, retObjects[i]).raw(), metricName.raw()); 1108 1102 const char *separator = ""; 1109 1103 for (unsigned j = 0; j < retLengths[i]; j++) 1110 1104 { 1111 if ( strcmp((const char *)metricUnit.raw(), "%"))1105 if (retScales[i] == 1) 1112 1106 RTPrintf("%s%d %ls", separator, retData[retIndices[i] + j], metricUnit.raw()); 1113 1107 else 1114 RTPrintf("%s%d.%02d%%", separator, retData[retIndices[i] + j] / 1000, (retData[retIndices[i] + j] / 10) % 100); 1108 RTPrintf("%s%d.%02d%ls", separator, retData[retIndices[i] + j] / retScales[i], 1109 (retData[retIndices[i] + j] * 100 / retScales[i]) % 100, metricUnit.raw()); 1115 1110 separator = ", "; 1116 1111 } -
trunk/src/libs/xpcom18a4/python/sample/shellcommon.py
r12942 r13082 23 23 self.collector = vb.performanceCollector 24 24 25 def _update_metric_params(self):26 metrics = self.collector.getMetrics(['*'], None)27 self.metrics = {}28 for m in metrics:29 self.metrics[str(m.object) + "/" + str(m.metricName)] = m30 31 25 def setup(self, names, objects, period, nsamples): 32 26 """ Discards all previously collected values for the specified … … 35 29 """ 36 30 self.collector.setupMetrics(names, objects, period, nsamples) 37 self._update_metric_params()38 31 39 32 def enable(self, names, objects): … … 58 51 'values_as_string': pre-processed values ready for 'print' statement 59 52 """ 60 (values, names_out, objects_out, indices, lengths) = self.collector.queryMetricsData(names, objects) 53 (values, names_out, objects_out, units, scales, sequence_numbers, 54 indices, lengths) = self.collector.queryMetricsData(names, objects) 61 55 out = [] 62 56 for i in xrange(0, len(names_out)): 63 metric = self.metrics[str(objects_out[i]) + "/" + str(names_out[i])] 64 unit = str(metric.getUnit()) 65 if unit == '%': 66 scale = 1000. 57 scale = int(scales[i]) 58 if scale != 1: 67 59 fmt = '%.2f%s' 68 60 else: 69 scale = 170 61 fmt = '%d %s' 71 62 out.append({ 72 63 'name':str(names_out[i]), 73 64 'object':str(objects_out[i]), 74 'unit':str( metric.getUnit()),65 'unit':str(units[i]), 75 66 'scale':scale, 76 67 'values':[int(values[j]) for j in xrange(int(indices[i]), int(indices[i])+int(lengths[i]))], 77 'values_as_string':'['+', '.join([fmt % (int(values[j])/scale, unit ) for j in xrange(int(indices[i]), int(indices[i])+int(lengths[i]))])+']'68 'values_as_string':'['+', '.join([fmt % (int(values[j])/scale, units[i]) for j in xrange(int(indices[i]), int(indices[i])+int(lengths[i]))])+']' 78 69 }) 79 70 return out
Note:
See TracChangeset
for help on using the changeset viewer.