Create cache request ratio plot
MODIFY
src/cacheinspector.cpp
src/cacheinspector.cpp
@@ -11,23 +11,40 @@ CacheInspector::CacheInspector(QWidget *parent)
m_hitData = {5, 7, 9};
m_missData = {2, 0, 5};
+ setupCacheRequestPlot();
+ setupCacheRequestRatioPlot();
+
+ // Setup view selection
+ m_ui->selectedPlot->setId(m_ui->crbutton, 0);
+ m_ui->selectedPlot->setId(m_ui->crrbutton, 1);
+ m_ui->selectedPlot->setId(m_ui->trbutton, 2);
+ m_ui->selectedPlot->setId(m_ui->trrbutton, 3);
+ connect(m_ui->selectedPlot, QOverload<int>::of(&QButtonGroup::buttonClicked),
+ [=] { changePlotView(m_ui->selectedPlot->checkedId()); });
+}
+
+void CacheInspector::changePlotView(int view) {
+ m_ui->plotview->setCurrentIndex(view);
+}
+
+void CacheInspector::setupCacheRequestPlot() {
// Setup bars
- m_hits =
- new QCPBars(m_ui->plottingwidget->xAxis, m_ui->plottingwidget->yAxis);
- m_hits->setName("Cache hit");
- m_hits->setPen(QPen(QColor(136, 240, 0).lighter(170)));
- m_hits->setBrush(QColor(136, 240, 0));
-
- m_misses =
- new QCPBars(m_ui->plottingwidget->xAxis, m_ui->plottingwidget->yAxis);
- m_misses->setName("Cache Miss");
- m_misses->setPen(QPen(QColor(255, 35, 0).lighter(170)));
- m_misses->setBrush(QColor(255, 35, 0));
+ QCPBars *hits =
+ new QCPBars(m_ui->cacheRequestPlot->xAxis, m_ui->cacheRequestPlot->yAxis);
+ hits->setName("Cache hit");
+ hits->setPen(QPen(QColor(136, 240, 0).lighter(170)));
+ hits->setBrush(QColor(136, 240, 0));
+
+ QCPBars *misses =
+ new QCPBars(m_ui->cacheRequestPlot->xAxis, m_ui->cacheRequestPlot->yAxis);
+ misses->setName("Cache Miss");
+ misses->setPen(QPen(QColor(255, 35, 0).lighter(170)));
+ misses->setBrush(QColor(255, 35, 0));
// Stack hit bars on top of miss bars
- setupBar(m_hits);
- setupBar(m_misses);
- m_misses->moveAbove(m_hits);
+ setupBar(hits);
+ setupBar(misses);
+ misses->moveAbove(hits);
// Setup ticker
QSharedPointer<QCPAxisTickerText> ticker(new QCPAxisTickerText);
@@ -36,27 +53,26 @@ CacheInspector::CacheInspector(QWidget *parent)
QVector<QString>() << "L1"
<< "L2"
<< "L3");
- m_ui->plottingwidget->xAxis->setTicker(ticker);
- m_ui->plottingwidget->xAxis->setRange(0, 4);
- m_ui->plottingwidget->xAxis->setLabel("Cache level");
- m_ui->plottingwidget->yAxis->setLabel("Cache requests");
+ m_ui->cacheRequestPlot->xAxis->setTicker(ticker);
+ m_ui->cacheRequestPlot->xAxis->setRange(0, 4);
+ m_ui->cacheRequestPlot->xAxis->setLabel("Cache level");
+ m_ui->cacheRequestPlot->yAxis->setLabel("Cache requests");
QFont font;
font.setPointSize(10);
- m_ui->plottingwidget->yAxis->setLabelFont(font);
- m_ui->plottingwidget->xAxis->setTickLabelFont(font);
- m_ui->plottingwidget->xAxis->setLabelFont(font);
+ m_ui->cacheRequestPlot->yAxis->setLabelFont(font);
+ m_ui->cacheRequestPlot->xAxis->setTickLabelFont(font);
+ m_ui->cacheRequestPlot->xAxis->setLabelFont(font);
// Setup legend
- m_ui->plottingwidget->legend->setVisible(true);
+ m_ui->cacheRequestPlot->legend->setVisible(true);
// Set data
- m_hits->setData(ticks, m_hitData);
- m_misses->setData(ticks, m_missData);
+ hits->setData(ticks, m_hitData);
+ misses->setData(ticks, m_missData);
- m_ui->plottingwidget->yAxis->rescale(true);
+ m_ui->cacheRequestPlot->yAxis->rescale(true);
}
-
void CacheInspector::setupBar(QCPBars *bar) {
bar->setAntialiased(false);
bar->setStackingGap(1);
@@ -70,4 +86,44 @@ void CacheInspector::updateData(int value, dataRole role, cacheLevel level) {
}
}
+void CacheInspector::setupCacheRequestRatioPlot() {
+ // Setup bars
+ QCPBars *ratio = new QCPBars(m_ui->cacheRequestRatioPlot->xAxis,
+ m_ui->cacheRequestRatioPlot->yAxis);
+ ratio->setName("Miss ratio");
+ ratio->setPen(QPen(QColor(179, 230, 249).lighter(170)));
+ ratio->setBrush(QColor(179, 230, 249));
+
+ // Setup ticker
+ QSharedPointer<QCPAxisTickerText> ticker(new QCPAxisTickerText);
+ QVector<double> ticks = {1, 2, 3};
+ ticker->addTicks(ticks,
+ QVector<QString>() << "L1"
+ << "L2"
+ << "L3");
+ m_ui->cacheRequestRatioPlot->xAxis->setTicker(ticker);
+ m_ui->cacheRequestRatioPlot->xAxis->setRange(0, 4);
+ m_ui->cacheRequestRatioPlot->xAxis->setLabel("Cache level");
+ m_ui->cacheRequestRatioPlot->yAxis->setLabel("Miss ratio [%]");
+
+ QFont font;
+ font.setPointSize(10);
+ m_ui->cacheRequestRatioPlot->yAxis->setLabelFont(font);
+ m_ui->cacheRequestRatioPlot->xAxis->setTickLabelFont(font);
+ m_ui->cacheRequestRatioPlot->xAxis->setLabelFont(font);
+
+ // Setup legend
+ m_ui->cacheRequestRatioPlot->legend->setVisible(true);
+
+ // Set data
+ QVector<double> data;
+ for (int i = 0; i < m_missData.size(); i++) {
+ data.push_back(m_missData[i] * 100 / (m_missData[i] + m_hitData[i]));
+ }
+ ratio->setData(ticks, data);
+ m_ui->cacheRequestRatioPlot->yAxis->setRange(0, 100);
+}
+void CacheInspector::setupTemporalPlot() {}
+void CacheInspector::setupTemporalRatioPlot() {}
+
CacheInspector::~CacheInspector() { delete m_ui; }

