| 1 |
/* |
| 2 |
* Copyright (C) 2013-2015, 2019 by the Konclude Developer Team. |
| 3 |
* |
| 4 |
* This file is part of the reasoning system Konclude. |
| 5 |
* For details and support, see <http://konclude.com/>. |
| 6 |
* |
| 7 |
* Konclude is free software: you can redistribute it and/or modify |
| 8 |
* it under the terms of version 3 of the GNU Lesser General Public |
| 9 |
* License (LGPLv3) as published by the Free Software Foundation. |
| 10 |
* |
| 11 |
* Konclude is distributed in the hope that it will be useful, |
| 12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 |
* GNU (Lesser) General Public License for more details. |
| 15 |
* |
| 16 |
* You should have received a copy of the GNU (Lesser) General Public |
| 17 |
* License along with Konclude. If not, see <http://www.gnu.org/licenses/>. |
| 18 |
* |
| 19 |
*/ |
| 20 |
|
| 21 |
#include "CReasonerEvaluationGroupRequestReasonerMemoryUsageAnalyser.h" |
| 22 |
|
| 23 |
|
| 24 |
namespace Konclude { |
| 25 |
|
| 26 |
namespace Test { |
| 27 |
|
| 28 |
namespace Evaluation { |
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
CReasonerEvaluationGroupRequestReasonerMemoryUsageAnalyser::CReasonerEvaluationGroupRequestReasonerMemoryUsageAnalyser() { |
| 33 |
} |
| 34 |
|
| 35 |
|
| 36 |
CReasonerEvaluationGroupRequestReasonerMemoryUsageAnalyser::~CReasonerEvaluationGroupRequestReasonerMemoryUsageAnalyser() { |
| 37 |
} |
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
bool CReasonerEvaluationGroupRequestReasonerMemoryUsageAnalyser::analyseGroupedEvaluationData(const QStringList& groubList, const QStringList& requestList, const QStringList& reasonerList, const QString& outputDirectory, CReasonerEvaluationAnalyseContext* context, CReasonerEvaluationGroupRequestSelector* selector) { |
| 42 |
|
| 43 |
mOutputFileName = QString("%1").arg(selector->getOutputString()); |
| 44 |
|
| 45 |
bool hasSelectedRequestFile = false; |
| 46 |
|
| 47 |
QStringList titleList; |
| 48 |
titleList.append("Requests"); |
| 49 |
titleList.append(reasonerList); |
| 50 |
titleList.append("Average"); |
| 51 |
titleList.append("Min"); |
| 52 |
titleList.append("Max"); |
| 53 |
|
| 54 |
QDir outDir(outputDirectory); |
| 55 |
outDir.mkpath(mOutputFileName); |
| 56 |
QString outputFileString(outputDirectory+mOutputFileName+"memory-usage"); |
| 57 |
|
| 58 |
CReasonerEvaluationTableMultiFormatOutputWriter<double> tableMultiFormatOutputWriter; |
| 59 |
tableMultiFormatOutputWriter.addColumnTitles(titleList); |
| 60 |
|
| 61 |
foreach (QString groupString, groubList) { |
| 62 |
|
| 63 |
if (selector->isGroupSelected(groupString)) { |
| 64 |
|
| 65 |
QSet<QString>* groupRequestList = getGroupRequests(groupString); |
| 66 |
foreach (QString requestString, *groupRequestList) { |
| 67 |
|
| 68 |
if (selector->isRequestSelected(groupString,requestString)) { |
| 69 |
|
| 70 |
bool allDataAvailable = true; |
| 71 |
foreach (QString reasonerString, reasonerList) { |
| 72 |
CReasonerEvaluationDataValue* evalData = getGroupRequestReasonerEvaluationData(groupString,requestString,reasonerString); |
| 73 |
if (!evalData || evalData->hasDataNotAvailableFlag()) { |
| 74 |
allDataAvailable = false; |
| 75 |
} |
| 76 |
} |
| 77 |
|
| 78 |
|
| 79 |
if (allDataAvailable) { |
| 80 |
|
| 81 |
hasSelectedRequestFile = true; |
| 82 |
double min = DOUBLE_MAX; |
| 83 |
double max = DOUBLE_MIN; |
| 84 |
double mean = 0.; |
| 85 |
cint64 count = 0; |
| 86 |
|
| 87 |
tableMultiFormatOutputWriter.addNewTableRow(requestString); |
| 88 |
|
| 89 |
foreach (QString reasonerString, reasonerList) { |
| 90 |
CReasonerEvaluationDataValue* evalData = getGroupRequestReasonerEvaluationData(groupString,requestString,reasonerString); |
| 91 |
CReasonerEvaluationDoubleDataValue* doubleDataValue = dynamic_cast<CReasonerEvaluationDoubleDataValue*>(evalData); |
| 92 |
if (doubleDataValue) { |
| 93 |
double memoryUsageValue = doubleDataValue->getValue(); |
| 94 |
|
| 95 |
tableMultiFormatOutputWriter.addValuesToLastTableRow(QList<double>()<< memoryUsageValue); |
| 96 |
|
| 97 |
mean += memoryUsageValue; |
| 98 |
min = qMin(min, memoryUsageValue); |
| 99 |
max = qMax(max, memoryUsageValue); |
| 100 |
count++; |
| 101 |
} |
| 102 |
} |
| 103 |
mean /= (double)count; |
| 104 |
tableMultiFormatOutputWriter.addValuesToLastTableRow(QList<double>()<<mean<<min<<max); |
| 105 |
} |
| 106 |
} |
| 107 |
} |
| 108 |
} |
| 109 |
} |
| 110 |
|
| 111 |
if (hasSelectedRequestFile) { |
| 112 |
|
| 113 |
QStringList reasonerCompGNUPlotFileList; |
| 114 |
QStringList reasonerCompHighchartPlotFileList; |
| 115 |
|
| 116 |
tableMultiFormatOutputWriter.buildSortedIndex(); |
| 117 |
reasonerCompHighchartPlotFileList += tableMultiFormatOutputWriter.writeCVSTable(outputFileString); |
| 118 |
reasonerCompHighchartPlotFileList += tableMultiFormatOutputWriter.writeCVSTablesSorted(outputFileString); |
| 119 |
tableMultiFormatOutputWriter.writeCVSTablesSeparateSorted(outputFileString); |
| 120 |
|
| 121 |
if (context->isGNUPlottingActivated()) { |
| 122 |
reasonerCompGNUPlotFileList += tableMultiFormatOutputWriter.writeGNUPlotDataTable(outputFileString); |
| 123 |
reasonerCompGNUPlotFileList += tableMultiFormatOutputWriter.writeGNUPlotDataTablesSorted(outputFileString); |
| 124 |
foreach (QString plotFileString, reasonerCompGNUPlotFileList) { |
| 125 |
if (true /*plotFileString.contains("-by-Average-")*/) { |
| 126 |
QString outputFile = plotFileString; |
| 127 |
outputFile.remove(".dat"); |
| 128 |
QString title = getPrettyTitleFromOutputFile(outputFile); |
| 129 |
context->getGNUPlotPlotter()->createReasonerComparisonPlot(plotFileString,context->getAdditionalTitleString()+title+"[bytes]",reasonerList,outputFile); |
| 130 |
} |
| 131 |
} |
| 132 |
} |
| 133 |
if (context->isHighchartPlottingActivated()) { |
| 134 |
foreach (QString plotFileString, reasonerCompHighchartPlotFileList) { |
| 135 |
if (true /*plotFileString.contains("-by-Average-")*/) { |
| 136 |
QString outputFile = plotFileString; |
| 137 |
outputFile.remove(".csv"); |
| 138 |
QString title = getPrettyTitleFromOutputFile(outputFile); |
| 139 |
context->getHighchartPlotter()->createReasonerMemoryUsagePlot(plotFileString,context->getAdditionalTitleString()+title+"[bytes]",reasonerList,outputFile,selector->getNameString()+" :: "+context->getAdditionalTitleString()); |
| 140 |
} |
| 141 |
} |
| 142 |
} |
| 143 |
|
| 144 |
} |
| 145 |
|
| 146 |
return true; |
| 147 |
} |
| 148 |
|
| 149 |
|
| 150 |
|
| 151 |
QString CReasonerEvaluationGroupRequestReasonerMemoryUsageAnalyser::getPrettyTitleFromOutputFile(const QString& outputFile) { |
| 152 |
QString title = outputFile; |
| 153 |
title.remove("table"); |
| 154 |
cint64 slashPos = title.lastIndexOf("/"); |
| 155 |
if (slashPos >= 0) { |
| 156 |
title = title.mid(slashPos+1); |
| 157 |
} |
| 158 |
title.replace("memory-usage", "Reaoner Max Memory Usage, "); |
| 159 |
title.replace("-", " "); |
| 160 |
title.replace("sorted","Sorted"); |
| 161 |
if (title.contains(" ascending")) { |
| 162 |
title.replace(" ascending",""); |
| 163 |
title.append(" in Ascending Order "); |
| 164 |
} |
| 165 |
if (title.contains(" descending")) { |
| 166 |
title.replace(" descending",""); |
| 167 |
title.append(" in Descending Order "); |
| 168 |
} |
| 169 |
return title; |
| 170 |
} |
| 171 |
}; // end namespace Evaluation |
| 172 |
|
| 173 |
}; // end namespace Test |
| 174 |
|
| 175 |
}; // end namespace Konclude |