Merge branch 'power_and_buffer_analysis' into 'develop'

Power and buffer analysis

See merge request ems/astdm/dram.sys!271
This commit is contained in:
Lukas Steiner
2020-11-23 14:51:34 +01:00
4 changed files with 203 additions and 4 deletions

View File

@@ -101,7 +101,7 @@ def plot(function):
return function
@plot
#@plot
def memory_utilisation_window(connection, tracePath, steps):
# This function determines the average memory bandwidth over time in
# percentage and in Gbit/s. The average bandwidth over time is done
@@ -246,7 +246,7 @@ def queue_window(connection, tracePath, steps):
return outputFile
@plot
#@plot
def power_window(connection, tracePath, steps):
windowSize = getWindowSize(connection)
@@ -340,7 +340,7 @@ def latency_analysis(connection, tracePath, steps):
return "none\n"
@plot
#@plot
def latency_histogram(connection, tracePath, steps):
# This function plots an histogram with access latencys

View File

@@ -45,6 +45,14 @@
#include <QString>
#include <QItemDelegate>
#include "qwt_plot_histogram.h"
#include "qwt_plot_curve.h"
#include "qwt_plot_layout.h"
#include "qwt_scale_draw.h"
#include "qwt_scale_widget.h"
#include "qwt_legend.h"
#include "qwt_plot_magnifier.h"
#include "qwt_plot_panner.h"
#include <math.h>
TraceFileTab::TraceFileTab(QWidget *parent, const QString &path) :
@@ -223,3 +231,121 @@ void TraceFileTab::on_startLatencyAnalysis_clicked()
ui->latencyPlot->setAxisTitle( QwtPlot::xBottom, axisTitle );
ui->latencyPlot->replot();
}
void TraceFileTab::on_startPowerAnalysis_clicked()
{
qDebug() << "Power Analysis";
QSqlDatabase db = navigator->TraceFile().getDatabase();
QSqlQuery query(db);
QString sql = "SELECT time, AveragePower FROM Power;";
query.exec(sql);
QwtPointSeriesData * data = new QwtPointSeriesData;
QwtPlotCurve * cur = new QwtPlotCurve("Speed");
QVector<QPointF>* samples=new QVector<QPointF>;
while (query.next()) {
double time = query.value(0).toDouble();
double power = query.value(1).toDouble();
samples->push_back(QPointF(time,power));
}
//ui->powerPlot->setAxisTitle(QwtPlot::xBottom,"Time");
//ui->powerPlot->setAxisLabelRotation(QwtPlot::xBottom,-50.0);
//ui->powerPlot->setAxisLabelAlignment(QwtPlot::xBottom,Qt::AlignLeft|Qt::AlignBottom);
//ui->powerPlot->setAxisTitle(QwtPlot::yLeft,"Power");
data->setSamples(*samples);
cur->setData(data);
cur->attach(ui->powerPlot);
QwtPlotMagnifier *mag1 = new QwtPlotMagnifier(ui->powerPlot->canvas());
mag1->setAxisEnabled(QwtPlot::xBottom, true);
mag1->setAxisEnabled(QwtPlot::yLeft, false);
mag1->setWheelFactor(5);
QwtPlotPanner *pan1 = new QwtPlotPanner(ui->powerPlot->canvas());
pan1->setAxisEnabled(QwtPlot::xBottom, true);
pan1->setAxisEnabled(QwtPlot::yLeft, false);
ui->powerPlot->replot();
// Bandwidth analysis:
sql = "SELECT time, AverageBandwidth FROM Bandwidth;";
query.exec(sql);
QwtPointSeriesData * data2 = new QwtPointSeriesData;
QwtPlotCurve * cur2 = new QwtPlotCurve("Speed");
QVector<QPointF>* samples2=new QVector<QPointF>;
while (query.next()) {
double time = query.value(0).toDouble();
double percentage = query.value(1).toDouble() * 100.0;
samples2->push_back(QPointF(time, percentage));
}
data2->setSamples(*samples2);
cur2->setData(data2);
cur2->attach(ui->bandwidthPlot);
ui->bandwidthPlot->setAxisTitle(0,"Bandwidth [%]");
ui->bandwidthPlot->setAxisScale(0,0.0,100.0);
QwtText axisTitle2( "Time [s]" );
axisTitle2.setFont( ui->bandwidthPlot->axisTitle( QwtPlot::xBottom ).font() );
ui->bandwidthPlot->setAxisTitle( QwtPlot::xBottom, axisTitle2 );
QwtPlotMagnifier *mag2 = new QwtPlotMagnifier(ui->bandwidthPlot->canvas());
mag2->setAxisEnabled(QwtPlot::xBottom, true);
mag2->setAxisEnabled(QwtPlot::yLeft, false);
mag2->setWheelFactor(5);
QwtPlotPanner *pan2 = new QwtPlotPanner(ui->bandwidthPlot->canvas());
pan2->setAxisEnabled(QwtPlot::xBottom, true);
pan2->setAxisEnabled(QwtPlot::yLeft, false);
ui->bandwidthPlot->replot();
// Buffer analysis:
sql = "select max(BufferNumber) from BufferDepth;";
query.exec(sql);
query.next();
unsigned int numberOfBuffers = query.value(0).toUInt();
sql = "select MaxBufferDepth from GeneralInfo;";
query.exec(sql);
query.next();
unsigned int maxBufferDepth = query.value(0).toUInt();
sql = "select Time, AverageBufferDepth from BufferDepth where BufferNumber = 0"; // TODO
query.exec(sql);
QwtPointSeriesData * data3 = new QwtPointSeriesData;
QwtPlotCurve * cur3 = new QwtPlotCurve("Speed");
QVector<QPointF>* samples3 = new QVector<QPointF>;
while (query.next()) {
double time = query.value(0).toDouble();
double queue = query.value(1).toDouble();
samples3->push_back(QPointF(time, queue));
}
data3->setSamples(*samples3);
cur3->setData(data3);
cur3->attach(ui->bufferPlot);
ui->bufferPlot->setAxisTitle(0,"Buffer Utilization");
ui->bufferPlot->setAxisScale(0,0.0, maxBufferDepth);
QwtText axisTitle3( "Time [s]" );
axisTitle3.setFont( ui->bufferPlot->axisTitle( QwtPlot::xBottom ).font() );
ui->bufferPlot->setAxisTitle( QwtPlot::xBottom, axisTitle3 );
QwtPlotMagnifier *mag3 = new QwtPlotMagnifier(ui->bufferPlot->canvas());
mag3->setAxisEnabled(QwtPlot::xBottom, true);
mag3->setAxisEnabled(QwtPlot::yLeft, false);
mag3->setWheelFactor(5);
QwtPlotPanner *pan3 = new QwtPlotPanner(ui->bufferPlot->canvas());
pan3->setAxisEnabled(QwtPlot::xBottom, true);
pan3->setAxisEnabled(QwtPlot::yLeft, false);
ui->bufferPlot->replot();
}

