Skip to content

Commit 7083ceb

Browse files
committed
Added support of live plotting
Kernel and user cpu utilization shown...
1 parent 4691773 commit 7083ceb

File tree

9 files changed

+37639
-50
lines changed

9 files changed

+37639
-50
lines changed

build_android/QtApp-debug.apk

367 KB
Binary file not shown.

build_win32/ADB_Task_Manager.exe

885 KB
Binary file not shown.

src/ADB_Task_Manager.pro

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#-------------------------------------------------
66

77
QT += core gui
8+
QT += printsupport
89

910
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
1011

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

2122
SOURCES += main.cpp\
22-
MainWindow.cpp
23+
MainWindow.cpp \
24+
qcustomplot.cpp
2325

24-
HEADERS += MainWindow.h
26+
HEADERS += MainWindow.h \
27+
qcustomplot.h
2528

2629
FORMS += MainWindow.ui
2730

src/ADB_Task_Manager.pro.user

Lines changed: 50 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<!DOCTYPE QtCreatorProject>
3-
<!-- Written by QtCreator 3.5.1, 2016-11-02T16:48:47. -->
3+
<!-- Written by QtCreator 3.5.1, 2016-11-03T16:41:21. -->
44
<qtcreator>
55
<data>
66
<variable>EnvironmentId</variable>
77
<value type="QByteArray">{08b7feb7-0683-4149-8a05-cbfaf2a6e8ee}</value>
88
</data>
99
<data>
1010
<variable>ProjectExplorer.Project.ActiveTarget</variable>
11-
<value type="int">0</value>
11+
<value type="int">1</value>
1212
</data>
1313
<data>
1414
<variable>ProjectExplorer.Project.EditorSettings</variable>
@@ -252,7 +252,7 @@
252252
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">{44fb8ce9-7092-4d44-91dc-281ff9132f82}</value>
253253
<value type="int" key="ProjectExplorer.Target.ActiveBuildConfiguration">1</value>
254254
<value type="int" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value>
255-
<value type="int" key="ProjectExplorer.Target.ActiveRunConfiguration">-1</value>
255+
<value type="int" key="ProjectExplorer.Target.ActiveRunConfiguration">0</value>
256256
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.0">
257257
<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>
258258
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
@@ -433,7 +433,53 @@
433433
<valuemap type="QVariantMap" key="ProjectExplorer.Target.PluginSettings">
434434
<value type="QString" key="AndroidDeviceSerialNumber">0000045600000123</value>
435435
</valuemap>
436-
<value type="int" key="ProjectExplorer.Target.RunConfigurationCount">0</value>
436+
<valuemap type="QVariantMap" key="ProjectExplorer.Target.RunConfiguration.0">
437+
<valuelist type="QVariantList" key="Analyzer.Valgrind.AddedSuppressionFiles"/>
438+
<value type="bool" key="Analyzer.Valgrind.Callgrind.CollectBusEvents">false</value>
439+
<value type="bool" key="Analyzer.Valgrind.Callgrind.CollectSystime">false</value>
440+
<value type="bool" key="Analyzer.Valgrind.Callgrind.EnableBranchSim">false</value>
441+
<value type="bool" key="Analyzer.Valgrind.Callgrind.EnableCacheSim">false</value>
442+
<value type="bool" key="Analyzer.Valgrind.Callgrind.EnableEventToolTips">true</value>
443+
<value type="double" key="Analyzer.Valgrind.Callgrind.MinimumCostRatio">0.01</value>
444+
<value type="double" key="Analyzer.Valgrind.Callgrind.VisualisationMinimumCostRatio">10</value>
445+
<value type="bool" key="Analyzer.Valgrind.FilterExternalIssues">true</value>
446+
<value type="int" key="Analyzer.Valgrind.LeakCheckOnFinish">1</value>
447+
<value type="int" key="Analyzer.Valgrind.NumCallers">25</value>
448+
<valuelist type="QVariantList" key="Analyzer.Valgrind.RemovedSuppressionFiles"/>
449+
<value type="int" key="Analyzer.Valgrind.SelfModifyingCodeDetection">1</value>
450+
<value type="bool" key="Analyzer.Valgrind.Settings.UseGlobalSettings">true</value>
451+
<value type="bool" key="Analyzer.Valgrind.ShowReachable">false</value>
452+
<value type="bool" key="Analyzer.Valgrind.TrackOrigins">true</value>
453+
<value type="QString" key="Analyzer.Valgrind.ValgrindExecutable">valgrind</value>
454+
<valuelist type="QVariantList" key="Analyzer.Valgrind.VisibleErrorKinds">
455+
<value type="int">0</value>
456+
<value type="int">1</value>
457+
<value type="int">2</value>
458+
<value type="int">3</value>
459+
<value type="int">4</value>
460+
<value type="int">5</value>
461+
<value type="int">6</value>
462+
<value type="int">7</value>
463+
<value type="int">8</value>
464+
<value type="int">9</value>
465+
<value type="int">10</value>
466+
<value type="int">11</value>
467+
<value type="int">12</value>
468+
<value type="int">13</value>
469+
<value type="int">14</value>
470+
</valuelist>
471+
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">ADB_Task_Manager</value>
472+
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
473+
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.AndroidRunConfiguration:G:/PD/Devleopment/Projects/Qt/ADB_Task_Manager/ADB_Task_Manager.pro</value>
474+
<value type="QString" key="QMakeProjectManager.QmakeAndroidRunConfiguration.ProFile">ADB_Task_Manager.pro</value>
475+
<value type="uint" key="RunConfiguration.QmlDebugServerPort">3768</value>
476+
<value type="bool" key="RunConfiguration.UseCppDebugger">false</value>
477+
<value type="bool" key="RunConfiguration.UseCppDebuggerAuto">true</value>
478+
<value type="bool" key="RunConfiguration.UseMultiProcess">false</value>
479+
<value type="bool" key="RunConfiguration.UseQmlDebugger">false</value>
480+
<value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">true</value>
481+
</valuemap>
482+
<value type="int" key="ProjectExplorer.Target.RunConfigurationCount">1</value>
437483
</valuemap>
438484
</data>
439485
<data>

