Skip to content

Commit

Permalink
Added support of live plotting
Browse files Browse the repository at this point in the history
Kernel and user cpu utilization shown...
  • Loading branch information
pPanda-beta committed Nov 3, 2016
1 parent 4691773 commit 7083ceb
Show file tree
Hide file tree
Showing 9 changed files with 37,639 additions and 50 deletions.
Binary file modified build_android/QtApp-debug.apk
Binary file not shown.
Binary file modified build_win32/ADB_Task_Manager.exe
Binary file not shown.
7 changes: 5 additions & 2 deletions src/ADB_Task_Manager.pro
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#-------------------------------------------------

QT += core gui
QT += printsupport

greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

Expand All @@ -19,9 +20,11 @@ CONFIG += C++1y
QMAKE_LINK += -shared-libgcc

SOURCES += main.cpp\
MainWindow.cpp
MainWindow.cpp \
qcustomplot.cpp

HEADERS += MainWindow.h
HEADERS += MainWindow.h \
qcustomplot.h

FORMS += MainWindow.ui

Expand Down
54 changes: 50 additions & 4 deletions src/ADB_Task_Manager.pro.user
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject>
<!-- Written by QtCreator 3.5.1, 2016-11-02T16:48:47. -->
<!-- Written by QtCreator 3.5.1, 2016-11-03T16:41:21. -->
<qtcreator>
<data>
<variable>EnvironmentId</variable>
<value type="QByteArray">{08b7feb7-0683-4149-8a05-cbfaf2a6e8ee}</value>
</data>
<data>
<variable>ProjectExplorer.Project.ActiveTarget</variable>
<value type="int">0</value>
<value type="int">1</value>
</data>
<data>
<variable>ProjectExplorer.Project.EditorSettings</variable>
Expand Down Expand Up @@ -252,7 +252,7 @@
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">{44fb8ce9-7092-4d44-91dc-281ff9132f82}</value>
<value type="int" key="ProjectExplorer.Target.ActiveBuildConfiguration">1</value>
<value type="int" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value>
<value type="int" key="ProjectExplorer.Target.ActiveRunConfiguration">-1</value>
<value type="int" key="ProjectExplorer.Target.ActiveRunConfiguration">0</value>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.0">
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">G:/PD/Devleopment/Projects/Qt/build-ADB_Task_Manager-Android_for_armeabi_v7a_GCC_4_9_Qt_5_5_1-Debug</value>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
Expand Down Expand Up @@ -433,7 +433,53 @@
<valuemap type="QVariantMap" key="ProjectExplorer.Target.PluginSettings">
<value type="QString" key="AndroidDeviceSerialNumber">0000045600000123</value>
</valuemap>
<value type="int" key="ProjectExplorer.Target.RunConfigurationCount">0</value>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.RunConfiguration.0">
<valuelist type="QVariantList" key="Analyzer.Valgrind.AddedSuppressionFiles"/>
<value type="bool" key="Analyzer.Valgrind.Callgrind.CollectBusEvents">false</value>
<value type="bool" key="Analyzer.Valgrind.Callgrind.CollectSystime">false</value>
<value type="bool" key="Analyzer.Valgrind.Callgrind.EnableBranchSim">false</value>
<value type="bool" key="Analyzer.Valgrind.Callgrind.EnableCacheSim">false</value>
<value type="bool" key="Analyzer.Valgrind.Callgrind.EnableEventToolTips">true</value>
<value type="double" key="Analyzer.Valgrind.Callgrind.MinimumCostRatio">0.01</value>
<value type="double" key="Analyzer.Valgrind.Callgrind.VisualisationMinimumCostRatio">10</value>
<value type="bool" key="Analyzer.Valgrind.FilterExternalIssues">true</value>
<value type="int" key="Analyzer.Valgrind.LeakCheckOnFinish">1</value>
<value type="int" key="Analyzer.Valgrind.NumCallers">25</value>
<valuelist type="QVariantList" key="Analyzer.Valgrind.RemovedSuppressionFiles"/>
<value type="int" key="Analyzer.Valgrind.SelfModifyingCodeDetection">1</value>
<value type="bool" key="Analyzer.Valgrind.Settings.UseGlobalSettings">true</value>
<value type="bool" key="Analyzer.Valgrind.ShowReachable">false</value>
<value type="bool" key="Analyzer.Valgrind.TrackOrigins">true</value>
<value type="QString" key="Analyzer.Valgrind.ValgrindExecutable">valgrind</value>
<valuelist type="QVariantList" key="Analyzer.Valgrind.VisibleErrorKinds">
<value type="int">0</value>
<value type="int">1</value>
<value type="int">2</value>
<value type="int">3</value>
<value type="int">4</value>
<value type="int">5</value>
<value type="int">6</value>
<value type="int">7</value>
<value type="int">8</value>
<value type="int">9</value>
<value type="int">10</value>
<value type="int">11</value>
<value type="int">12</value>
<value type="int">13</value>
<value type="int">14</value>
</valuelist>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">ADB_Task_Manager</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.AndroidRunConfiguration:G:/PD/Devleopment/Projects/Qt/ADB_Task_Manager/ADB_Task_Manager.pro</value>
<value type="QString" key="QMakeProjectManager.QmakeAndroidRunConfiguration.ProFile">ADB_Task_Manager.pro</value>
<value type="uint" key="RunConfiguration.QmlDebugServerPort">3768</value>
<value type="bool" key="RunConfiguration.UseCppDebugger">false</value>
<value type="bool" key="RunConfiguration.UseCppDebuggerAuto">true</value>
<value type="bool" key="RunConfiguration.UseMultiProcess">false</value>
<value type="bool" key="RunConfiguration.UseQmlDebugger">false</value>
<value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">true</value>
</valuemap>
<value type="int" key="ProjectExplorer.Target.RunConfigurationCount">1</value>
</valuemap>
</data>
<data>
Expand Down
52 changes: 43 additions & 9 deletions src/MainWindow.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@