MODIFY
src/cacheinspector.h
src/cacheinspector.h
@@ -20,12 +20,15 @@ public:
~CacheInspector();
void updateData(int value, dataRole role, cacheLevel level);
+ void changePlotView(int view);
private:
Ui::CacheInspector *m_ui;
- QCPBars *m_hits;
- QCPBars *m_misses;
+ void setupCacheRequestPlot();
+ void setupCacheRequestRatioPlot();
+ void setupTemporalPlot();
+ void setupTemporalRatioPlot();
QVector<double> m_missData;
QVector<double> m_hitData;

MODIFY
src/cacheinspector.ui
src/cacheinspector.ui
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
- <widget class="QRadioButton" name="radioButton">
+ <widget class="QRadioButton" name="crbutton">
<property name="text">
<string>Cache requests</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
+ <attribute name="buttonGroup">
+ <string notr="true">selectedPlot</string>
+ </attribute>
</widget>
</item>
<item>
- <widget class="QRadioButton" name="radioButton_3">
+ <widget class="QRadioButton" name="crrbutton">
<property name="text">
<string>Cache requests (ratio)</string>
</property>
+ <attribute name="buttonGroup">
+ <string notr="true">selectedPlot</string>
+ </attribute>
</widget>
</item>
<item>
- <widget class="QRadioButton" name="radioButton_2">
+ <widget class="QRadioButton" name="trbutton">
<property name="text">
<string>Temporal requests</string>
</property>
+ <attribute name="buttonGroup">
+ <string notr="true">selectedPlot</string>
+ </attribute>
</widget>
</item>
<item>
- <widget class="QRadioButton" name="radioButton_4">
+ <widget class="QRadioButton" name="trrbutton">
<property name="text">
<string>Temporal requests (ratio)</string>
</property>
+ <attribute name="buttonGroup">
+ <string notr="true">selectedPlot</string>
+ </attribute>
</widget>
</item>
<item>
</layout>
</widget>
</item>
- <item>
- <widget class="QCustomPlot" name="plottingwidget" native="true">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Expanding" vsizetype="Preferred">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- </widget>
- </item>
</layout>
</item>
+ <item row="0" column="1">
+ <widget class="QStackedWidget" name="plotview">
+ <widget class="QCustomPlot" name="cacheRequestPlot"/>
+ <widget class="QCustomPlot" name="cacheRequestRatioPlot"/>
+ <widget class="QCustomPlot" name="temporalPlot"/>
+ <widget class="QCustomPlot" name="temporalRatioPlot"/>
+ </widget>
+ </item>
</layout>
</widget>
<customwidgets>
</customwidgets>
<resources/>
<connections/>
+ <buttongroups>
+ <buttongroup name="selectedPlot"/>
+ </buttongroups>
</ui>

MODIFY
src/mainwindow.cpp
src/mainwindow.cpp
#include "registerwidget.h"
#include "runner.h"
-<<<<<<< HEAD
#include "defines.h"
MainWindow::MainWindow(Runner *runnerPtr, Parser *parserPtr, QWidget *parent)

Create cache request ratio plot