View File

@@ -83,6 +83,7 @@ private Q_SLOTS:
void on_tabWidget_currentChanged(int index);
void on_latencyTreeView_doubleClicked(const QModelIndex &index);
void on_startLatencyAnalysis_clicked();
void on_startPowerAnalysis_clicked();
};
#endif // TRACEFILETAB_H

View File

@@ -171,7 +171,7 @@
</item>
</layout>
</widget>
<widget class="QWidget" name="tab_2">
<widget class="QWidget" name="tabLatencyAnalysis">
<attribute name="title">
<string>Latency Analysis</string>
</attribute>
@@ -213,6 +213,78 @@
</item>
</layout>
</widget>
<widget class="QWidget" name="tabPowerAnalysis">
<property name="enabled">
<bool>true</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>467</width>
<height>0</height>
</size>
</property>
<property name="accessibleName">
<string/>
</property>
<attribute name="title">
<string>Power and Bandwidth Analysis</string>
</attribute>
<layout class="QGridLayout" name="gridLayout_4">
<item row="0" column="0">
<widget class="QPushButton" name="startPowerAnalysis">
<property name="text">
<string>Start Analysis</string>
</property>
</widget>
</item>
<item row="1" column="0">
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<widget class="QGroupBox" name="powerBox">
<property name="title">
<string>Power:</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_6">
<item>
<widget class="QwtPlot" name="powerPlot"/>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="bandwidthBox">
<property name="title">
<string>Bandwidth:</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_5">
<item>
<widget class="QwtPlot" name="bandwidthPlot"/>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="bufferBox">
<property name="title">
<string>Buffer Analysis:</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_8">
<item>
<widget class="QwtPlot" name="bufferPlot"/>
</item>
</layout>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</widget>
</item>
</layout>