diff --git a/sdrgui/gui/profiledialog.cpp b/sdrgui/gui/profiledialog.cpp index 24f319a1c..70934bb40 100644 --- a/sdrgui/gui/profiledialog.cpp +++ b/sdrgui/gui/profiledialog.cpp @@ -15,6 +15,8 @@ // along with this program. If not, see . // /////////////////////////////////////////////////////////////////////////////////// +#include + #include #include "profiledialog.h" @@ -57,6 +59,7 @@ void ProfileDialog::resizeTable() ui->table->setRowCount(row + 1); ui->table->setItem(row, COL_NAME, new QTableWidgetItem("Random-SDR[0] Spectrum @12345678910")); ui->table->setItem(row, COL_TOTAL, new QTableWidgetItem("1000.000 ms")); + ui->table->setItem(row, COL_PERCENT, new QTableWidgetItem("100.0")); ui->table->setItem(row, COL_AVERAGE, new QTableWidgetItem("1000.000 ns/frame")); ui->table->setItem(row, COL_LAST, new QTableWidgetItem("1000.000 ms")); ui->table->setItem(row, COL_MAX, new QTableWidgetItem("1000.000 ms")); @@ -69,6 +72,7 @@ void ProfileDialog::resizeTable() void ProfileDialog::updateData() { QHash& profileData = GlobalProfileData::getProfileData(); + const double runTime = GlobalProfileData::getMSSinceStart() * 1e6; // ns QHashIterator itr(profileData); @@ -81,6 +85,7 @@ void ProfileDialog::updateData() double averageTime = data.getAverage(); double lastTime = data.getLast(); double maxTime = data.getMax(); + double percent = runTime > 0.0 ? std::round(1000.0 * totalTime / runTime) / 10.0 : 0.0; int i = 0; for (; i < ui->table->rowCount(); i++) @@ -90,6 +95,7 @@ void ProfileDialog::updateData() { // Update existing row ui->table->item(i, COL_TOTAL)->setData(Qt::DisplayRole, totalTime); + ui->table->item(i, COL_PERCENT)->setData(Qt::DisplayRole, percent); ui->table->item(i, COL_AVERAGE)->setData(Qt::DisplayRole, averageTime); ui->table->item(i, COL_LAST)->setData(Qt::DisplayRole, lastTime); ui->table->item(i, COL_MAX)->setData(Qt::DisplayRole, maxTime); @@ -106,6 +112,7 @@ void ProfileDialog::updateData() QTableWidgetItem *name = new QTableWidgetItem(key); QTableWidgetItem *total = new QTableWidgetItem(); + QTableWidgetItem *percentItem = new QTableWidgetItem(); QTableWidgetItem *average = new QTableWidgetItem(); QTableWidgetItem *last = new QTableWidgetItem(); QTableWidgetItem *max = new QTableWidgetItem(); @@ -113,18 +120,21 @@ void ProfileDialog::updateData() ui->table->setItem(row, COL_NAME, name); ui->table->setItem(row, COL_TOTAL, total); + ui->table->setItem(row, COL_PERCENT, percentItem); ui->table->setItem(row, COL_AVERAGE, average); ui->table->setItem(row, COL_LAST, last); ui->table->setItem(row, COL_MAX, max); ui->table->setItem(row, COL_NUM_SAMPLES, numSamples); total->setTextAlignment(Qt::AlignRight | Qt::AlignVCenter); + percentItem->setTextAlignment(Qt::AlignRight | Qt::AlignVCenter); average->setTextAlignment(Qt::AlignRight | Qt::AlignVCenter); last->setTextAlignment(Qt::AlignRight | Qt::AlignVCenter); max->setTextAlignment(Qt::AlignRight | Qt::AlignVCenter); numSamples->setTextAlignment(Qt::AlignRight | Qt::AlignVCenter); total->setData(Qt::DisplayRole, totalTime); + percentItem->setData(Qt::DisplayRole, percent); average->setData(Qt::DisplayRole, averageTime); last->setData(Qt::DisplayRole, lastTime); max->setData(Qt::DisplayRole, maxTime); diff --git a/sdrgui/gui/profiledialog.h b/sdrgui/gui/profiledialog.h index 9cd2c2a04..397fbbb6f 100644 --- a/sdrgui/gui/profiledialog.h +++ b/sdrgui/gui/profiledialog.h @@ -50,6 +50,7 @@ private: enum Cols { COL_NAME, COL_TOTAL, + COL_PERCENT, COL_AVERAGE, COL_LAST, COL_MAX, diff --git a/sdrgui/gui/profiledialog.ui b/sdrgui/gui/profiledialog.ui index defb724a3..4ec22beb8 100644 --- a/sdrgui/gui/profiledialog.ui +++ b/sdrgui/gui/profiledialog.ui @@ -77,6 +77,14 @@ Total time spent executing the code + + + % Runtime + + + Total time as a percentage of the run time: the share of a core used, for code in one thread + + Average