| 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 "CReasonerEvaluationSpecifiedTimeExtractor.h" |
| 22 |
|
| 23 |
|
| 24 |
namespace Konclude { |
| 25 |
|
| 26 |
namespace Test { |
| 27 |
|
| 28 |
namespace Evaluation { |
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
CReasonerEvaluationSpecifiedTimeExtractor::CReasonerEvaluationSpecifiedTimeExtractor(CReasonerEvaluationExtractor::EXTRACTORTYPE extractorType, double timelimit, double errorPunishmentTime, CReasonerEvaluationDataValueCacher* cacher) { |
| 33 |
mTimelimit = timelimit; |
| 34 |
mErrorPunishmentTime = errorPunishmentTime; |
| 35 |
mCacher = cacher; |
| 36 |
|
| 37 |
mExtractorType = extractorType; |
| 38 |
|
| 39 |
mClassificationExtractionTagList << "Classify"; |
| 40 |
mConsistencyExtractionTagList << "IsKBSatisfiable"; |
| 41 |
mSatisfiabilityExtractionTagList << "IsClassSatisfiable"; |
| 42 |
mRealizationExtractionTagList << "Realize"; |
| 43 |
mComplexQueryingExtractionTagList << "SelectQuery" << "AskQuery"; |
| 44 |
|
| 45 |
mCalculationExtractionTagList += mClassificationExtractionTagList; |
| 46 |
mCalculationExtractionTagList += mConsistencyExtractionTagList; |
| 47 |
mCalculationExtractionTagList += mSatisfiabilityExtractionTagList; |
| 48 |
mCalculationExtractionTagList += mRealizationExtractionTagList; |
| 49 |
} |
| 50 |
|
| 51 |
|
| 52 |
|
| 53 |
|
| 54 |
CReasonerEvaluationDoubleDataValue* CReasonerEvaluationSpecifiedTimeExtractor::extractSpecifiedTimesEvaluationData(QDomDocument& document, const QString& responseFileString, const QStringList& extractionTagList, CReasonerEvaluationExtractor::EXTRACTORTYPE extractionType) { |
| 55 |
CReasonerEvaluationDoubleDataValue* doubleEvalValue = nullptr; |
| 56 |
|
| 57 |
if (mCacher) { |
| 58 |
doubleEvalValue = dynamic_cast<CReasonerEvaluationDoubleDataValue*>(mCacher->getCachedDataValue(responseFileString,(cint64)extractionType)); |
| 59 |
} |
| 60 |
|
| 61 |
if (!doubleEvalValue) { |
| 62 |
double doubleValue = 0; |
| 63 |
bool errorOccured = false; |
| 64 |
bool timeoutOccured = false; |
| 65 |
bool allRespTimeValid = true; |
| 66 |
bool lastTimeoutOccured = false; |
| 67 |
bool dataAvailable = false; |
| 68 |
|
| 69 |
QDomElement rootEl = document.documentElement(); |
| 70 |
|
| 71 |
|
| 72 |
QDomElement childEl = rootEl.firstChildElement(); |
| 73 |
while (!childEl.isNull()) { |
| 74 |
QString timeoutString = childEl.attribute("timeout"); |
| 75 |
if (timeoutString == "1") { |
| 76 |
lastTimeoutOccured = true; |
| 77 |
} |
| 78 |
|
| 79 |
QString requestCommandString = childEl.attribute("request-command"); |
| 80 |
bool useTagTime = false; |
| 81 |
foreach (const QString& extractionTag, extractionTagList) { |
| 82 |
if (requestCommandString == extractionTag) { |
| 83 |
useTagTime = true; |
| 84 |
dataAvailable = true; |
| 85 |
break; |
| 86 |
} |
| 87 |
} |
| 88 |
if (useTagTime) { |
| 89 |
if (lastTimeoutOccured) { |
| 90 |
timeoutOccured = true; |
| 91 |
} |
| 92 |
if (!timeoutOccured) { |
| 93 |
bool validResponseTime = false; |
| 94 |
QString respTimeString = childEl.attribute("response-time","timeout"); |
| 95 |
double respTime = respTimeString.toDouble(&validResponseTime); |
| 96 |
if (validResponseTime) { |
| 97 |
doubleValue += respTime; |
| 98 |
} |
| 99 |
if (childEl.tagName() == "Error") { |
| 100 |
validResponseTime = false; |
| 101 |
} |
| 102 |
allRespTimeValid &= validResponseTime; |
| 103 |
} |
| 104 |
} |
| 105 |
childEl = childEl.nextSiblingElement(); |
| 106 |
} |
| 107 |
|
| 108 |
if (timeoutOccured) { |
| 109 |
doubleValue = mTimelimit; |
| 110 |
} |
| 111 |
if (mTimelimit >= 0) { |
| 112 |
doubleValue = qMin(mTimelimit,doubleValue); |
| 113 |
} |
| 114 |
//if (errorOccured || !allRespTimeValid) { |
| 115 |
// if (mTimelimit >= 0) { |
| 116 |
// doubleValue = mTimelimit+mErrorPunishmentTime; |
| 117 |
// } else { |
| 118 |
// doubleValue = mErrorPunishmentTime; |
| 119 |
// } |
| 120 |
//} |
| 121 |
doubleEvalValue = new CReasonerEvaluationDoubleDataValue(doubleValue); |
| 122 |
if (!dataAvailable) { |
| 123 |
doubleEvalValue->setDataNotAvailableFlag(); |
| 124 |
} |
| 125 |
|
| 126 |
if (mCacher) { |
| 127 |
mCacher->addDataValueToCache(responseFileString,(cint64)extractionType,doubleEvalValue); |
| 128 |
} |
| 129 |
|
| 130 |
} |
| 131 |
return doubleEvalValue; |
| 132 |
} |
| 133 |
|
| 134 |
|
| 135 |
CReasonerEvaluationDoubleDataValue* CReasonerEvaluationSpecifiedTimeExtractor::extractClassificationEvaluationData(QDomDocument& document, const QString& responseFileString) { |
| 136 |
return extractSpecifiedTimesEvaluationData(document,responseFileString,mClassificationExtractionTagList,CReasonerEvaluationExtractor::CLASSIFICATIONTIMEEXTRACTOR); |
| 137 |
} |
| 138 |
|
| 139 |
|
| 140 |
CReasonerEvaluationDoubleDataValue* CReasonerEvaluationSpecifiedTimeExtractor::extractComplexQueryingEvaluationData(QDomDocument& document, const QString& responseFileString) { |
| 141 |
return extractSpecifiedTimesEvaluationData(document, responseFileString, mComplexQueryingExtractionTagList, CReasonerEvaluationExtractor::COMPLEXQUERYINGTIMEEXTRACTOR); |
| 142 |
} |
| 143 |
|
| 144 |
|
| 145 |
CReasonerEvaluationDoubleDataValue* CReasonerEvaluationSpecifiedTimeExtractor::extractRealizationEvaluationData(QDomDocument& document, const QString& responseFileString) { |
| 146 |
return extractSpecifiedTimesEvaluationData(document,responseFileString,mRealizationExtractionTagList,CReasonerEvaluationExtractor::REALIZATIONTIMEEXTRACTOR); |
| 147 |
} |
| 148 |
|
| 149 |
|
| 150 |
|
| 151 |
CReasonerEvaluationDoubleDataValue* CReasonerEvaluationSpecifiedTimeExtractor::extractConsistencyEvaluationData(QDomDocument& document, const QString& responseFileString) { |
| 152 |
return extractSpecifiedTimesEvaluationData(document,responseFileString,mConsistencyExtractionTagList,CReasonerEvaluationExtractor::CONSISTENCYTIMEEXTRACTOR); |
| 153 |
} |
| 154 |
|
| 155 |
|
| 156 |
|
| 157 |
CReasonerEvaluationDoubleDataValue* CReasonerEvaluationSpecifiedTimeExtractor::extractSatisfiabilityEvaluationData(QDomDocument& document, const QString& responseFileString) { |
| 158 |
return extractSpecifiedTimesEvaluationData(document,responseFileString,mSatisfiabilityExtractionTagList,CReasonerEvaluationExtractor::SATISFIABILITYTIMEEXTRACTOR); |
| 159 |
} |
| 160 |
|
| 161 |
|
| 162 |
|
| 163 |
CReasonerEvaluationDoubleDataValue* CReasonerEvaluationSpecifiedTimeExtractor::extractCalculationEvaluationData(QDomDocument& document, const QString& responseFileString) { |
| 164 |
return extractSpecifiedTimesEvaluationData(document,responseFileString,mCalculationExtractionTagList,CReasonerEvaluationExtractor::CALCULATIONTIMEEXTRACTOR); |
| 165 |
} |
| 166 |
|
| 167 |
|
| 168 |
|
| 169 |
CReasonerEvaluationDoubleDataValue* CReasonerEvaluationSpecifiedTimeExtractor::extractLoadingEvaluationData(QDomDocument& document, const QString& responseFileString) { |
| 170 |
CReasonerEvaluationDoubleDataValue* doubleEvalValue = nullptr; |
| 171 |
|
| 172 |
if (mCacher) { |
| 173 |
doubleEvalValue = dynamic_cast<CReasonerEvaluationDoubleDataValue*>(mCacher->getCachedDataValue(responseFileString,(cint64)CReasonerEvaluationExtractor::LOADINGTIMEEXTRACTOR)); |
| 174 |
} |
| 175 |
|
| 176 |
if (!doubleEvalValue) { |
| 177 |
double doubleValue = 0; |
| 178 |
bool errorOccured = false; |
| 179 |
bool timeoutOccured = false; |
| 180 |
bool allRespTimeValid = true; |
| 181 |
bool lastTimeoutOccured = false; |
| 182 |
|
| 183 |
QDomElement rootEl = document.documentElement(); |
| 184 |
|
| 185 |
|
| 186 |
QDomElement childEl = rootEl.firstChildElement(); |
| 187 |
while (!childEl.isNull()) { |
| 188 |
QString timeoutString = childEl.attribute("timeout"); |
| 189 |
if (timeoutString == "1") { |
| 190 |
lastTimeoutOccured = true; |
| 191 |
} |
| 192 |
|
| 193 |
QString requestCommandString = childEl.attribute("request-command"); |
| 194 |
if (requestCommandString == "Tell" || requestCommandString == "LoadOntologies" || requestCommandString == "LoadGraph" || requestCommandString == "GraphLoad") { |
| 195 |
if (lastTimeoutOccured) { |
| 196 |
timeoutOccured = true; |
| 197 |
} |
| 198 |
if (!timeoutOccured) { |
| 199 |
bool validResponseTime = false; |
| 200 |
QString respTimeString = childEl.attribute("response-time","timeout"); |
| 201 |
double respTime = respTimeString.toDouble(&validResponseTime); |
| 202 |
if (validResponseTime) { |
| 203 |
doubleValue += respTime; |
| 204 |
} |
| 205 |
if (childEl.tagName() != "OK") { |
| 206 |
validResponseTime = false; |
| 207 |
} |
| 208 |
allRespTimeValid &= validResponseTime; |
| 209 |
} |
| 210 |
} |
| 211 |
childEl = childEl.nextSiblingElement(); |
| 212 |
} |
| 213 |
|
| 214 |
if (timeoutOccured) { |
| 215 |
doubleValue = mTimelimit; |
| 216 |
} |
| 217 |
if (mTimelimit >= 0) { |
| 218 |
doubleValue = qMin(mTimelimit,doubleValue); |
| 219 |
} |
| 220 |
//if (errorOccured || !allRespTimeValid) { |
| 221 |
// if (mTimelimit >= 0) { |
| 222 |
// doubleValue = mTimelimit+mErrorPunishmentTime; |
| 223 |
// } else { |
| 224 |
// doubleValue = mErrorPunishmentTime; |
| 225 |
// } |
| 226 |
//} |
| 227 |
doubleEvalValue = new CReasonerEvaluationDoubleDataValue(doubleValue); |
| 228 |
|
| 229 |
if (mCacher) { |
| 230 |
mCacher->addDataValueToCache(responseFileString,(cint64)CReasonerEvaluationExtractor::LOADINGTIMEEXTRACTOR,doubleEvalValue); |
| 231 |
} |
| 232 |
|
| 233 |
} |
| 234 |
return doubleEvalValue; |
| 235 |
} |
| 236 |
|
| 237 |
|
| 238 |
CReasonerEvaluationDoubleDataValue* CReasonerEvaluationSpecifiedTimeExtractor::extractResultCountingEvaluationData(QDomDocument& document, const QString& responseFileString) { |
| 239 |
CReasonerEvaluationDoubleDataValue* doubleEvalValue = nullptr; |
| 240 |
|
| 241 |
if (mCacher) { |
| 242 |
doubleEvalValue = dynamic_cast<CReasonerEvaluationDoubleDataValue*>(mCacher->getCachedDataValue(responseFileString, (cint64)CReasonerEvaluationExtractor::RESPONSECOUNTEXTRACTOR)); |
| 243 |
} |
| 244 |
|
| 245 |
if (!doubleEvalValue) { |
| 246 |
double doubleValue = 0; |
| 247 |
bool errorOccured = false; |
| 248 |
bool allRespTimeValid = true; |
| 249 |
bool lastTimeoutOccured = false; |
| 250 |
|
| 251 |
QDomElement rootEl = document.documentElement(); |
| 252 |
|
| 253 |
|
| 254 |
QDomElement childEl = rootEl.firstChildElement(); |
| 255 |
while (!childEl.isNull()) { |
| 256 |
QString timeoutString = childEl.attribute("timeout"); |
| 257 |
if (timeoutString == "1") { |
| 258 |
lastTimeoutOccured = true; |
| 259 |
} |
| 260 |
|
| 261 |
QString requestCommandString = childEl.attribute("request-command"); |
| 262 |
if (requestCommandString == "SelectQuery") { |
| 263 |
bool validResponseCount = false; |
| 264 |
QString respTimeString = childEl.attribute("response-count", ""); |
| 265 |
double reportedResCount = respTimeString.toDouble(&validResponseCount); |
| 266 |
if (validResponseCount) { |
| 267 |
doubleValue += reportedResCount; |
| 268 |
} |
| 269 |
QDomElement resultsEl = childEl.nextSiblingElement("results"); |
| 270 |
while (!resultsEl.isNull()) { |
| 271 |
|
| 272 |
QDomElement resultEl = resultsEl.firstChildElement("result"); |
| 273 |
while (!resultEl.isNull()) { |
| 274 |
doubleValue++; |
| 275 |
resultEl = resultEl.nextSiblingElement("result"); |
| 276 |
} |
| 277 |
|
| 278 |
resultsEl = resultsEl.nextSiblingElement("results"); |
| 279 |
} |
| 280 |
} |
| 281 |
childEl = childEl.nextSiblingElement(); |
| 282 |
} |
| 283 |
|
| 284 |
//if (errorOccured || !allRespTimeValid) { |
| 285 |
// if (mTimelimit >= 0) { |
| 286 |
// doubleValue = mTimelimit+mErrorPunishmentTime; |
| 287 |
// } else { |
| 288 |
// doubleValue = mErrorPunishmentTime; |
| 289 |
// } |
| 290 |
//} |
| 291 |
doubleEvalValue = new CReasonerEvaluationDoubleDataValue(doubleValue); |
| 292 |
|
| 293 |
if (mCacher) { |
| 294 |
mCacher->addDataValueToCache(responseFileString, (cint64)CReasonerEvaluationExtractor::RESPONSECOUNTEXTRACTOR, doubleEvalValue); |
| 295 |
} |
| 296 |
|
| 297 |
} |
| 298 |
return doubleEvalValue; |
| 299 |
} |
| 300 |
|
| 301 |
|
| 302 |
|
| 303 |
|
| 304 |
|
| 305 |
CReasonerEvaluationDoubleDataValue* CReasonerEvaluationSpecifiedTimeExtractor::extractTotalResponseEvaluationData(QDomDocument& document, const QString& responseFileString) { |
| 306 |
CReasonerEvaluationDoubleDataValue* doubleEvalValue = nullptr; |
| 307 |
|
| 308 |
if (mCacher) { |
| 309 |
doubleEvalValue = dynamic_cast<CReasonerEvaluationDoubleDataValue*>(mCacher->getCachedDataValue(responseFileString,(cint64)CReasonerEvaluationExtractor::TOTALRESPONSETIMEEXTRACTOR)); |
| 310 |
} |
| 311 |
|
| 312 |
if (!doubleEvalValue) { |
| 313 |
double doubleValue = 0; |
| 314 |
bool errorOccured = false; |
| 315 |
bool timeoutOccured = false; |
| 316 |
bool validResponseTime = false; |
| 317 |
|
| 318 |
QDomElement rootEl = document.documentElement(); |
| 319 |
QString respTimeString = rootEl.attribute("response-time"); |
| 320 |
double respTime = respTimeString.toDouble(&validResponseTime); |
| 321 |
if (validResponseTime) { |
| 322 |
doubleValue += respTime; |
| 323 |
} |
| 324 |
|
| 325 |
|
| 326 |
QDomElement childEl = rootEl.firstChildElement(); |
| 327 |
while (!childEl.isNull()) { |
| 328 |
QString timeoutString = childEl.attribute("timeout"); |
| 329 |
if (timeoutString == "1") { |
| 330 |
timeoutOccured = true; |
| 331 |
} |
| 332 |
|
| 333 |
if (!timeoutOccured) { |
| 334 |
QString requestCommandString = childEl.tagName(); |
| 335 |
if (requestCommandString == "Error") { |
| 336 |
errorOccured = true; |
| 337 |
} |
| 338 |
} |
| 339 |
childEl = childEl.nextSiblingElement(); |
| 340 |
} |
| 341 |
|
| 342 |
if (timeoutOccured) { |
| 343 |
doubleValue = mTimelimit; |
| 344 |
} |
| 345 |
if (mTimelimit >= 0) { |
| 346 |
doubleValue = qMin(mTimelimit,doubleValue); |
| 347 |
} |
| 348 |
//if (errorOccured || !validResponseTime) { |
| 349 |
// if (mTimelimit >= 0) { |
| 350 |
// doubleValue = mTimelimit+mErrorPunishmentTime; |
| 351 |
// } else { |
| 352 |
// doubleValue = mErrorPunishmentTime; |
| 353 |
// } |
| 354 |
//} |
| 355 |
doubleEvalValue = new CReasonerEvaluationDoubleDataValue(doubleValue); |
| 356 |
|
| 357 |
if (mCacher) { |
| 358 |
mCacher->addDataValueToCache(responseFileString,(cint64)CReasonerEvaluationExtractor::TOTALRESPONSETIMEEXTRACTOR,doubleEvalValue); |
| 359 |
} |
| 360 |
|
| 361 |
} |
| 362 |
return doubleEvalValue; |
| 363 |
} |
| 364 |
|
| 365 |
|
| 366 |
|
| 367 |
|
| 368 |
|
| 369 |
|
| 370 |
CReasonerEvaluationDoubleDataValue* CReasonerEvaluationSpecifiedTimeExtractor::extractTimeoutErrorEvaluationData(QDomDocument& document, const QString& responseFileString) { |
| 371 |
CReasonerEvaluationDoubleDataValue* doubleEvalValue = nullptr; |
| 372 |
|
| 373 |
if (mCacher) { |
| 374 |
doubleEvalValue = dynamic_cast<CReasonerEvaluationDoubleDataValue*>(mCacher->getCachedDataValue(responseFileString,(cint64)CReasonerEvaluationExtractor::TIMEOUTERROREXTRACTOR)); |
| 375 |
} |
| 376 |
|
| 377 |
if (!doubleEvalValue) { |
| 378 |
cint64 errorTimeoutValue = 0; |
| 379 |
bool errorOccured = false; |
| 380 |
bool timeoutOccured = false; |
| 381 |
|
| 382 |
QDomElement rootEl = document.documentElement(); |
| 383 |
|
| 384 |
|
| 385 |
QDomElement childEl = rootEl.firstChildElement(); |
| 386 |
while (!childEl.isNull()) { |
| 387 |
QString timeoutString = childEl.attribute("timeout"); |
| 388 |
if (timeoutString == "1") { |
| 389 |
timeoutOccured = true; |
| 390 |
} |
| 391 |
|
| 392 |
if (!timeoutOccured) { |
| 393 |
QString requestCommandString = childEl.tagName(); |
| 394 |
if (requestCommandString == "Error") { |
| 395 |
errorOccured = true; |
| 396 |
} |
| 397 |
} |
| 398 |
childEl = childEl.nextSiblingElement(); |
| 399 |
} |
| 400 |
|
| 401 |
if (timeoutOccured || errorOccured) { |
| 402 |
++errorTimeoutValue; |
| 403 |
} |
| 404 |
doubleEvalValue = new CReasonerEvaluationDoubleDataValue(errorTimeoutValue); |
| 405 |
|
| 406 |
if (mCacher) { |
| 407 |
mCacher->addDataValueToCache(responseFileString,(cint64)CReasonerEvaluationSpecifiedTimeExtractor::TIMEOUTERROREXTRACTOR,doubleEvalValue); |
| 408 |
} |
| 409 |
|
| 410 |
} |
| 411 |
return doubleEvalValue; |
| 412 |
} |
| 413 |
|
| 414 |
|
| 415 |
|
| 416 |
|
| 417 |
|
| 418 |
CReasonerEvaluationDoubleDataValue* CReasonerEvaluationSpecifiedTimeExtractor::extractErrorEvaluationData(QDomDocument& document, const QString& responseFileString) { |
| 419 |
CReasonerEvaluationDoubleDataValue* doubleEvalValue = nullptr; |
| 420 |
|
| 421 |
if (mCacher) { |
| 422 |
doubleEvalValue = dynamic_cast<CReasonerEvaluationDoubleDataValue*>(mCacher->getCachedDataValue(responseFileString,(cint64)CReasonerEvaluationExtractor::ERROREXTRACTOR)); |
| 423 |
} |
| 424 |
|
| 425 |
if (!doubleEvalValue) { |
| 426 |
cint64 errorTimeoutValue = 0; |
| 427 |
bool errorOccured = false; |
| 428 |
bool timeoutOccured = false; |
| 429 |
|
| 430 |
QDomElement rootEl = document.documentElement(); |
| 431 |
|
| 432 |
|
| 433 |
QDomElement childEl = rootEl.firstChildElement(); |
| 434 |
while (!childEl.isNull()) { |
| 435 |
QString timeoutString = childEl.attribute("timeout"); |
| 436 |
if (timeoutString == "1") { |
| 437 |
timeoutOccured = true; |
| 438 |
} |
| 439 |
|
| 440 |
if (!timeoutOccured) { |
| 441 |
QString requestCommandString = childEl.tagName(); |
| 442 |
if (requestCommandString == "Error") { |
| 443 |
errorOccured = true; |
| 444 |
} |
| 445 |
} |
| 446 |
childEl = childEl.nextSiblingElement(); |
| 447 |
} |
| 448 |
|
| 449 |
if (errorOccured) { |
| 450 |
++errorTimeoutValue; |
| 451 |
} |
| 452 |
doubleEvalValue = new CReasonerEvaluationDoubleDataValue(errorTimeoutValue); |
| 453 |
|
| 454 |
if (mCacher) { |
| 455 |
mCacher->addDataValueToCache(responseFileString,(cint64)CReasonerEvaluationSpecifiedTimeExtractor::ERROREXTRACTOR,doubleEvalValue); |
| 456 |
} |
| 457 |
|
| 458 |
} |
| 459 |
return doubleEvalValue; |
| 460 |
} |
| 461 |
|
| 462 |
|
| 463 |
|
| 464 |
CReasonerEvaluationDoubleDataValue* CReasonerEvaluationSpecifiedTimeExtractor::extractMemoryUsageEvaluationData(QDomDocument& document, const QString& responseFileString) { |
| 465 |
CReasonerEvaluationDoubleDataValue* doubleEvalValue = nullptr; |
| 466 |
|
| 467 |
if (mCacher) { |
| 468 |
doubleEvalValue = dynamic_cast<CReasonerEvaluationDoubleDataValue*>(mCacher->getCachedDataValue(responseFileString, (cint64)CReasonerEvaluationExtractor::MEMORYUSAGEEXTRACTOR)); |
| 469 |
} |
| 470 |
|
| 471 |
if (!doubleEvalValue) { |
| 472 |
|
| 473 |
QDomElement rootEl = document.documentElement(); |
| 474 |
QString memoryUsageString = rootEl.attribute("maxMemoryUsage"); |
| 475 |
|
| 476 |
|
| 477 |
QDomElement childEl = rootEl.firstChildElement(); |
| 478 |
while (!childEl.isNull() && memoryUsageString.isEmpty()) { |
| 479 |
memoryUsageString = childEl.attribute("maxMemoryUsage"); |
| 480 |
childEl = childEl.nextSiblingElement(); |
| 481 |
} |
| 482 |
|
| 483 |
bool parsedOk = false; |
| 484 |
cint64 memoryUsage = memoryUsageString.toLongLong(&parsedOk); |
| 485 |
if (parsedOk) { |
| 486 |
doubleEvalValue = new CReasonerEvaluationDoubleDataValue(memoryUsage); |
| 487 |
} |
| 488 |
|
| 489 |
if (mCacher) { |
| 490 |
mCacher->addDataValueToCache(responseFileString, (cint64)CReasonerEvaluationSpecifiedTimeExtractor::MEMORYUSAGEEXTRACTOR, doubleEvalValue); |
| 491 |
} |
| 492 |
|
| 493 |
} |
| 494 |
return doubleEvalValue; |
| 495 |
} |
| 496 |
|
| 497 |
|
| 498 |
|
| 499 |
|
| 500 |
|
| 501 |
CReasonerEvaluationDoubleDataValue* CReasonerEvaluationSpecifiedTimeExtractor::extractTimeoutEvaluationData(QDomDocument& document, const QString& responseFileString) { |
| 502 |
CReasonerEvaluationDoubleDataValue* doubleEvalValue = nullptr; |
| 503 |
|
| 504 |
if (mCacher) { |
| 505 |
doubleEvalValue = dynamic_cast<CReasonerEvaluationDoubleDataValue*>(mCacher->getCachedDataValue(responseFileString,(cint64)CReasonerEvaluationExtractor::TIMEOUTEXTRACTOR)); |
| 506 |
} |
| 507 |
|
| 508 |
if (!doubleEvalValue) { |
| 509 |
cint64 errorTimeoutValue = 0; |
| 510 |
bool errorOccured = false; |
| 511 |
bool timeoutOccured = false; |
| 512 |
|
| 513 |
QDomElement rootEl = document.documentElement(); |
| 514 |
|
| 515 |
|
| 516 |
QDomElement childEl = rootEl.firstChildElement(); |
| 517 |
while (!childEl.isNull()) { |
| 518 |
QString timeoutString = childEl.attribute("timeout"); |
| 519 |
if (timeoutString == "1") { |
| 520 |
timeoutOccured = true; |
| 521 |
} |
| 522 |
childEl = childEl.nextSiblingElement(); |
| 523 |
} |
| 524 |
|
| 525 |
if (timeoutOccured) { |
| 526 |
++errorTimeoutValue; |
| 527 |
} |
| 528 |
doubleEvalValue = new CReasonerEvaluationDoubleDataValue(errorTimeoutValue); |
| 529 |
|
| 530 |
if (mCacher) { |
| 531 |
mCacher->addDataValueToCache(responseFileString,(cint64)CReasonerEvaluationSpecifiedTimeExtractor::TIMEOUTEXTRACTOR,doubleEvalValue); |
| 532 |
} |
| 533 |
|
| 534 |
} |
| 535 |
return doubleEvalValue; |
| 536 |
} |
| 537 |
|
| 538 |
|
| 539 |
|
| 540 |
CReasonerEvaluationStringValue* CReasonerEvaluationSpecifiedTimeExtractor::extractResponseFileEvaluationData(QDomDocument& document, const QString& responseFileString) { |
| 541 |
CReasonerEvaluationStringValue* responseFileEvalValue = nullptr; |
| 542 |
|
| 543 |
if (mCacher) { |
| 544 |
responseFileEvalValue = dynamic_cast<CReasonerEvaluationStringValue*>(mCacher->getCachedDataValue(responseFileString,(cint64)CReasonerEvaluationExtractor::RESPONSEFILEEXTRACTOR)); |
| 545 |
} |
| 546 |
|
| 547 |
if (!responseFileEvalValue) { |
| 548 |
responseFileEvalValue = new CReasonerEvaluationStringValue(responseFileString); |
| 549 |
|
| 550 |
if (mCacher) { |
| 551 |
mCacher->addDataValueToCache(responseFileString,(cint64)CReasonerEvaluationExtractor::RESPONSEFILEEXTRACTOR,responseFileEvalValue); |
| 552 |
} |
| 553 |
|
| 554 |
} |
| 555 |
return responseFileEvalValue; |
| 556 |
} |
| 557 |
|
| 558 |
|
| 559 |
|
| 560 |
|
| 561 |
CReasonerEvaluationStringValue* CReasonerEvaluationSpecifiedTimeExtractor::extractRequestFileEvaluationData(QDomDocument& document, const QString& responseFileString) { |
| 562 |
CReasonerEvaluationStringValue* requestFileEvalValue = nullptr; |
| 563 |
|
| 564 |
if (mCacher) { |
| 565 |
requestFileEvalValue = dynamic_cast<CReasonerEvaluationStringValue*>(mCacher->getCachedDataValue(responseFileString,(cint64)CReasonerEvaluationExtractor::REQUESTFILEEXTRACTOR)); |
| 566 |
} |
| 567 |
|
| 568 |
if (!requestFileEvalValue) { |
| 569 |
|
| 570 |
QDomElement rootEl = document.documentElement(); |
| 571 |
QString requestFileString = rootEl.attribute("test"); |
| 572 |
requestFileString = requestFileString.replace("./",""); |
| 573 |
requestFileString = requestFileString.replace("Evaluation/Requests/",""); |
| 574 |
|
| 575 |
requestFileEvalValue = new CReasonerEvaluationStringValue(requestFileString); |
| 576 |
|
| 577 |
if (mCacher) { |
| 578 |
mCacher->addDataValueToCache(responseFileString,(cint64)CReasonerEvaluationExtractor::REQUESTFILEEXTRACTOR,requestFileEvalValue); |
| 579 |
} |
| 580 |
|
| 581 |
} |
| 582 |
return requestFileEvalValue; |
| 583 |
} |
| 584 |
|
| 585 |
|
| 586 |
|
| 587 |
|
| 588 |
CReasonerEvaluationDataValue* CReasonerEvaluationSpecifiedTimeExtractor::extractEvaluationData(const QString& responseFileString) { |
| 589 |
CReasonerEvaluationDataValue* evalValue = nullptr; |
| 590 |
|
| 591 |
if (mCacher) { |
| 592 |
evalValue = mCacher->getCachedDataValue(responseFileString,(cint64)mExtractorType); |
| 593 |
} |
| 594 |
|
| 595 |
if (!evalValue) { |
| 596 |
|
| 597 |
QFile responseFile(responseFileString); |
| 598 |
if (responseFile.open(QIODevice::ReadOnly)) { |
| 599 |
QDomDocument document; |
| 600 |
document.setContent(&responseFile,false); |
| 601 |
QDomElement rootEl = document.documentElement(); |
| 602 |
responseFile.close(); |
| 603 |
|
| 604 |
CReasonerEvaluationDoubleDataValue* doubleClassificationEvalValue = extractClassificationEvaluationData(document,responseFileString); |
| 605 |
if (mExtractorType == CReasonerEvaluationExtractor::CLASSIFICATIONTIMEEXTRACTOR) { |
| 606 |
evalValue = doubleClassificationEvalValue; |
| 607 |
} |
| 608 |
CReasonerEvaluationDoubleDataValue* doubleComplexQueryEvalValue = extractComplexQueryingEvaluationData(document,responseFileString); |
| 609 |
if (mExtractorType == CReasonerEvaluationExtractor::COMPLEXQUERYINGTIMEEXTRACTOR) { |
| 610 |
evalValue = doubleComplexQueryEvalValue; |
| 611 |
} |
| 612 |
CReasonerEvaluationDoubleDataValue* doubleRealizationEvalValue = extractRealizationEvaluationData(document,responseFileString); |
| 613 |
if (mExtractorType == CReasonerEvaluationExtractor::REALIZATIONTIMEEXTRACTOR) { |
| 614 |
evalValue = doubleRealizationEvalValue; |
| 615 |
} |
| 616 |
CReasonerEvaluationDoubleDataValue* doubleConsistencyEvalValue = extractConsistencyEvaluationData(document,responseFileString); |
| 617 |
if (mExtractorType == CReasonerEvaluationExtractor::CONSISTENCYTIMEEXTRACTOR) { |
| 618 |
evalValue = doubleConsistencyEvalValue; |
| 619 |
} |
| 620 |
CReasonerEvaluationDoubleDataValue* doubleSatisfiabilityEvalValue = extractSatisfiabilityEvaluationData(document,responseFileString); |
| 621 |
if (mExtractorType == CReasonerEvaluationExtractor::SATISFIABILITYTIMEEXTRACTOR) { |
| 622 |
evalValue = doubleSatisfiabilityEvalValue; |
| 623 |
} |
| 624 |
CReasonerEvaluationDoubleDataValue* doubleCalculationEvalValue = extractCalculationEvaluationData(document,responseFileString); |
| 625 |
if (mExtractorType == CReasonerEvaluationExtractor::CALCULATIONTIMEEXTRACTOR) { |
| 626 |
evalValue = doubleCalculationEvalValue; |
| 627 |
} |
| 628 |
CReasonerEvaluationDoubleDataValue* doubleLoadingEvalValue = extractLoadingEvaluationData(document,responseFileString); |
| 629 |
if (mExtractorType == CReasonerEvaluationExtractor::LOADINGTIMEEXTRACTOR) { |
| 630 |
evalValue = doubleLoadingEvalValue; |
| 631 |
} |
| 632 |
CReasonerEvaluationDoubleDataValue* doubleResponseCountEvalValue = extractResultCountingEvaluationData(document, responseFileString); |
| 633 |
if (mExtractorType == CReasonerEvaluationExtractor::RESPONSECOUNTEXTRACTOR) { |
| 634 |
evalValue = doubleResponseCountEvalValue; |
| 635 |
} |
| 636 |
CReasonerEvaluationDoubleDataValue* doubleTotalEvalValue = extractTotalResponseEvaluationData(document,responseFileString); |
| 637 |
if (mExtractorType == CReasonerEvaluationExtractor::TOTALRESPONSETIMEEXTRACTOR) { |
| 638 |
evalValue = doubleTotalEvalValue; |
| 639 |
} |
| 640 |
CReasonerEvaluationDoubleDataValue* doubleTimeoutErrorEvalValue = extractTimeoutErrorEvaluationData(document,responseFileString); |
| 641 |
if (mExtractorType == CReasonerEvaluationExtractor::TIMEOUTERROREXTRACTOR) { |
| 642 |
evalValue = doubleTimeoutErrorEvalValue; |
| 643 |
} |
| 644 |
CReasonerEvaluationDoubleDataValue* doubleErrorEvalValue = extractErrorEvaluationData(document,responseFileString); |
| 645 |
if (mExtractorType == CReasonerEvaluationExtractor::ERROREXTRACTOR) { |
| 646 |
evalValue = doubleErrorEvalValue; |
| 647 |
} |
| 648 |
CReasonerEvaluationDoubleDataValue* doubleMemoryUsageEvalValue = extractMemoryUsageEvaluationData(document, responseFileString); |
| 649 |
if (mExtractorType == CReasonerEvaluationExtractor::MEMORYUSAGEEXTRACTOR) { |
| 650 |
evalValue = doubleMemoryUsageEvalValue; |
| 651 |
} |
| 652 |
CReasonerEvaluationDoubleDataValue* doubleTimeoutEvalValue = extractTimeoutEvaluationData(document,responseFileString); |
| 653 |
if (mExtractorType == CReasonerEvaluationExtractor::TIMEOUTEXTRACTOR) { |
| 654 |
evalValue = doubleTimeoutEvalValue; |
| 655 |
} |
| 656 |
CReasonerEvaluationStringValue* stringResponseFileEvalValue = extractResponseFileEvaluationData(document,responseFileString); |
| 657 |
if (mExtractorType == CReasonerEvaluationExtractor::RESPONSEFILEEXTRACTOR) { |
| 658 |
evalValue = stringResponseFileEvalValue; |
| 659 |
} |
| 660 |
CReasonerEvaluationStringValue* stringRequestFileEvalValue = extractRequestFileEvaluationData(document,responseFileString); |
| 661 |
if (mExtractorType == CReasonerEvaluationExtractor::REQUESTFILEEXTRACTOR) { |
| 662 |
evalValue = stringRequestFileEvalValue; |
| 663 |
} |
| 664 |
} |
| 665 |
|
| 666 |
} |
| 667 |
if (evalValue) { |
| 668 |
evalValue = evalValue->getCopy(); |
| 669 |
} |
| 670 |
return evalValue; |
| 671 |
} |
| 672 |
|
| 673 |
|
| 674 |
}; // end namespace Evaluation |
| 675 |
|
| 676 |
}; // end namespace Test |
| 677 |
|
| 678 |
}; // end namespace Konclude |