[Libreoffice-commits] core.git: bin/parse-perfcheck.py
Laurent Godard
lgodard.libre at laposte.net
Wed Oct 29 04:01:06 PDT 2014
bin/parse-perfcheck.py | 125 +++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 125 insertions(+)
New commits:
commit 4f5f6d2444a24138c3d3d378771f87cb06427195
Author: Laurent Godard <lgodard.libre at laposte.net>
Date: Tue Oct 14 09:50:39 2014 +0200
perfcheck : parse callgrind.out results to build csv file
appends results on existing target file
Change-Id: Icd897b090e1d1ed896b88a2f5923e8f35e95e5d2
diff --git a/bin/parse-perfcheck.py b/bin/parse-perfcheck.py
new file mode 100755
index 0000000..afa22a4
--- /dev/null
+++ b/bin/parse-perfcheck.py
@@ -0,0 +1,125 @@
+#!/usr/bin/python
+
+# 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/.
+
+import sys
+import os
+import time
+
+parseTrigger = "desc: Trigger: Client Request: "
+parseTotal = "totals: "
+
+separator = os.path.sep
+
+lastCommitId = ""
+needsCsvHeader = True
+
+def processDirectory(rootDir):
+
+ if needsCsvHeader:
+ intermediateResult = "lastCommit\ttest name\tfiledatetime\tdump comment\tcount\n"
+ else:
+ intermediateResult = ""
+
+ for dirName, subdirList, fileList in os.walk(rootDir):
+
+ files = [ fi for fi in fileList if fi.startswith("callgrind.out.") ]
+ for fname in files:
+ found = parseFile(dirName, fname)
+ if found != "":
+ intermediateResult += found
+
+ return intermediateResult
+
+def parseFile(dirname, filename):
+
+ path = dirname + separator + filename
+ callgrindFile = open(path,'r')
+ lines = callgrindFile.readlines()
+
+ message = ""
+ total = ""
+
+ for line in lines:
+ if line.startswith(parseTrigger):
+ message = line[len(parseTrigger):]
+ elif line.startswith(parseTotal):
+ total = line[len(parseTotal):]
+
+ callgrindFile.close()
+
+ if message == "" and total == "0\n":
+ return ""
+
+ dirs = dirname.split(separator)
+ currentTest = dirs[-1:]
+ testName = currentTest[0].replace(".test.core","")
+
+ message = message.replace("\n","")
+
+ fileDate = time.strftime('%m/%d/%Y %H:%M:%S', time.gmtime(os.path.getmtime(path)))
+
+ result = lastCommitId + "\t" + testName + "\t" + fileDate + "\t" + message + "\t" + total
+
+ return result
+
+def getLastCommitId():
+
+ stream = os.popen("git log")
+ line = stream.readline()
+ return line.replace("commit ","").replace("\n","")
+
+def displayUsage():
+
+ print
+ print "Parses the callgrind results of make percheck"
+ print
+ print "Usage: bin/parse_perfcheck.py [targetFileName = perfcheckResult.csv] [sourceDirectory = ./workdir/CppunitTest]"
+ print "default assumes running from core root directory"
+ print
+
+if __name__ == '__main__':
+
+ #check args
+
+ if len(sys.argv) < 3:
+ if len(sys.argv) == 2:
+ if sys.argv[1] == "--help":
+ displayUsage()
+ sys.exit(1)
+ else:
+ targetFileName = sys.argv[1]
+ sourceDirectory = "./workdir/CppunitTest"
+ elif len(sys.argv) == 1:
+ targetFileName = "perfcheckResult.csv"
+ sourceDirectory = "./workdir/CppunitTest"
+ else:
+ displayUsage()
+ sys.exit(1)
+ else:
+ targetFileName = sys.argv[1]
+ sourceDirectory = sys.argv[2]
+
+ # check if sourceDirectorty exists
+ if not os.path.isdir(sourceDirectory):
+ print "sourceDirectorty %s not found - Aborting" % (sourceDirectory)
+ sys.exit(1)
+
+ # last commit Id
+ lastCommitId = getLastCommitId()
+
+ # needs header in csv file ?
+ needsCsvHeader = not os.path.isfile(targetFileName)
+
+ # call walker
+ globalResult = processDirectory(sourceDirectory)
+
+ print globalResult
+
+ # write result
+ fileResult = open(targetFileName,'a')
+ fileResult.write(globalResult)
+ fileResult.close()
More information about the Libreoffice-commits
mailing list