VirtualBox

Changeset 80409 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Aug 23, 2019 10:43:22 PM (5 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:9510: Removing the network metric we get from IPerformanceCollector.

Location:
trunk/src/VBox/Frontends/VirtualBox/src/runtime/information
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/information/UIInformationRuntime.cpp

    r80407 r80409  
    587587            strValue = QString::number(iValue);
    588588        else if (m_pSubMetric->unit().compare("kb", Qt::CaseInsensitive) == 0)
    589             strValue = uiCommon().formatSize(_1K * (quint64)iValue, iDecimalCount);
     589            strValue = uiCommon().formatSize(_1K * (qulonglong)iValue, iDecimalCount);
    590590        else if (m_pSubMetric->unit().compare("b", Qt::CaseInsensitive) == 0 ||
    591591                 m_pSubMetric->unit().compare("b/s", Qt::CaseInsensitive) == 0)
     
    804804    , m_strRAMMetricName("RAM Usage")
    805805    , m_strDiskMetricName("Disk Usage")
    806     , m_strNetMetricName("Net")
    807     , m_strNetDebuggerMetricName("NetDebugger")
    808 
     806    , m_strNetworkMetricName("NetDebugger")
     807    , m_iTimeStep(0)
    809808{
    810809    if (!m_console.isNull())
     
    844843    m_strRAMInfoLabelUsed = QApplication::translate("UIVMInformationDialog", "Used");
    845844    iMaximum = qMax(iMaximum, m_strRAMInfoLabelUsed.length());
    846     m_strNetInfoLabelTitle = QApplication::translate("UIVMInformationDialog", "Network");
    847     iMaximum = qMax(iMaximum, m_strNetInfoLabelTitle.length());
    848     m_strNetInfoLabelReceived = QApplication::translate("UIVMInformationDialog", "Receive Rate");
    849     iMaximum = qMax(iMaximum, m_strNetInfoLabelReceived.length());
    850     m_strNetInfoLabelTransmitted = QApplication::translate("UIVMInformationDialog", "Transmit Rate");
    851     iMaximum = qMax(iMaximum, m_strNetInfoLabelTransmitted.length());
    852     m_strNetInfoLabelMaximum = QApplication::translate("UIVMInformationDialog", "Maximum");
    853     iMaximum = qMax(iMaximum, m_strNetInfoLabelMaximum.length());
     845    m_strNetworkInfoLabelTitle = QApplication::translate("UIVMInformationDialog", "Network");
     846    iMaximum = qMax(iMaximum, m_strNetworkInfoLabelTitle.length());
     847    m_strNetworkInfoLabelReceived = QApplication::translate("UIVMInformationDialog", "Receive Rate");
     848    iMaximum = qMax(iMaximum, m_strNetworkInfoLabelReceived.length());
     849    m_strNetworkInfoLabelTransmitted = QApplication::translate("UIVMInformationDialog", "Transmit Rate");
     850    iMaximum = qMax(iMaximum, m_strNetworkInfoLabelTransmitted.length());
     851    m_strNetworkInfoLabelReceivedTotal = QApplication::translate("UIVMInformationDialog", "Total Received");
     852    iMaximum = qMax(iMaximum, m_strNetworkInfoLabelReceivedTotal.length());
     853    m_strNetworkInfoLabelTransmittedTotal = QApplication::translate("UIVMInformationDialog", "Total Transmitted");
     854    iMaximum = qMax(iMaximum, m_strNetworkInfoLabelReceivedTotal.length());
     855
    854856
    855857    /* Compute the maximum label string length and set it as a fixed width to labels to prevent always changing widths: */
    856     /* Add m_iDecimalCount plus 3 characters for the number and 2 for unit string: */
    857     iMaximum += (iDecimalCount + 5);
     858    /* Add m_iDecimalCount plus 3 characters for the number and 3 for unit string: */
     859    iMaximum += (iDecimalCount + 7);
    858860    if (!m_infoLabels.isEmpty())
    859861    {
     
    862864        {
    863865            QFontMetrics labelFontMetric(pLabel->font());
    864             int iWidth = iMaximum * labelFontMetric.width('x');
     866            int iWidth = iMaximum * labelFontMetric.width('X');
    865867            foreach (QLabel *pInfoLabel, m_infoLabels)
    866868                pInfoLabel->setFixedWidth(iWidth);
     
    890892
    891893    QStringList chartOder;
    892     chartOder << m_strCPUMetricName << m_strRAMMetricName << m_strDiskMetricName << m_strNetMetricName << m_strNetDebuggerMetricName;
     894    chartOder << m_strCPUMetricName << m_strRAMMetricName << m_strDiskMetricName << m_strNetworkMetricName;
    893895    int iRow = 0;
    894896    foreach (const QString &strMetricName, chartOder)
     
    909911
    910912    /* Configure charts: */
    911     if (m_charts.contains(m_strNetMetricName) && m_charts[m_strNetMetricName])
    912     {
    913         m_charts[m_strNetMetricName]->setDrawPieChart(false);
    914         m_charts[m_strNetMetricName]->setUseGradientLineColor(false);
    915     }
    916     if (m_charts.contains(m_strNetDebuggerMetricName) && m_charts[m_strNetDebuggerMetricName])
    917     {
    918         m_charts[m_strNetDebuggerMetricName]->setDrawPieChart(false);
    919         m_charts[m_strNetDebuggerMetricName]->setUseGradientLineColor(false);
     913    if (m_charts.contains(m_strNetworkMetricName) && m_charts[m_strNetworkMetricName])
     914    {
     915        m_charts[m_strNetworkMetricName]->setDrawPieChart(false);
     916        m_charts[m_strNetworkMetricName]->setUseGradientLineColor(false);
    920917    }
    921918
     
    941938    if (m_performanceMonitor.isNull())
    942939        return;
     940    ++m_iTimeStep;
    943941    QVector<QString> allNames;// = new ArrayList<IUnknown>();
    944942    QVector<CUnknown> allObjects;// = new ArrayList<IUnknown>();
     
    961959                                                                     aReturnDataIndices,
    962960                                                                     aReturnDataLengths);
    963     quint64 iTotalRAM = 0;
    964     quint64 iFreeRAM = 0;
    965     ULONG iReceiveRate = 0;
    966     ULONG  iTransmitRate = 0;
     961    qulonglong iTotalRAM = 0;
     962    qulonglong iFreeRAM = 0;
    967963
    968964    for (int i = 0; i < aReturnNames.size(); ++i)
     
    979975                iFreeRAM = (quint64)fData;
    980976        }
    981         else if (aReturnNames[i].contains("Net/Rate", Qt::CaseInsensitive) && !aReturnNames[i].contains(":"))
    982         {
    983             if (aReturnNames[i].contains("Rx", Qt::CaseInsensitive))
    984                 iReceiveRate = fData;
    985             if (aReturnNames[i].contains("Tx", Qt::CaseInsensitive))
    986                 iTransmitRate = fData;
    987         }
    988977    }
    989978    if (m_subMetrics.contains(m_strRAMMetricName))
    990979        updateRAMGraphsAndMetric(iTotalRAM, iFreeRAM);
    991     if (m_subMetrics.contains(m_strNetMetricName))
    992         updateNetworkGraphsAndMetric(iReceiveRate, iTransmitRate);
    993980
    994981    /* Update the CPU load chart with values we get from IMachineDebugger::getCPULoad(..): */
     
    10171004                if (data.m_strName.contains(strDeviceType, Qt::CaseInsensitive))
    10181005                {
    1019                     if (metric.name() == m_strNetDebuggerMetricName)
     1006                    if (metric.name() == m_strNetworkMetricName)
    10201007                    {
    10211008                        if (data.m_strName.contains("receive", Qt::CaseInsensitive))
     
    10501037        return;
    10511038
    1052     // m_nameList << "Guest/RAM/Usage*";
    10531039    m_nameList << "Guest/RAM/Usage*";
    1054     m_nameList << "Net/Rate*";
    1055 
    1056 
    10571040    m_objectList = QVector<CUnknown>(m_nameList.size(), CUnknown());
    10581041    m_performanceMonitor.SetupMetrics(m_nameList, m_objectList, iPeriod, iMetricSetupCount);
     
    10701053                    m_subMetrics.insert(m_strRAMMetricName, newMetric);
    10711054                }
    1072                 else if (strName.contains("Net", Qt::CaseInsensitive))
    1073                 {
    1074                     UISubMetric newMetric(m_strNetMetricName, metrics[i].GetUnit(), iMaximumQueueSize);
    1075                     newMetric.setRequiresGuestAdditions(true);
    1076                     m_subMetrics.insert(m_strNetMetricName, newMetric);
    1077                 }
    10781055            }
    10791056        }
     
    10821059    m_subMetrics.insert(m_strCPUMetricName, UISubMetric(m_strCPUMetricName, "%", iMaximumQueueSize));
    10831060
    1084     UISubMetric networkMetric(m_strNetDebuggerMetricName, "B", iMaximumQueueSize);
     1061    UISubMetric networkMetric(m_strNetworkMetricName, "B", iMaximumQueueSize);
    10851062    QStringList networkDeviceList;
    10861063    networkDeviceList << "E1k" <<"VNet" << "PCNet";
     
    10891066    networkMetricDataSubStringList << "ReceiveBytes" << "TransmitBytes";
    10901067    networkMetric.setMetricDataSubString(networkMetricDataSubStringList);
    1091     m_subMetrics.insert(m_strNetDebuggerMetricName, networkMetric);
     1068    m_subMetrics.insert(m_strNetworkMetricName, networkMetric);
    10921069
    10931070    for (QMap<QString, UISubMetric>::const_iterator iterator =  m_subMetrics.begin();
     
    11851162}
    11861163
    1187 void UIInformationRuntime::updateNetworkGraphsAndMetric(qulonglong iReceiveRate, qulonglong iTransmitRate)
    1188 {
    1189     UISubMetric &NetMetric = m_subMetrics[m_strNetMetricName];
    1190 
    1191     NetMetric.addData(0, iReceiveRate);
    1192     NetMetric.addData(1, iTransmitRate);
    1193 
    1194     qulonglong iMaximum = qMax(NetMetric.maximum(), qMax(iReceiveRate, iTransmitRate));
    1195     NetMetric.setMaximum(iMaximum);
    1196 
    1197     if (m_infoLabels.contains(m_strNetMetricName)  && m_infoLabels[m_strNetMetricName])
    1198     {
    1199         QString strInfo;
    1200         QString strReceiveColor;
    1201         if (m_infoLabels[m_strNetMetricName]->isEnabled())
    1202             strInfo = QString("<b>%1</b></b><br/><font color=\"%2\">%3: %4</font><br/><font color=\"%5\">%6: %7</font><br/>%8: %9")
    1203                 .arg(m_strNetInfoLabelTitle)
    1204                 .arg(dataColorString(m_strNetMetricName, 0))
    1205                 .arg(m_strNetInfoLabelReceived).arg(uiCommon().formatSize((quint64)iReceiveRate, iDecimalCount))
    1206                 .arg(dataColorString(m_strNetMetricName, 1))
    1207                 .arg(m_strNetInfoLabelTransmitted).arg(uiCommon().formatSize((quint64)iTransmitRate, iDecimalCount))
    1208                 .arg(m_strNetInfoLabelMaximum).arg(uiCommon().formatSize((quint64)iMaximum, iDecimalCount));
    1209         else
    1210             strInfo = QString("<b>%1</b><br/>%2: %3<br/>%4: %5<br/>%6: %7").arg(m_strNetInfoLabelTitle).arg(m_strNetInfoLabelReceived).arg("---").arg(m_strNetInfoLabelTransmitted).arg("---");
    1211         m_infoLabels[m_strNetMetricName]->setText(strInfo);
    1212     }
    1213     if (m_charts.contains(m_strNetMetricName))
    1214         m_charts[m_strNetMetricName]->update();
    1215 }
    1216 
    12171164void UIInformationRuntime::updateNetworkDebuggerGraphsAndMetric(qulonglong iReceiveTotal, qulonglong iTransmitTotal)
    12181165{
    1219     UISubMetric &NetMetric = m_subMetrics[m_strNetDebuggerMetricName];
     1166    UISubMetric &NetMetric = m_subMetrics[m_strNetworkMetricName];
    12201167
    12211168    qulonglong iReceiveRate = iReceiveTotal - NetMetric.total(0);
     
    12251172    NetMetric.setTotal(1, iTransmitTotal);
    12261173
     1174    /* Do not set data and maximum if the timer has just started since we need to initialize totals "(t-1)" first: */
     1175    if (m_iTimeStep <= 1)
     1176        return;
    12271177    NetMetric.addData(0, iReceiveRate);
    12281178    NetMetric.addData(1, iTransmitRate);
    12291179    qulonglong iMaximum = qMax(NetMetric.maximum(), qMax(iReceiveRate, iTransmitRate));
    12301180    NetMetric.setMaximum(iMaximum);
     1181
     1182    if (m_infoLabels.contains(m_strNetworkMetricName)  && m_infoLabels[m_strNetworkMetricName])
     1183    {
     1184        QString strInfo;
     1185        QString strReceiveColor;
     1186        if (m_infoLabels[m_strNetworkMetricName]->isEnabled())
     1187            strInfo = QString("<b>%1</b></b><br/><font color=\"%2\">%3: %4<br/>%5 %6</font><br/><font color=\"%7\">%8: %9<br/>%10 %11</font>")
     1188                .arg(m_strNetworkInfoLabelTitle)
     1189                .arg(dataColorString(m_strNetworkMetricName, 0)).arg(m_strNetworkInfoLabelReceived).arg(uiCommon().formatSize((quint64)iReceiveRate, iDecimalCount))
     1190                .arg(m_strNetworkInfoLabelReceivedTotal).arg(uiCommon().formatSize((quint64)iReceiveTotal, iDecimalCount))
     1191                .arg(dataColorString(m_strNetworkMetricName, 1)).arg(m_strNetworkInfoLabelTransmitted).arg(uiCommon().formatSize((quint64)iTransmitRate, iDecimalCount))
     1192                .arg(m_strNetworkInfoLabelTransmittedTotal).arg(uiCommon().formatSize((quint64)iTransmitTotal, iDecimalCount));
     1193
     1194        else
     1195            strInfo = QString("<b>%1</b><br/>%2: %3<br/>%4: %5").
     1196                arg(m_strNetworkInfoLabelTitle)
     1197                .arg(m_strNetworkInfoLabelReceived).arg("---")
     1198                .arg(m_strNetworkInfoLabelTransmitted).arg("---");
     1199        m_infoLabels[m_strNetworkMetricName]->setText(strInfo);
     1200    }
     1201    if (m_charts.contains(m_strNetworkMetricName))
     1202        m_charts[m_strNetworkMetricName]->update();
    12311203
    12321204}
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/information/UIInformationRuntime.h

    r80406 r80409  
    151151    void updateCPUGraphsAndMetric(ULONG iLoadPercentage, ULONG iOtherPercentage);
    152152    void updateRAMGraphsAndMetric(quint64 iTotalRAM, quint64 iFreeRAM);
    153     void updateNetworkGraphsAndMetric(qulonglong iReceiveRate, qulonglong iTransmitRate);
    154153    void updateNetworkDebuggerGraphsAndMetric(qulonglong iReceiveTotal, qulonglong iTransmitTotal);
    155154
     
    183182        QString m_strRAMMetricName;
    184183        QString m_strDiskMetricName;
    185         QString m_strNetMetricName;
    186         QString m_strNetDebuggerMetricName;
     184        QString m_strNetworkMetricName;
    187185    /** @} */
    188186
     
    199197        QString m_strRAMInfoLabelUsed;
    200198        /** Net traffic info label strings. */
    201         QString m_strNetInfoLabelTitle;
    202         QString m_strNetInfoLabelReceived;
    203         QString m_strNetInfoLabelTransmitted;
    204         QString m_strNetInfoLabelMaximum;
     199        QString m_strNetworkInfoLabelTitle;
     200        QString m_strNetworkInfoLabelReceived;
     201        QString m_strNetworkInfoLabelTransmitted;
     202        QString m_strNetworkInfoLabelReceivedTotal;
     203        QString m_strNetworkInfoLabelTransmittedTotal;
    205204    /** @} */
    206205    /** The following string is used while querrying CMachineDebugger. */
    207206    QString m_strQueryString;
     207    qulonglong m_iTimeStep;
    208208};
    209209
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette