# This file is part of the LibreOffice project. # This Source Code Form is subject to the terms of the Mozilla Public # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/.
with open(path,'r') as callgrindFile:
lines = callgrindFile.readlines()
for line in lines: if line.startswith(trigger):
curTestComment = line[trigger_len:].replace("\n","") elif line.startswith(totals):
total = line[totals_len:].replace("\n","")
if curTestComment isNoneor total isNone: returnNone
if needsCsvHeader:
results.append(["lastCommit", "lastCommitDate", "test filename", "dump comment", "count", "filename"])
for dirName, subdirList, fileList in os.walk(rootDir):
files = [f for f in fileList if f.startswith("callgrind.out.")] for fname in files:
found = parseFile(dirName, fname, lastCommit) if found isnotNone:
results.append(found) return results
def getLastCommitInfo():
stream = os.popen("git log --date=iso")
line = stream.readline()
commitId = line.replace("commit ","").replace("\n","")
line = stream.readline()
line = stream.readline()
commitDate = line.replace("Date: ","").replace("\n","").strip()
return commitId, commitDate
def displayUsage():
usage = """
Parses the callgrind results of make perfcheck
Arguments :
--csv-file\t\t the target CSV file - new or containing previous tests - default : perfcheckResult.csv
--source-directory\t directory containing make perfcheck output - default : ./workdir/CppunitTest
--alert-type\t\t mode for calculating alerts - valid values : previous first
--alert-value\t\t alert threshold in % - default = 10
for o, a in opts: if o == '--help':
displayUsage()
sys.exit() elif o == "--csv-file":
targetFileName = a elif o == "--source-directory":
sourceDirectory = a elif o == "--alert-type":
alertType = a elif o == "--alert-value":
alertValue = float(a) else: raise WrongArguments
# check if sourceDirectory exists ifnot os.path.isdir(sourceDirectory):
print("sourceDirectory %s not found - Aborting" % (sourceDirectory))
sys.exit(1)
# read the complete CSV file if os.path.isfile(targetFileName):
readCsvFile(targetFileName)
needsCsvHeader = False else:
needsCsvHeader = True
# last commit Id
lastCommitId, lastCommitDate = getLastCommitInfo()
# walker through directory if lastCommitId notin colsResult:
lastCommit = (lastCommitId, lastCommitDate)
results = processDirectory(sourceDirectory, needsCsvHeader, lastCommit)
ppResults = "\n".join(["\t".join(row) for row in results])
print('\nNew results\n' + ppResults)
# append raw result with open(targetFileName,'a') as csvfile:
writer = csv.writer(csvfile, delimiter='\t')
writer.writerows(results)
print("\nCSV file written at " + targetFileName + '\n')
else:
print("\nCSV file up to date " + targetFileName + '\n')
with open(targetFileName + '.col','w') as fileResult: for k in colsResult:
mLine += k + "\t" + colsResult[k]['date'] + "\t" for t in allTests: if t in colsResult[k]['values']:
mValue= colsResult[k]['values'][t] if t notin alertTest:
alertTest[t] = {}
alertTest[t][colsResult[k]['date']] = mValue else:
mValue = ""
mLine += mValue + "\t"
mLine += "\n"
# write columned result
fileResult.write(mLine)
print("Columned file written at " + targetFileName + '.col\n')
if delta > float(alertValue):
alertResult += t + "\t" + "{:.2f}".format(delta) + " %\n"
if alertResult != "":
print("!!!!!!!! ALERT !!!!!!!\n")
print(alertResult)
¤ Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.0.16Bemerkung:
(vorverarbeitet)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.