Thread Metrics

This commit is contained in:
Felipe S. Prado
2016-10-14 15:14:28 +02:00
parent a7827e5e69
commit 49a01e94d5
4 changed files with 48 additions and 25 deletions

View File

@@ -101,8 +101,17 @@ void EvaluationTool::showAndEvaluateMetrics(QList<QString> paths)
vector<string> EvaluationTool::getMetrics()
{
ui->traceMetricTreeWidget->clear();
TraceFileItem* item = static_cast<TraceFileItem*>(traceFilesModel->item(0));
return pythonCaller.getMetrics(item->getPath());
vector<string> metrics;
for(int row = 0; row < traceFilesModel->rowCount(); ++row)
{
TraceFileItem* item = static_cast<TraceFileItem*>(traceFilesModel->item(row));
vector<string> result = pythonCaller.getMetrics(item->getPath());
if(result.size() > metrics.size())
metrics = result;
}
return metrics;
}
void EvaluationTool::cleanUpUI()
@@ -173,7 +182,6 @@ void EvaluationTool::getSelectedMetrics()
calculateMetrics(selectedMetrics);
}
void EvaluationTool::calculateMetrics(vector<long> selectedMetrics)
{
ui->traceMetricTreeWidget->clear();
@@ -185,10 +193,8 @@ void EvaluationTool::calculateMetrics(vector<long> selectedMetrics)
ui->traceMetricTreeWidget->addTraceMetricResults(result);
}
ui->traceMetricTreeWidget->expandAll();
}
void EvaluationTool::setTestMessage(QString message)
{
ui->testMessage->setPlainText(message);

View File

@@ -51,11 +51,17 @@ void TraceMetricTreeWidget::addTraceMetricResults(const TraceCalculatedMetrics&
QTreeWidgetItem* top = new QTreeWidgetItem({result.getTraceName()});
addTopLevelItem(top);
for(CalculatedMetric calculatedMetric : result.getCalculatedMetrics())
if(result.getCalculatedMetrics().empty())
{
new QTreeWidgetItem(top,{calculatedMetric.getName() + QString(": ") + QString::number(calculatedMetric.getValue())});
new QTreeWidgetItem(top,{QString("Number of threads: 1")});
}
else
{
for(CalculatedMetric calculatedMetric : result.getCalculatedMetrics())
{
new QTreeWidgetItem(top,{calculatedMetric.getName() + QString(": ") + QString::number(calculatedMetric.getValue())});
}
}
}
void TraceMetricTreeWidget::addTracePlotResults(QString traceName, QString outputFiles)
@@ -67,5 +73,3 @@ void TraceMetricTreeWidget::addTracePlotResults(QString traceName, QString outpu
new QTreeWidgetItem(top,{outputFiles});
}

View File

@@ -45,14 +45,13 @@ TraceTestTreeWidget::TraceTestTreeWidget(QWidget *parent) : QTreeWidget(parent)
void TraceTestTreeWidget::addTraceTestResult(const TraceTestResults &traceTestResult)
{
QTreeWidgetItem* top = new QTreeWidgetItem({traceTestResult.getTraceName()});
addTopLevelItem(top);
if(traceTestResult.hasPassedAllTests())
if(traceTestResult.hasPassedAllTests())
top->setTextColor(0,Qt::green);
else
top->setTextColor(0,Qt::red);
else
top->setTextColor(0,Qt::red);
for(const TestResult& testResult: traceTestResult.getTestResults())
{

View File

@@ -203,6 +203,15 @@ def paralellism(connection, thread):
return round(para/len(stalltimes), 2)
@threadMetric
def thread_conclusion_in_ns(connection,thread):
cursor = connection.cursor()
query = """ SELECT max(PhaseEnd)/1000 FROM Phases INNER JOIN Transactions on Phases.transact=Transactions.id WHERE TThread = :Thread """
cursor.execute(query, {"Thread": thread})
result = cursor.fetchone()
return result[0]
@metric
def number_of_activates(connection):
cursor = connection.cursor()
@@ -429,7 +438,7 @@ def passRatio(connection):
passRatio = numberOfPassWins[thread]*1.0/(numberOfPassWins[thread]+numberOfPassLosses[thread])
else:
passRatio = 0.5
print("Thread {0} passed other threads {1} times and was passed {2} times. Pass ratio is {3}".format(thread, numberOfPassWins[thread], numberOfPassLosses[thread], passRatio))
#print("Thread {0} passed other threads {1} times and was passed {2} times. Pass ratio is {3}".format(thread, numberOfPassWins[thread], numberOfPassLosses[thread], passRatio))
result.append(("Thread {0} pass ratio".format(thread), passRatio))
return result
@@ -450,7 +459,7 @@ def getMetrics(pathToTrace):
if metric not in metrics:
metrics.append(metric)
if (len(getThreads(connection)) == 1):
if (len(getThreads(connection)) >= 1):
for metric in metrics:
res = metric.__name__.replace("_", " ")
selectedMetrics.append(res)
@@ -458,8 +467,10 @@ def getMetrics(pathToTrace):
if (len(getThreads(connection)) > 1):
for thread in getThreads(connection):
for threadMetric in threadMetrics:
res = threadMetric.__name__.replace("_"," ")
res = "Thread {0}: {1}".format(thread,threadMetric.__name__.replace("_"," "))
selectedMetrics.append(res)
res = "pass ratio"
selectedMetrics.append(res)
connection.close()
return selectedMetrics
@@ -488,11 +499,11 @@ def calculateMetrics(pathToTrace, selectedMetrics = []):
print("Number of threads is {0}".format(len(getThreads(connection))))
if not selectedMetrics:
selectedMetrics = [0] * len(metrics)
selectedMetrics = [0] * (len(metrics) + len(getThreads(connection))*len(threadMetrics) + 1)
for i in range(len(metrics)):
selectedMetrics[i] = True
if (len(getThreads(connection)) == 1):
if (len(getThreads(connection)) >= 1):
for metric in metrics:
if selectedMetrics[metrics.index(metric)]:
mres = metric(connection)
@@ -513,12 +524,15 @@ def calculateMetrics(pathToTrace, selectedMetrics = []):
print("{0}: {1}".format(res[0], res[1]))
if (len(getThreads(connection)) > 1):
# for thread in getThreads(connection):
# for metric in threadMetrics:
# res = ("Thread " + str(thread) + " " + metric.__name__.replace("_"," "), metric(connection, thread))
# print("{0}: {1}".format(res[0],res[1]))
# calculatedMetrics.append(res)
calculatedMetrics.extend(passRatio(connection))
for thread in getThreads(connection):
for metric in threadMetrics:
if(selectedMetrics[len(metrics) + len(threadMetrics)*(thread-1) + threadMetrics.index(metric)]):
mres = metric(connection, thread)
mname = "Thread {0} - {1}".format(thread,metric.__name__.replace("_"," "))
r = (mname, mres)
calculatedMetrics.append(r)
if(selectedMetrics[len(selectedMetrics) -1]):
calculatedMetrics.extend(passRatio(connection))
# refreshMissDecision(connection, calculatedMetrics)
if (len(getThreads(connection)) == 0):