src/MainWindow.cpp

Lines changed: 43 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
2+
3+
4+
15
#include "MainWindow.h"
26
#include "ui_MainWindow.h"
37

@@ -8,7 +12,6 @@ thread_local int tid=++threads;
812
913
1014
11-
1215
void setDataset(QTableWidget *tb,auto &&ll)
1316
{
1417
tb->setRowCount(0);
@@ -40,6 +43,21 @@ MainWindow::MainWindow(QWidget *parent) :
4043
ui->tableWidget->setColumnCount(header.size());
4144
ui->tableWidget->setHorizontalHeaderLabels(header);
4245
46+
47+
ui->Perf->xAxis->setLabel("Time -> ");
48+
ui->Perf->yAxis->setLabel("Cpu util %");
49+
ui->Perf->xAxis->setRange(1,mxX);
50+
ui->Perf->yAxis->setRange(0,100.0);
51+
52+
ui->Perf->addGraph(ui->Perf->xAxis,ui->Perf->yAxis);
53+
ui->Perf->graph(0)->setBrush(QColor(100,100,255,100));
54+
ui->Perf->graph(0)->setName("Total");
55+
56+
ui->Perf->addGraph(ui->Perf->xAxis,ui->Perf->yAxis);
57+
ui->Perf->graph(1)->setBrush(QColor(0,0,255,100));
58+
ui->Perf->graph(1)->setName("Kernel");
59+
60+
4361
g
4462
ipc=std::thread ([&]
4563
{
@@ -63,7 +81,7 @@ MainWindow::MainWindow(QWidget *parent) :
6381
qDebug()<<qtop->state()<<":"<<cmd.str().data();
6482
6583
}
66-
84+
6785
6886
QString ln;
6987
{
@@ -76,16 +94,21 @@ MainWindow::MainWindow(QWidget *parent) :
7694
ln=qtop->readLine();
7795
}
7896
bool isBlank=ln.trimmed().isEmpty();
79-
// qDebug()<<ln<<" vs "<<isBlank;
80-
// qDebug()<<"Mode begin :"<<mode;
97+
// qDebug()<<ln<<" vs "<<isBlank;
98+
// qDebug()<<"Mode begin :"<<mode;
8199
82100
switch(mode)
83101
{
84102
case 0 :
85-
if(not isBlank)
86-
mode=(mode+1)%4;
87-
else
103+
if(isBlank)
88104
break;
105+
else
106+
{
107+
mode=(mode+1)%4;
108+
auto &&row=ln.split(QRegExp("\\s+|%|,"),QString::SkipEmptyParts);
109+
u_u=row[1].toInt();//stoi(row[1].toStdString());
110+
s_u=row[3].toInt();//stoi(row[3].toStdString());
111+
}
89112
case 1 :
90113
bl=ln;
91114
mode=(mode+1)%4;
@@ -107,7 +130,13 @@ MainWindow::MainWindow(QWidget *parent) :
107130
mode=(mode+1)%4;
108131
QMetaObject::invokeMethod(ui->tableWidget,"cellActivated",
109132
Qt::QueuedConnection,Q_ARG(int,-1),Q_ARG(int,-1));
110-
133+
if(ks.size()<mxX)
134+
ks.push_back(ks.size()+1);
135+
vs[0].push_back((double)u_u+s_u);
136+
vs[1].push_back((double)s_u);
137+
while(vs[0].size()>mxX)
138+
for(auto &vl:vs)
139+
vl.pop_front();
111140
sem.acquire();
112141
ll.clear();
113142
}
@@ -145,11 +174,16 @@ void MainWindow::on_tableWidget_cellActivated(int row, int column)
145174
if(row < 0 and column < 0 and running)
146175
{
147176
setDataset(ui->tableWidget,ll);
148-
149177
150178
ui->tableWidget->resizeColumnsToContents();
151179
ui->tableWidget->resizeRowsToContents();
152180
ui->statusBar->showMessage(bl);
181+
182+
for(size_t i=0;i<sizeof(vs)/sizeof(vs[0]);i++)
183+
ui->Perf->graph(i)->setData(ks,vs[i],true);
184+
185+
ui->Perf->replot();
186+
153187
sem.release();
154188
}
155189
}

src/MainWindow.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
#include <QProcess>
1515
#include <QSemaphore>
1616

17+
#include "qcustomplot.h"
18+
1719
using namespace std;
1820
namespace Ui {
1921
class MainWindow;
@@ -27,7 +29,7 @@ class MainWindow : public QMainWindow
2729
explicit MainWindow(QWidget *parent = 0);
2830
~MainWindow();
2931

30-
int m_nop,m_del;
32+
int m_nop,m_del,u_u,s_u,mxX=25;
3133
std::thread ipc;
3234
std::mutex mt;
3335
atomic<int> running,mode;
@@ -37,6 +39,7 @@ class MainWindow : public QMainWindow
3739
QSemaphore sem;
3840
QString bl;
3941

42+
QVector<double> ks,vs[2];
4043
void restarttopProc();
4144
private slots:
4245
void on_tableWidget_cellActivated(int row, int column);

src/MainWindow.ui

Lines changed: 99 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -14,47 +14,104 @@
1414
<string>MainWindow</string>
1515
</property>
1616
<widget class="QWidget" name="centralWidget">
17-
<layout class="QVBoxLayout" name="verticalLayout">
17+
<layout class="QVBoxLayout" name="verticalLayout" stretch="1,2">
18+
<property name="spacing">
19+
<number>2</number>
20+
</property>
21+
<property name="sizeConstraint">
22+
<enum>QLayout::SetDefaultConstraint</enum>
23+
</property>
24+
<property name="leftMargin">
25+
<number>0</number>
26+
</property>
27+
<property name="topMargin">
28+
<number>0</number>
29+
</property>
30+
<property name="rightMargin">
31+
<number>0</number>
32+
</property>
33+
<property name="bottomMargin">
34+
<number>0</number>
35+
</property>
1836
<item>
19-
<layout class="QGridLayout" name="gridLayout">
20-
<item row="0" column="0">
21-
<widget class="QLabel" name="label">
22-
<property name="text">
23-
<string>No of Process</string>
24-
</property>
25-
</widget>
26-
</item>
27-
<item row="0" column="1">
28-
<widget class="QSpinBox" name="nop">
29-
<property name="minimum">
30-
<number>1</number>
31-
</property>
32-
<property name="value">
33-
<number>5</number>
34-
</property>
35-
</widget>
36-
</item>
37-
<item row="1" column="0">
38-
<widget class="QLabel" name="label_2">
39-
<property name="text">
40-
<string>Delay</string>
41-
</property>
42-
</widget>
43-
</item>
44-
<item row="1" column="1">
45-
<widget class="QSpinBox" name="del">
46-
<property name="value">
47-
<number>1</number>
48-
</property>
49-
</widget>
50-
</item>
51-
</layout>
37+
<widget class="QTabWidget" name="tabWidget">
38+
<property name="currentIndex">
39+
<number>0</number>
40+
</property>
41+
<widget class="QWidget" name="Settings">
42+
<attribute name="title">
43+
<string>Settings</string>
44+
</attribute>
45+
<layout class="QGridLayout" name="gridLayout">
46+
<item row="1" column="1">
47+
<widget class="QSpinBox" name="del">
48+
<property name="value">
49+
<number>1</number>
50+
</property>
51+
</widget>
52+
</item>
53+
<item row="1" column="0">
54+
<widget class="QLabel" name="label_2">
55+
<property name="text">
56+
<string>Delay</string>
57+
</property>
58+
</widget>
59+
</item>
60+
<item row="0" column="1">
61+
<widget class="QSpinBox" name="nop">
62+
<property name="minimum">
63+
<number>1</number>
64+
</property>
65+
<property name="value">
66+
<number>5</number>
67+
</property>
68+
</widget>
69+
</item>
70+
<item row="0" column="0">
71+
<widget class="QLabel" name="label">
72+
<property name="text">
73+
<string>No of Process</string>
74+
</property>
75+
</widget>
76+
</item>
77+
</layout>
78+
</widget>
79+
<widget class="QCustomPlot" name="Perf">
80+
<attribute name="title">
81+
<string>Performance</string>
82+
</attribute>
83+
</widget>
84+
</widget>
5285
</item>
5386
<item>
5487
<widget class="QTableWidget" name="tableWidget">
88+
<property name="enabled">
89+
<bool>true</bool>
90+
</property>
91+
<property name="sizePolicy">
92+
<sizepolicy hsizetype="Expanding" vsizetype="MinimumExpanding">
93+
<horstretch>0</horstretch>
94+
<verstretch>0</verstretch>
95+
</sizepolicy>
96+
</property>
97+
<property name="minimumSize">
98+
<size>
99+
<width>0</width>
100+
<height>10</height>
101+
</size>
102+
</property>
103+
<property name="baseSize">
104+
<size>
105+
<width>0</width>
106+
<height>10</height>
107+
</size>
108+
</property>
55109
<property name="sortingEnabled">
56110
<bool>true</bool>
57111
</property>
112+
<property name="rowCount">
113+
<number>0</number>
114+
</property>
58115
<property name="columnCount">
59116
<number>10</number>
60117
</property>
@@ -87,6 +144,14 @@
87144
<widget class="QStatusBar" name="statusBar"/>
88145
</widget>
89146
<layoutdefault spacing="6" margin="11"/>
147+
<customwidgets>
148+
<customwidget>
149+
<class>QCustomPlot</class>
150+
<extends>QWidget</extends>
151+
<header location="global">QCustomPlot.h</header>
152+
<container>1</container>
153+
</customwidget>
154+
</customwidgets>
90155
<resources/>
91156
<connections/>
92157
</ui>

0 commit comments

Comments
 (0)