From: Milian Wolff Date: Fri, 17 Jun 2016 16:27:22 +0000 (+0200) Subject: Also disable flame graphs in diff mode. X-Git-Tag: submit/tizen/20180620.112952^2~165^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=867d2226a5994a2b84b6c4076c725459edb6fd18;p=sdk%2Ftools%2Fheaptrack.git Also disable flame graphs in diff mode. In the future, we may want to implement differential flame graphs, but for now this is too much work. --- diff --git a/gui/flamegraph.cpp b/gui/flamegraph.cpp index c066189..4417fce 100644 --- a/gui/flamegraph.cpp +++ b/gui/flamegraph.cpp @@ -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(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& 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& 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; } diff --git a/gui/mainwindow.cpp b/gui/mainwindow.cpp index 0c3a5de..a88107b 100644 --- a/gui/mainwindow.cpp +++ b/gui/mainwindow.cpp @@ -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); diff --git a/gui/mainwindow.h b/gui/mainwindow.h index 97084f2..faec3d3 100644 --- a/gui/mainwindow.h +++ b/gui/mainwindow.h @@ -49,6 +49,7 @@ private: QScopedPointer m_ui; Parser* m_parser; KSharedConfig::Ptr m_config; + bool m_diffMode = false; }; #endif // MAINWINDOW_H