Also disable flame graphs in diff mode.
authorMilian Wolff <mail@milianw.de>
Fri, 17 Jun 2016 16:27:22 +0000 (18:27 +0200)
committerMilian Wolff <mail@milianw.de>
Fri, 17 Jun 2016 16:27:22 +0000 (18:27 +0200)
In the future, we may want to implement differential flame graphs,
but for now this is too much work.

gui/flamegraph.cpp
gui/mainwindow.cpp
gui/mainwindow.h

index c066189..4417fce 100644 (file)
@@ -225,11 +225,10 @@ void layoutItems(FrameGraphicsItem *parent)
     const qreal y_margin = 2.;
     const qreal y = pos.y() - h - y_margin;
     qreal x = pos.x();
-    // TODO: check this algorithm for differential flamegraphs
 
     foreach (auto child, parent->childItems()) {
         auto frameChild = static_cast<FrameGraphicsItem*>(child);
-        const qreal w = std::abs(maxWidth * double(frameChild->cost()) / parent->cost());
+        const qreal w = maxWidth * double(frameChild->cost()) / parent->cost();
         frameChild->setVisible(w > 1);
         if (frameChild->isVisible()) {
             frameChild->setRect(QRectF(x, y, w, h));
@@ -265,7 +264,7 @@ void toGraphicsItems(const QVector<RowData>& data, FrameGraphicsItem *parent, in
         } else {
             item->setCost(item->cost() + row.cost.*member);
         }
-        if (std::abs(item->cost()) > costThreshold) {
+        if (item->cost() > costThreshold) {
             toGraphicsItems(row.children, item, member, costThreshold);
         }
     }
@@ -322,7 +321,7 @@ FrameGraphicsItem* parseData(const QVector<RowData>& topDownData, CostType type,
     auto rootItem = new FrameGraphicsItem(totalCost, type, label);
     rootItem->setBrush(scheme.background());
     rootItem->setPen(pen);
-    toGraphicsItems(topDownData, rootItem, member, std::abs(totalCost) * costThreshold / 100.);
+    toGraphicsItems(topDownData, rootItem, member, totalCost * costThreshold / 100.);
     return rootItem;
 }
 
index 0c3a5de..a88107b 100644 (file)
@@ -116,7 +116,9 @@ MainWindow::MainWindow(QWidget* parent)
     connect(m_parser, &Parser::bottomUpDataAvailable,
             this, [=] (const TreeData& data) {
         bottomUpModel->resetData(data);
-        m_ui->flameGraphTab->setBottomUpData(data);
+        if (!m_diffMode) {
+            m_ui->flameGraphTab->setBottomUpData(data);
+        }
         m_ui->progressLabel->setAlignment(Qt::AlignVCenter | Qt::AlignRight);
         statusBar()->addWidget(m_ui->progressLabel, 1);
         statusBar()->addWidget(m_ui->loadingProgress);
@@ -130,9 +132,11 @@ MainWindow::MainWindow(QWidget* parent)
     connect(m_parser, &Parser::topDownDataAvailable,
             this, [=] (const TreeData& data) {
                 topDownModel->resetData(data);
-                m_ui->flameGraphTab->setTopDownData(data);
                 m_ui->tabWidget->setTabEnabled(m_ui->tabWidget->indexOf(m_ui->topDownTab), true);
-                m_ui->tabWidget->setTabEnabled(m_ui->tabWidget->indexOf(m_ui->flameGraphTab), true);
+                if (!m_diffMode) {
+                    m_ui->flameGraphTab->setTopDownData(data);
+                }
+                m_ui->tabWidget->setTabEnabled(m_ui->tabWidget->indexOf(m_ui->flameGraphTab), !m_diffMode);
             });
     connect(m_parser, &Parser::consumedChartDataAvailable,
             this, [=] (const ChartData& data) {
@@ -368,9 +372,11 @@ void MainWindow::loadFile(const QString& file, const QString& diffBase)
     if (diffBase.isEmpty()) {
         setWindowTitle(i18nc("%1: file name that is open", "Heaptrack - %1",
                              QFileInfo(file).fileName()));
+        m_diffMode = false;
     } else {
         setWindowTitle(i18nc("%1, %2: file names that are open", "Heaptrack - %1 compared to %2",
                              QFileInfo(file).fileName(), QFileInfo(diffBase).fileName()));
+        m_diffMode = true;
     }
     m_ui->pages->setCurrentWidget(m_ui->loadingPage);
     m_parser->parse(file, diffBase);
index 97084f2..faec3d3 100644 (file)
@@ -49,6 +49,7 @@ private:
     QScopedPointer<Ui::MainWindow> m_ui;
     Parser* m_parser;
     KSharedConfig::Ptr m_config;
+    bool m_diffMode = false;
 };
 
 #endif // MAINWINDOW_H