summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjasplin <qt-info@nokia.com>2011-03-10 15:24:09 +0100
committerjasplin <qt-info@nokia.com>2011-03-10 15:24:09 +0100
commitf391632c21afb4d122cd6e22c2de967257faddde (patch)
tree234b49a0e6faad7d659bfc12f77a1e6b6d9eb90a
parent4e912ee858748285c5edc1c29cb44d38b6afac2e (diff)
Let uploadresults.py execute computerankings.py itself as appropriate.
-rwxr-xr-xscripts/computerankings.py (renamed from scripts/finalizeresults.py)34
-rwxr-xr-xscripts/uploadresults.py97
2 files changed, 112 insertions, 19 deletions
diff --git a/scripts/finalizeresults.py b/scripts/computerankings.py
index dafa858..6726806 100755
--- a/scripts/finalizeresults.py
+++ b/scripts/computerankings.py
@@ -12,8 +12,8 @@ from misc import (
def printUsage():
print (
"usage:" + sys.argv[0] +
- " --help | [--dbhost H --dbport P] --db D --host H --platform P "
- "--branch B --sha1 S")
+ " --help | [--dbhost H] [--dbport P] --db D --host H --platform P "
+ "--branch B --sha1 S [--noprogress NP]")
def printVerboseUsage():
printUsage()
@@ -40,6 +40,8 @@ def printVerboseUsage():
" --sha1: The tested revision within the branch. Can be "
"extracted using 'git log -1 --pretty=format:%H' (assuming the "
"tested revision is the current head revision).")
+ print(
+ " --noprogress: Specify \'true\' to disable progress indicator.")
# ### 2 B DOCUMENTED!
@@ -188,7 +190,8 @@ def getFirstUploadTimestamp(snapshots, sha1_id):
# ### 2 B DOCUMENTED!
-def updateRankings(host_id, platform_id, branch_id, sha12_id, context2_id):
+def updateRankings(
+ host_id, platform_id, branch_id, sha12_id, context2_id, no_progress):
# Get all snapshots matching the host/platform/branch combination:
sys.stdout.write("getting snapshots ... ")
@@ -263,11 +266,17 @@ def updateRankings(host_id, platform_id, branch_id, sha12_id, context2_id):
sys.exit(1)
# Get time series statistics for all benchmarks:
+ if no_progress:
+ sys.stdout.write("getting time series statistics ... ")
bmstats_list = getBMTimeSeriesStatsList(
host_id, platform_id, branch_id, snapshots, None, difftol, durtolmin,
- durtolmax, printProgress, "getting time series statistics")
+ durtolmax, None if no_progress else printProgress,
+ "getting time series statistics")
- sys.stdout.write("\n")
+ if no_progress:
+ sys.stdout.write("done\n")
+ else:
+ sys.stdout.write("\n")
# *** Compute rankings **************************************************
@@ -288,12 +297,12 @@ def updateRankings(host_id, platform_id, branch_id, sha12_id, context2_id):
sys.exit(1)
nameToIndex = { "QS": 3, "LCSSR": 4, "LCSSI": 5, "LCSS1R": 6, "LCSS1I": 7 }
for name in nameToIndex:
- sys.stdout.write("registering ranking for " + name + " ...\r")
+ sys.stdout.write("registering ranking for " + name + " ... ")
sys.stdout.flush()
registerRanking(
table, nameToIndex[name], name, context1_id, context2_id)
-
- sys.stdout.write("\n")
+ sys.stdout.write("done\n")
+ sys.stdout.flush()
# --- END Global functions ----------------------------------------------
@@ -342,12 +351,15 @@ if context2_id == -1:
print "error: no results found for this context"
sys.exit(1)
-
-updateRankings(host_id, platform_id, branch_id, sha12_id, context2_id)
+updateRankings(
+ host_id, platform_id, branch_id, sha12_id, context2_id,
+ ("noprogress" in options) and (
+ (options["noprogress"] == "1")
+ or (options["noprogress"].lower() == "true")))
# Write to database:
commit()
-print "finalization done"
+print "rankings computation done"
# --- END Main program ----------------------------------------------
diff --git a/scripts/uploadresults.py b/scripts/uploadresults.py
index 3c92691..f0db5a7 100755
--- a/scripts/uploadresults.py
+++ b/scripts/uploadresults.py
@@ -1,9 +1,11 @@
#!/usr/bin/env python
import sys
+from subprocess import Popen, PIPE
from xml.dom.minidom import parse
from dbaccess import setDatabase, execQuery, commit
-from misc import getOptions, textToId, isValidSHA1, getContext
+from misc import (
+ getOptions, textToId, idToText, isValidSHA1, getContext, getAllSnapshots)
# --- BEGIN Global functions ----------------------------------------------
@@ -253,6 +255,75 @@ def rankingsExist(host, platform, branch, sha1):
return len(matches) > 0
+# Returns the context ID if found, otherwise -1:
+def getContextIdFromNames(options):
+ host_id = textToId("host", options["host"])
+ platform_id = textToId("platform", options["platform"])
+ branch_id = textToId("branch", options["branch"])
+ sha1_id = textToId("sha1", options["sha1"])
+ return getContext(host_id, platform_id, branch_id, sha1_id)
+
+
+# Returns True iff this context exists:
+def contextExists(options):
+ return getContextIdFromNames(options) != -1
+
+
+# Returns True iff no more results are to be expected for this context:
+def contextComplete(options):
+
+ max_sample_size = 5 # WARNING: This value must match the corresponding value
+ # in the script that triggers benchmark execution.
+
+ context_id = getContextIdFromNames(options)
+ sample_size = execQuery(
+ "SELECT count(*) FROM"
+ " (SELECT DISTINCT uploadId from result where contextId=%d) AS foo;"
+ % context_id)[0][0]
+
+ return sample_size >= max_sample_size
+
+
+# Executes the external computerankings.py script with appropriate arguments.
+def execComputeRankings(options, use_latest_snapshot):
+
+ if use_latest_snapshot:
+ # Attempt to use the latest available snapshot for this
+ # host/platform/branch combination as the actual snapshot:
+ host_id = textToId("host", options["host"])
+ platform_id = textToId("platform", options["platform"])
+ branch_id = textToId("branch", options["branch"])
+ snapshots = getAllSnapshots(host_id, platform_id, branch_id)
+ if len(snapshots) > 0:
+ actual_snapshot = idToText("sha1", snapshots[-1][0])
+ else:
+ return # special case when no snapshots exist yet
+ else:
+ actual_snapshot = options["sha1"]
+
+ cmd = [
+ "computerankings.py", "--db", options["db"], "--host", options["host"],
+ "--platform", options["platform"], "--branch", options["branch"],
+ "--sha1", actual_snapshot, "--noprogress", "true"]
+ if "dbhost" in options:
+ cmd += ["--dbhost", options["dbhost"]]
+ if "dbport" in options:
+ cmd += ["--dbport", options["dbport"]]
+
+ p = Popen(cmd, stdout = PIPE, stderr = PIPE)
+ stdout, stderr = p.communicate()
+ if (p.returncode != 0):
+ print "failed to execute command '" + cmd + "':"
+ print " return code:", p.returncode
+ print " stdout: >%s<" % stdout.strip()
+ print " stderr: >%s<" % stderr.strip()
+ else:
+ print "computerankings.py executed successfully:"
+ print " return code:", p.returncode
+ print " stdout: >%s<" % stdout.strip()
+ print " stderr: >%s<" % stderr.strip()
+
+
# --- END Global functions ----------------------------------------------
@@ -281,27 +352,37 @@ setDatabase(
# Reject uploading if rankings exist for this context, since that would
# require a recomputation of these rankings.
#
-# (Note that this check if sufficient as long as we assume that results
-# are uploaded in an order that is consistent with the order of the
-# corresponding SHA-1s in the branch in question (i.e. that results will
-# never be uploaded for a SHA-1 that precedes (is "older" than) a SHA-1 for
-# which results already exist). This assumption ensures that results for a
-# new SHA-1 will not alter the input for any existing ranking.)
+# (Note that we only need to check the current SHA-1 as long as we assume that
+# results are uploaded in an order that is consistent with the order of the
+# corresponding SHA-1s in the branch in question: Rankings for earlier SHA-1s
+# will not be affected by results for this SHA-1, and rankings for later
+# SHA-1s cannot exist a this point (by assumption).)
if rankingsExist(
options["host"], options["platform"], options["branch"], options["sha1"]):
print "error: this context has already been finalized"
sys.exit(1)
+# If this is the first set of results for the current context, we finalize the
+# results for the same context, only one snapshot back:
+if not contextExists(options):
+ execComputeRankings(options, True)
+
+# Parse results and store them in the database:
try:
results = extractResults(options["file"])
except BaseException as e:
print "error: failed to parse XML file:", e.args[0]
sys.exit(1)
-
uploadToDatabase(
options["host"], options["platform"], options["branch"], options["sha1"],
results)
print "uploading done"
+# If no more results are expected in this context, we can finalize the
+# results already at this point:
+if contextComplete(options):
+ execComputeRankings(options, False)
+
+
# --- END Main program ----------------------------------------------