diff --git a/DRAMSys/traceAnalyzer/scripts/plots.py b/DRAMSys/traceAnalyzer/scripts/plots.py index dc6def9f..e3c469a0 100755 --- a/DRAMSys/traceAnalyzer/scripts/plots.py +++ b/DRAMSys/traceAnalyzer/scripts/plots.py @@ -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 diff --git a/DRAMSys/traceAnalyzer/tracefiletab.cpp b/DRAMSys/traceAnalyzer/tracefiletab.cpp index b67004b7..981e60fb 100644 --- a/DRAMSys/traceAnalyzer/tracefiletab.cpp +++ b/DRAMSys/traceAnalyzer/tracefiletab.cpp @@ -45,6 +45,14 @@ #include #include #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 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* samples=new QVector; + + 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* samples2=new QVector; + + 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* samples3 = new QVector; + + 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(); +} diff --git a/DRAMSys/traceAnalyzer/tracefiletab.h b/DRAMSys/traceAnalyzer/tracefiletab.h index 6ec1cec5..6a7890a4 100644 --- a/DRAMSys/traceAnalyzer/tracefiletab.h +++ b/DRAMSys/traceAnalyzer/tracefiletab.h @@ -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 diff --git a/DRAMSys/traceAnalyzer/tracefiletab.ui b/DRAMSys/traceAnalyzer/tracefiletab.ui index 726f36c8..182c410e 100644 --- a/DRAMSys/traceAnalyzer/tracefiletab.ui +++ b/DRAMSys/traceAnalyzer/tracefiletab.ui @@ -171,7 +171,7 @@ - + Latency Analysis @@ -213,6 +213,78 @@ + + + true + + + + 0 + 0 + + + + + 467 + 0 + + + + + + + Power and Bandwidth Analysis + + + + + + Start Analysis + + + + + + + + + Power: + + + + + + + + + + + + Bandwidth: + + + + + + + + + + + + Buffer Analysis: + + + + + + + + + + + +