Changeset 82131 in vbox for trunk/src/VBox/Frontends
- Timestamp:
- Nov 23, 2019 5:58:45 PM (5 years ago)
- svn:sync-xref-src-repo-rev:
- 134941
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/runtime/information
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/runtime/information/UIInformationPerformanceMonitor.cpp
r81793 r82131 838 838 foreach (const QString &strSubString, m_metricDataSubString) 839 839 { 840 /** @todo r=bird: It is much more efficient to (1) start a query with '/' and 841 * (2) not use multiple expressions. If you don't start with '/', 842 * STAM must search all the statistics. If you have multiple 843 * expressions it is not yet clever enough to optimize the search and 844 * will search all the statistics. There are several thousand in a 845 * debug builds, some 400-600 in a typical release build (config dep). */ 840 846 m_strQueryString += QString("*%1*%2*%3*|").arg(m_strQueryPrefix).arg(strDeviceName).arg(strSubString); 841 847 } … … 1063 1069 } 1064 1070 1065 /* Collect the data from IMachineDebugger::getStats(..): */ 1066 quint64 uNetworkTotalReceive = 0; 1067 quint64 uNetworkTotalTransmit = 0; 1068 quint64 uDiskIOTotalWritten = 0; 1069 quint64 uDiskIOTotalRead = 0; 1070 quint64 uTotalVMExits = 0; 1071 1072 QVector<UIDebuggerMetricData> xmlData = getTotalCounterFromDegugger(m_strQueryString); 1073 for (QMap<QString, UIMetric>::iterator iterator = m_metrics.begin(); 1074 iterator != m_metrics.end(); ++iterator) 1075 { 1076 UIMetric &metric = iterator.value(); 1077 const QStringList &deviceTypeList = metric.deviceTypeList(); 1078 foreach (const QString &strDeviceType, deviceTypeList) 1071 /* Update the network load chart with values we find under /Public/NetAdapter/: */ 1072 { 1073 quint64 cbNetworkTotalReceived = 0; 1074 quint64 cbNetworkTotalTransmitted = 0; 1075 QVector<UIDebuggerMetricData> xmlData = getAndParseStatsFromDebugger("/Public/NetAdapter/*/Bytes*"); 1076 foreach (const UIDebuggerMetricData &data, xmlData) 1079 1077 { 1080 foreach (const UIDebuggerMetricData &data, xmlData) 1081 { 1082 if (data.m_strName.contains(strDeviceType, Qt::CaseInsensitive)) 1083 { 1084 if (metric.name() == m_strNetworkMetricName) 1085 { 1086 if (data.m_strName.contains("receive", Qt::CaseInsensitive)) 1087 uNetworkTotalReceive += data.m_counter; 1088 else if (data.m_strName.contains("transmit", Qt::CaseInsensitive)) 1089 uNetworkTotalTransmit += data.m_counter; 1090 } 1091 else if (metric.name() == m_strDiskIOMetricName) 1092 { 1093 if (data.m_strName.contains("written", Qt::CaseInsensitive)) 1094 uDiskIOTotalWritten += data.m_counter; 1095 else if (data.m_strName.contains("read", Qt::CaseInsensitive)) 1096 uDiskIOTotalRead += data.m_counter; 1097 } 1098 else if (metric.name() == m_strVMExitMetricName) 1099 { 1100 if (data.m_strName.contains("RecordedExits", Qt::CaseInsensitive)) 1101 uTotalVMExits += data.m_counter; 1102 } 1103 } 1104 } 1078 if (data.m_strName.endsWith("BytesReceived")) 1079 cbNetworkTotalReceived += data.m_counter; 1080 else if (data.m_strName.endsWith("BytesTransmitted")) 1081 cbNetworkTotalTransmitted += data.m_counter; 1082 else 1083 AssertMsgFailed(("name=%s\n", data.m_strName.toLocal8Bit().data())); 1105 1084 } 1106 } 1107 updateNetworkGraphsAndMetric(uNetworkTotalReceive, uNetworkTotalTransmit); 1108 updateDiskIOGraphsAndMetric(uDiskIOTotalWritten, uDiskIOTotalRead); 1109 updateVMExitMetric(uTotalVMExits); 1110 } 1111 1085 updateNetworkGraphsAndMetric(cbNetworkTotalReceived, cbNetworkTotalTransmitted); 1086 } 1087 1088 /* Update the Disk I/O chart with values we find under /Public/Storage/?/Port?/Bytes*: */ 1089 { 1090 quint64 cbDiskIOTotalWritten = 0; 1091 quint64 cbDiskIOTotalRead = 0; 1092 QVector<UIDebuggerMetricData> xmlData = getAndParseStatsFromDebugger("/Public/Storage/*/Port*/Bytes*"); 1093 foreach (const UIDebuggerMetricData &data, xmlData) 1094 { 1095 if (data.m_strName.endsWith("BytesWritten")) 1096 cbDiskIOTotalWritten += data.m_counter; 1097 else if (data.m_strName.endsWith("BytesRead")) 1098 cbDiskIOTotalRead += data.m_counter; 1099 else 1100 AssertMsgFailed(("name=%s\n", data.m_strName.toLocal8Bit().data())); 1101 } 1102 updateDiskIOGraphsAndMetric(cbDiskIOTotalWritten, cbDiskIOTotalRead); 1103 } 1104 1105 /* Update the VM exit chart with values we find as /PROF/CPU?/EM/RecordedExits: */ 1106 { 1107 quint64 cTotalVMExits = 0; 1108 QVector<UIDebuggerMetricData> xmlData = getAndParseStatsFromDebugger("/PROF/CPU*/EM/RecordedExits"); 1109 foreach (const UIDebuggerMetricData &data, xmlData) 1110 { 1111 if (data.m_strName.endsWith("RecordedExits")) 1112 cTotalVMExits += data.m_counter; 1113 else 1114 AssertMsgFailed(("name=%s\n", data.m_strName.toLocal8Bit().data())); 1115 } 1116 updateVMExitMetric(cTotalVMExits); 1117 } 1118 } 1119 1120 /** 1121 * 1122 * @returns 1123 */ 1112 1124 void UIInformationPerformanceMonitor::sltGuestAdditionsStateChange() 1113 1125 { … … 1147 1159 1148 1160 m_metrics.insert(m_strCPUMetricName, UIMetric(m_strCPUMetricName, "%", iMaximumQueueSize)); 1161 /** @todo r=bird: This way of constructing queries is inefficient, see 1162 * comment in query composer. Also, both the network and disk bits 1163 * have moved now. The update timer method has been updated and no 1164 * longer makes use of this for the statistics querying. */ 1149 1165 { 1150 1166 /* Network metric: */ … … 1152 1168 networkMetric.setQueryPrefix("Public"); 1153 1169 QStringList networkDeviceList; 1154 networkDeviceList << "E1k" << "VNet" << "PCNet";1170 networkDeviceList << "E1k" << "VNet" << "PCNet"; 1155 1171 networkMetric.setDeviceTypeList(networkDeviceList); 1156 1172 QStringList networkMetricDataSubStringList; … … 1410 1426 } 1411 1427 1412 QVector<UIDebuggerMetricData> UIInformationPerformanceMonitor::get TotalCounterFromDegugger(const QString &strQuery)1428 QVector<UIDebuggerMetricData> UIInformationPerformanceMonitor::getAndParseStatsFromDebugger(const QString &strQuery) 1413 1429 { 1414 1430 QVector<UIDebuggerMetricData> xmlData; 1415 1431 if (strQuery.isEmpty()) 1416 1432 return xmlData; 1417 CMachineDebugger debugger = m_console.GetDebugger(); 1418 QString strStats = debugger.GetStats(strQuery, false); 1433 QString strStats = m_machineDebugger.GetStats(strQuery, false); 1419 1434 QXmlStreamReader xmlReader; 1420 1435 xmlReader.addData(strStats); 1421 quint64 iTotal = 0;1422 1436 if (xmlReader.readNextStartElement()) 1423 1437 { … … 1428 1442 QXmlStreamAttributes attributes = xmlReader.attributes(); 1429 1443 quint64 iCounter = attributes.value("c").toULongLong(); 1430 iTotal += iCounter; 1431 xmlReader.skipCurrentElement(); 1432 xmlData.push_back(UIDebuggerMetricData(*(attributes.value("name").string()), iCounter)); 1444 xmlData.push_back(UIDebuggerMetricData(attributes.value("name"), iCounter)); 1433 1445 } 1434 1446 else if (xmlReader.name() == "U64") … … 1436 1448 QXmlStreamAttributes attributes = xmlReader.attributes(); 1437 1449 quint64 iCounter = attributes.value("val").toULongLong(); 1438 iTotal += iCounter; 1439 xmlReader.skipCurrentElement(); 1440 xmlData.push_back(UIDebuggerMetricData(*(attributes.value("name").string()), iCounter)); 1450 xmlData.push_back(UIDebuggerMetricData(attributes.value("name"), iCounter)); 1441 1451 } 1442 else 1443 xmlReader.skipCurrentElement(); 1452 xmlReader.skipCurrentElement(); 1444 1453 } 1445 1454 } -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/information/UIInformationPerformanceMonitor.h
r81109 r82131 53 53 UIDebuggerMetricData() 54 54 : m_counter(0){} 55 UIDebuggerMetricData(const QString & strName, quint64 counter)56 : m_strName(strName)55 UIDebuggerMetricData(const QStringRef & strName, quint64 counter) 56 : m_strName(strName.toString()) 57 57 , m_counter(counter){} 58 58 QString m_strName; … … 181 181 QString dataColorString(const QString &strChartName, int iDataIndex); 182 182 /** Parses the xml string we get from the IMachineDebugger and returns an array of UIDebuggerMetricData. */ 183 QVector<UIDebuggerMetricData> get TotalCounterFromDegugger(const QString &strQuery);183 QVector<UIDebuggerMetricData> getAndParseStatsFromDebugger(const QString &strQuery); 184 184 185 185 bool m_fGuestAdditionsAvailable;
Note:
See TracChangeset
for help on using the changeset viewer.