#include "MainWindow.h"
#include "ui_MainWindow.h"

Expand All @@ -8,7 +12,6 @@ thread_local int tid=++threads;
void setDataset(QTableWidget *tb,auto &&ll)
{
tb->setRowCount(0);
Expand Down Expand Up @@ -40,6 +43,21 @@ MainWindow::MainWindow(QWidget *parent) :
ui->tableWidget->setColumnCount(header.size());
ui->tableWidget->setHorizontalHeaderLabels(header);
ui->Perf->xAxis->setLabel("Time -> ");
ui->Perf->yAxis->setLabel("Cpu util %");
ui->Perf->xAxis->setRange(1,mxX);
ui->Perf->yAxis->setRange(0,100.0);
ui->Perf->addGraph(ui->Perf->xAxis,ui->Perf->yAxis);
ui->Perf->graph(0)->setBrush(QColor(100,100,255,100));
ui->Perf->graph(0)->setName("Total");
ui->Perf->addGraph(ui->Perf->xAxis,ui->Perf->yAxis);
ui->Perf->graph(1)->setBrush(QColor(0,0,255,100));
ui->Perf->graph(1)->setName("Kernel");
g
ipc=std::thread ([&]
{
Expand All @@ -63,7 +81,7 @@ MainWindow::MainWindow(QWidget *parent) :
qDebug()<<qtop->state()<<":"<<cmd.str().data();
}
QString ln;
{
Expand All @@ -76,16 +94,21 @@ MainWindow::MainWindow(QWidget *parent) :
ln=qtop->readLine();
}
bool isBlank=ln.trimmed().isEmpty();
// qDebug()<<ln<<" vs "<<isBlank;
// qDebug()<<"Mode begin :"<<mode;
// qDebug()<<ln<<" vs "<<isBlank;
// qDebug()<<"Mode begin :"<<mode;
switch(mode)
{
case 0 :
if(not isBlank)
mode=(mode+1)%4;
else
if(isBlank)
break;
else
{
mode=(mode+1)%4;
auto &&row=ln.split(QRegExp("\\s+|%|,"),QString::SkipEmptyParts);
u_u=row[1].toInt();//stoi(row[1].toStdString());
s_u=row[3].toInt();//stoi(row[3].toStdString());
}
case 1 :
bl=ln;
mode=(mode+1)%4;
Expand All @@ -107,7 +130,13 @@ MainWindow::MainWindow(QWidget *parent) :
mode=(mode+1)%4;
QMetaObject::invokeMethod(ui->tableWidget,"cellActivated",
Qt::QueuedConnection,Q_ARG(int,-1),Q_ARG(int,-1));
if(ks.size()<mxX)
ks.push_back(ks.size()+1);
vs[0].push_back((double)u_u+s_u);
vs[1].push_back((double)s_u);
while(vs[0].size()>mxX)
for(auto &vl:vs)
vl.pop_front();
sem.acquire();
ll.clear();
}
Expand Down Expand Up @@ -145,11 +174,16 @@ void MainWindow::on_tableWidget_cellActivated(int row, int column)
if(row < 0 and column < 0 and running)
{
setDataset(ui->tableWidget,ll);
ui->tableWidget->resizeColumnsToContents();
ui->tableWidget->resizeRowsToContents();
ui->statusBar->showMessage(bl);
for(size_t i=0;i<sizeof(vs)/sizeof(vs[0]);i++)
ui->Perf->graph(i)->setData(ks,vs[i],true);
ui->Perf->replot();
sem.release();
}
}
Expand Down
5 changes: 4 additions & 1 deletion src/MainWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
#include <QProcess>
#include <QSemaphore>

#include "qcustomplot.h"

using namespace std;
namespace Ui {
class MainWindow;
Expand All @@ -27,7 +29,7 @@ class MainWindow : public QMainWindow
explicit MainWindow(QWidget *parent = 0);
~MainWindow();

int m_nop,m_del;
int m_nop,m_del,u_u,s_u,mxX=25;
std::thread ipc;
std::mutex mt;
atomic<int> running,mode;
Expand All @@ -37,6 +39,7 @@ class MainWindow : public QMainWindow
QSemaphore sem;
QString bl;

QVector<double> ks,vs[2];
void restarttopProc();
private slots:
void on_tableWidget_cellActivated(int row, int column);
Expand Down
133 changes: 99 additions & 34 deletions src/MainWindow.ui
Original file line number Diff line number Diff line change
Expand Up @@ -14,47 +14,104 @@
<string>MainWindow</string>
</property>
<widget class="QWidget" name="centralWidget">
<layout class="QVBoxLayout" name="verticalLayout">
<layout class="QVBoxLayout" name="verticalLayout" stretch="1,2">
<property name="spacing">
<number>2</number>
</property>
<property name="sizeConstraint">
<enum>QLayout::SetDefaultConstraint</enum>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>No of Process</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QSpinBox" name="nop">
<property name="minimum">
<number>1</number>
</property>
<property name="value">
<number>5</number>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Delay</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QSpinBox" name="del">
<property name="value">
<number>1</number>
</property>
</widget>
</item>
</layout>
<widget class="QTabWidget" name="tabWidget">
<property name="currentIndex">
<number>0</number>
</property>
<widget class="QWidget" name="Settings">
<attribute name="title">
<string>Settings</string>
</attribute>
<layout class="QGridLayout" name="gridLayout">
<item row="1" column="1">
<widget class="QSpinBox" name="del">
<property name="value">
<number>1</number>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Delay</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QSpinBox" name="nop">
<property name="minimum">
<number>1</number>
</property>
<property name="value">
<number>5</number>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>No of Process</string>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QCustomPlot" name="Perf">
<attribute name="title">
<string>Performance</string>
</attribute>
</widget>
</widget>
</item>
<item>
<widget class="QTableWidget" name="tableWidget">
<property name="enabled">
<bool>true</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>10</height>
</size>
</property>
<property name="baseSize">
<size>
<width>0</width>
<height>10</height>
</size>
</property>
<property name="sortingEnabled">
<bool>true</bool>
</property>
<property name="rowCount">
<number>0</number>
</property>
<property name="columnCount">
<number>10</number>
</property>
Expand Down Expand Up @@ -87,6 +144,14 @@
<widget class="QStatusBar" name="statusBar"/>
</widget>
<layoutdefault spacing="6" margin="11"/>
<customwidgets>
<customwidget>
<class>QCustomPlot</class>
<extends>QWidget</extends>
<header location="global">QCustomPlot.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>
Loading

0 comments on commit 7083ceb

Please sign in to comment.