Added first latency analysis
This commit is contained in:
@@ -5,10 +5,10 @@
|
||||
"DatabaseRecording": true,
|
||||
"Debug": false,
|
||||
"ECCControllerMode": "Disabled",
|
||||
"EnableWindowing": false,
|
||||
"EnableWindowing": true,
|
||||
"ErrorCSVFile": "",
|
||||
"ErrorChipSeed": 42,
|
||||
"PowerAnalysis": false,
|
||||
"PowerAnalysis": true,
|
||||
"SimulationName": "ddr3",
|
||||
"SimulationProgressBar": true,
|
||||
"StoreMode": "NoStorage",
|
||||
|
||||
@@ -348,6 +348,11 @@ vector<Comment> TraceDB::getDebugMessagesInTimespan(const Timespan &span,
|
||||
return parseCommentsFromQuery(selectDebugMessagesByTimespanWithLimit);
|
||||
}
|
||||
|
||||
QSqlDatabase TraceDB::getDatabase() const
|
||||
{
|
||||
return database;
|
||||
}
|
||||
|
||||
/* Helpers
|
||||
*
|
||||
*
|
||||
|
||||
@@ -102,6 +102,8 @@ public:
|
||||
std::vector<Comment> getDebugMessagesInTimespan(const Timespan &span,
|
||||
unsigned int limit);
|
||||
|
||||
QSqlDatabase getDatabase() const;
|
||||
|
||||
private:
|
||||
QString pathToDB;
|
||||
QSqlDatabase database;
|
||||
|
||||
@@ -252,6 +252,45 @@ def power_window(connection, tracePath, steps):
|
||||
|
||||
return outputFile
|
||||
|
||||
@plot
|
||||
def latency_analysis(connection, tracePath, steps):
|
||||
from collections import Counter
|
||||
query = """ SELECT ((p2.PhaseEnd - p1.PhaseBegin)/1000), t.id
|
||||
FROM Transactions t, Phases p1, Phases p2
|
||||
WHERE t.id = p1.Transact
|
||||
AND t.id = p2.Transact
|
||||
AND p1.PhaseName = "REQ"
|
||||
AND p2.PhaseName = "RESP" """
|
||||
cursor = connection.cursor()
|
||||
cursor.execute(query)
|
||||
results = []
|
||||
while True:
|
||||
result = cursor.fetchone()
|
||||
if (result is not None):
|
||||
results.append([result[0], result[1]])
|
||||
else:
|
||||
break
|
||||
|
||||
# Create histogram for analysis:
|
||||
hist = {}
|
||||
transactions = {}
|
||||
for i in results:
|
||||
hist[i[0]] = hist.get(i[0], 0) + 1
|
||||
if i[0] in transactions:
|
||||
transactions[i[0]].append(i[1])
|
||||
else:
|
||||
transactions[i[0]] = []
|
||||
|
||||
# Find N highest bins
|
||||
N = 3
|
||||
k = Counter(hist)
|
||||
high = k.most_common(3)
|
||||
|
||||
for i in high:
|
||||
print(i[0]," :",i[1]," ")
|
||||
print(transactions[i[0]])
|
||||
|
||||
return "none\n"
|
||||
|
||||
@plot
|
||||
def latency_histogram(connection, tracePath, steps):
|
||||
|
||||
@@ -41,6 +41,9 @@
|
||||
#include "QFileInfo"
|
||||
#include "qmessagebox.h"
|
||||
#include <iostream>
|
||||
#include <QStandardItemModel>
|
||||
#include <QString>
|
||||
#include <QItemDelegate>
|
||||
|
||||
TraceFileTab::TraceFileTab(QWidget *parent, const QString &path) :
|
||||
QWidget(parent), ui(new Ui::TraceFileTab), savingChangesToDB(false)
|
||||
@@ -82,7 +85,6 @@ void TraceFileTab::initNavigatorAndItsDependentWidgets(QString path)
|
||||
ui->selectedTransactionTree->init(navigator);
|
||||
//ui->debugMessages->init(navigator,ui->traceplot);
|
||||
ui->commentTree->init(navigator);
|
||||
|
||||
}
|
||||
|
||||
void TraceFileTab::setUpFileWatcher(QString path)
|
||||
@@ -110,3 +112,87 @@ void TraceFileTab::tracefileChanged()
|
||||
navigator->refreshData();
|
||||
}
|
||||
|
||||
class ItemDelegate: public QItemDelegate
|
||||
{
|
||||
public:
|
||||
ItemDelegate(QObject* parent = nullptr): QItemDelegate(parent)
|
||||
{
|
||||
}
|
||||
|
||||
void paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const
|
||||
{
|
||||
if (index.column() == 1) {
|
||||
double progress = index.data().toDouble();
|
||||
QStyleOptionProgressBar opt;
|
||||
opt.rect = option.rect;
|
||||
opt.minimum = 0;
|
||||
opt.maximum = 100;
|
||||
opt.progress = static_cast<int>(progress);
|
||||
opt.text = QString::number(progress, 'f', 2)+" %";
|
||||
opt.textVisible = true;
|
||||
QApplication::style()->drawControl(QStyle::CE_ProgressBar, &opt, painter, nullptr);
|
||||
} else {
|
||||
QItemDelegate::paint(painter, option, index);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
void TraceFileTab::on_tabWidget_currentChanged(int index)
|
||||
{
|
||||
if(index == 1) // Changed to latency tab:
|
||||
{
|
||||
// Create Database Setup and Query:
|
||||
QString sql = "SELECT ((p2.PhaseEnd - p1.PhaseBegin)/1000) as latency, t.id "
|
||||
"FROM Transactions t, Phases p1, Phases p2 "
|
||||
"WHERE t.id = p1.Transact "
|
||||
"AND t.id = p2.Transact "
|
||||
"AND p1.PhaseName = \"REQ\" "
|
||||
"AND p2.PhaseName = \"RESP\" ORDER BY latency;";
|
||||
|
||||
QSqlDatabase db = navigator->TraceFile().getDatabase();
|
||||
QSqlQuery query(db);
|
||||
query.exec(sql);
|
||||
|
||||
// Creatoe model and fill it from Database:
|
||||
QStandardItemModel* model = new QStandardItemModel();
|
||||
|
||||
int currentLatency = 0;
|
||||
QStandardItem* currentLatencyItem = nullptr;
|
||||
int counter = 0;
|
||||
while (query.next()) {
|
||||
if(query.value(0) != currentLatency) {
|
||||
currentLatencyItem = new QStandardItem(QString::number(query.value(0).toInt())+" ns");
|
||||
currentLatency = query.value(0).toInt();
|
||||
QList<QStandardItem *> row;
|
||||
row.append(currentLatencyItem);
|
||||
row.append(new QStandardItem());
|
||||
model->appendRow(row);
|
||||
}
|
||||
QStandardItem * id = new QStandardItem(query.value(1).toString());
|
||||
currentLatencyItem->appendRow(id);
|
||||
counter++;
|
||||
}
|
||||
QStringList header = {"Latency","Occurences"};
|
||||
model->setHorizontalHeaderLabels(header);
|
||||
|
||||
// Generate Histrogram:
|
||||
for(int i = 0; i < model->rowCount(); i++) {
|
||||
int numberOfChilds = model->item(i)->rowCount();
|
||||
double percentage = 100*((double(numberOfChilds))/(double(counter)));
|
||||
model->item(i,1)->setText(QString::number(percentage));
|
||||
}
|
||||
ui->latencyTreeView->setItemDelegate(new ItemDelegate(ui->latencyTreeView));
|
||||
ui->latencyTreeView->setModel(model);
|
||||
}
|
||||
}
|
||||
|
||||
void TraceFileTab::on_latencyTreeView_doubleClicked(const QModelIndex &index)
|
||||
{
|
||||
// Get onlye the leaf:
|
||||
if(index.column() == 0 && index.model()->hasChildren(index) == false) {
|
||||
unsigned int id = index.data().toUInt();
|
||||
if(id!=0) {
|
||||
navigator->selectTransaction(id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -79,6 +79,9 @@ public Q_SLOTS:
|
||||
Q_SIGNALS:
|
||||
void statusChanged(QString message, bool saveChangesEnable = false);
|
||||
void colorGroupingChanged(ColorGrouping colorgrouping);
|
||||
private Q_SLOTS:
|
||||
void on_tabWidget_currentChanged(int index);
|
||||
void on_latencyTreeView_doubleClicked(const QModelIndex &index);
|
||||
};
|
||||
|
||||
#endif // TRACEFILETAB_H
|
||||
|
||||
@@ -58,46 +58,88 @@
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2" stretch="0,0,0">
|
||||
<item>
|
||||
<widget class="SelectedTransactionTreeWidget" name="selectedTransactionTree">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||
<horstretch>3</horstretch>
|
||||
<verstretch>3</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<widget class="QTabWidget" name="tabWidget">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>300</width>
|
||||
<height>0</height>
|
||||
<width>0</width>
|
||||
<height>500</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16777215</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="itemsExpandable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="sortingEnabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="animated">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="columnCount">
|
||||
<property name="currentIndex">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<attribute name="headerStretchLastSection">
|
||||
<bool>true</bool>
|
||||
</attribute>
|
||||
<widget class="QWidget" name="tabSelectedTrans">
|
||||
<attribute name="title">
|
||||
<string>Selected Transaction</string>
|
||||
</attribute>
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<item row="0" column="0">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_4">
|
||||
<item>
|
||||
<widget class="SelectedTransactionTreeWidget" name="selectedTransactionTree">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||
<horstretch>3</horstretch>
|
||||
<verstretch>3</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>300</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16777215</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="itemsExpandable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="sortingEnabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="animated">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="columnCount">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<attribute name="headerStretchLastSection">
|
||||
<bool>true</bool>
|
||||
</attribute>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="tab_2">
|
||||
<attribute name="title">
|
||||
<string>Latency Analysis</string>
|
||||
</attribute>
|
||||
<layout class="QGridLayout" name="gridLayout_3">
|
||||
<item row="0" column="0">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_7">
|
||||
<item>
|
||||
<widget class="QTreeView" name="latencyTreeView">
|
||||
<property name="editTriggers">
|
||||
<set>QAbstractItemView::NoEditTriggers</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="CommentTreeWidget" name="commentTree">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Minimum">
|
||||
<horstretch>2</horstretch>
|
||||
<verstretch>1</verstretch>
|
||||
</sizepolicy>
|
||||
@@ -105,7 +147,7 @@
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>300</width>
|
||||
<height>0</height>
|
||||
<height>200</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
|
||||
Reference in New Issue
Block a user