From 1311b0e8016c39da9dbb2cdea5ddd62f70315b0b Mon Sep 17 00:00:00 2001 From: Milian Wolff Date: Wed, 24 Feb 2016 01:58:06 +0100 Subject: [PATCH] Put summary text into three columns to save vertical space. --- gui/mainwindow.cpp | 40 ++++++++++++++++++++++++++++++++- gui/mainwindow.ui | 66 ++++++++++++++++++++++++++++++++++++------------------ gui/parser.cpp | 41 +++++++++++---------------------- gui/parser.h | 15 ++++++++++++- 4 files changed, 110 insertions(+), 52 deletions(-) diff --git a/gui/mainwindow.cpp b/gui/mainwindow.cpp index 05b14d6..0cdd8d0 100644 --- a/gui/mainwindow.cpp +++ b/gui/mainwindow.cpp @@ -147,7 +147,45 @@ MainWindow::MainWindow(QWidget* parent) m_ui->tabWidget->setTabEnabled(m_ui->tabWidget->indexOf(m_ui->sizesTab), true); }); connect(m_parser, &Parser::summaryAvailable, - m_ui->summary, &QLabel::setText); + this, [this] (const SummaryData& data) { + KFormat format; + QString textLeft; + QString textCenter; + QString textRight; + const double totalTimeS = 0.001 * data.totalTime; + const double peakTimeS = 0.001 * data.peakTime; + { + QTextStream stream(&textLeft); + stream << "
" + << i18n("
debuggee:
%1
", data.debuggee) + // xgettext:no-c-format + << i18n("
total runtime:
%1s
", totalTimeS) + << "
"; + } + { + QTextStream stream(&textCenter); + stream << "
" + << i18n("
calls to allocation functions:
%1 (%2/s)
", + data.allocations, quint64(data.allocations / totalTimeS)) + << i18n("
temporary allocations:
%1 (%2%, %3/s)
", + data.temporary, round(float(data.temporary) * 100.f * 100.f / data.allocations) / 100.f, + quint64(data.temporary / totalTimeS)) + << "
"; + } + { + QTextStream stream(&textRight); + stream << "
" + << i18n("
peak heap memory consumption:
%1 after %2s
", format.formatByteSize(data.peak), peakTimeS) + << i18n("
total memory leaked:
%1
", format.formatByteSize(data.leaked)) + << i18n("
bytes allocated in total (ignoring deallocations):
%1 (%2/s)
", + format.formatByteSize(data.allocated, 2), format.formatByteSize(data.allocated / totalTimeS)) + << "
"; + } + + m_ui->summaryLeft->setText(textLeft); + m_ui->summaryCenter->setText(textCenter); + m_ui->summaryRight->setText(textRight); + }); connect(m_parser, &Parser::progressMessageAvailable, m_ui->progressLabel, &QLabel::setText); auto removeProgress = [this] { diff --git a/gui/mainwindow.ui b/gui/mainwindow.ui index 0d42055..b8910f0 100644 --- a/gui/mainwindow.ui +++ b/gui/mainwindow.ui @@ -21,7 +21,8 @@ KMessageWidget::Information - + + .. @@ -114,21 +115,48 @@ - - - - 0 - 0 - - - - summary goes here - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop - - - true + + + + + + summary + + + + + + + summary + + + + + + + + 0 + 0 + + + + summary goes here + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + + true + + + + + + + + + + Qt::Horizontal @@ -302,12 +330,6 @@ - summary - widget_5 - widget_6 - widget_7 - widget_8 - widget_9 diff --git a/gui/parser.cpp b/gui/parser.cpp index ec44a78..fc24251 100644 --- a/gui/parser.cpp +++ b/gui/parser.cpp @@ -20,10 +20,8 @@ #include "parser.h" #include -#include #include -#include #include #include "../accumulatedtracedata.h" @@ -294,30 +292,6 @@ struct ParserData final : public AccumulatedTraceData bool buildCharts = false; }; -QString generateSummary(const ParserData& data) -{ - QString ret; - KFormat format; - QTextStream stream(&ret); - const double totalTimeS = 0.001 * data.totalTime; - const double peakTimeS = 0.001 * data.peakTime; - stream << "
" - << i18n("
debuggee:
%1
", QString::fromStdString(data.debuggee)) - // xgettext:no-c-format - << i18n("
total runtime:
%1s
", totalTimeS) - << i18n("
bytes allocated in total (ignoring deallocations):
%1 (%2/s)
", - format.formatByteSize(data.totalAllocated, 2), format.formatByteSize(data.totalAllocated / totalTimeS)) - << i18n("
calls to allocation functions:
%1 (%2/s)
", - data.totalAllocations, quint64(data.totalAllocations / totalTimeS)) - << i18n("
temporary allocations:
%1 (%2%, %3/s)
", - data.totalTemporary, round(float(data.totalTemporary) * 100.f * 100.f / data.totalAllocations) / 100.f, - quint64(data.totalTemporary / totalTimeS)) - << i18n("
peak heap memory consumption:
%1 after %2s
", format.formatByteSize(data.peak), peakTimeS) - << i18n("
total memory leaked:
%1
", format.formatByteSize(data.leaked)); - stream << "
"; - return ret; -} - void setParents(QVector& children, const RowData* parent) { for (auto& row: children) { @@ -486,7 +460,9 @@ HistogramData buildSizeHistogram(ParserData& data) Parser::Parser(QObject* parent) : QObject(parent) -{} +{ + qRegisterMetaType(); +} Parser::~Parser() = default; @@ -504,7 +480,16 @@ void Parser::parse(const QString& path) data->updateStringCache(); - emit summaryAvailable(generateSummary(*data)); + emit summaryAvailable({ + QString::fromStdString(data->debuggee), + data->totalTime, + data->peakTime, + data->peak, + data->leaked, + data->totalAllocations, + data->totalTemporary, + data->totalAllocated + }); emit progressMessageAvailable(i18n("merging allocations...")); // merge allocations before modifying the data again diff --git a/gui/parser.h b/gui/parser.h index 22e1eb6..0036371 100644 --- a/gui/parser.h +++ b/gui/parser.h @@ -26,6 +26,19 @@ #include "chartmodel.h" #include "histogrammodel.h" +struct SummaryData +{ + QString debuggee; + uint64_t totalTime; + uint64_t peakTime; + uint64_t peak; + uint64_t leaked; + uint64_t allocations; + uint64_t temporary; + uint64_t allocated; +}; +Q_DECLARE_METATYPE(SummaryData); + class Parser : public QObject { Q_OBJECT @@ -38,7 +51,7 @@ public slots: signals: void progressMessageAvailable(const QString& progress); - void summaryAvailable(const QString& summary); + void summaryAvailable(const SummaryData& summary); void bottomUpDataAvailable(const TreeData& data); void topDownDataAvailable(const TreeData& data); void consumedChartDataAvailable(const ChartData& data); -- 2.7.4