summaryrefslogtreecommitdiffstats
path: root/scripts/finalizeresults.py
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/finalizeresults.py')
-rwxr-xr-xscripts/finalizeresults.py41
1 files changed, 17 insertions, 24 deletions
diff --git a/scripts/finalizeresults.py b/scripts/finalizeresults.py
index 05f7949..60c41f0 100755
--- a/scripts/finalizeresults.py
+++ b/scripts/finalizeresults.py
@@ -3,7 +3,7 @@
import sys
from dbaccess import setDatabase, execQuery, commit
from misc import (
- textToId, getAllSnapshots, getLastRankingSnapshot, isValidSHA1,
+ textToId, getAllSnapshots, getLastRankingSnapshot, getContext, isValidSHA1,
getBMTimeSeriesStatsList)
@@ -67,8 +67,7 @@ def qualityScore(lsd, ni, nz, nc, mdrse):
# Assumptions:
# - A high value should be ranked above a small one.
# - A negative value is undefined and gets an invalid ranking position, i.e. -1.
-def registerRanking(
- table, stat_index, stat_name, host_id, platform_id, branch_id, sha1_id):
+def registerRanking(table, stat_index, stat_name, context_id):
table.sort(key=lambda x: x[stat_index], reverse=True)
@@ -101,10 +100,7 @@ def registerRanking(
# Insert or update the corresponding row in the 'ranking' table:
query = (
"SELECT merge_ranking("
- + str(host_id)
- + ", " + str(platform_id)
- + ", " + str(branch_id)
- + ", " + str(sha1_id)
+ + str(context_id)
+ ", " + str(benchmark_id)
+ ", " + str(metric_id)
+ ", " + str(stat_id)
@@ -112,7 +108,6 @@ def registerRanking(
+ ", " + str(ranking_pos)
+ ");"
)
-
execQuery(query, False)
@@ -174,7 +169,7 @@ def getFirstUploadTimestamp(snapshots, sha1_id):
# ### 2 B DOCUMENTED!
-def updateRankings(host_id, platform_id, branch_id, sha1_id):
+def updateRankings(host_id, platform_id, branch_id, sha1_id, context_id):
# Get all snapshots matching the host/platform/branch combination:
sys.stdout.write("getting snapshots ... ")
@@ -185,8 +180,8 @@ def updateRankings(host_id, platform_id, branch_id, sha1_id):
# Rankings will normally be computed once a week for each
- # host/context/branch combination (note the tradeoff between update
- # frequency and database space consumption):
+ # host/platform/branch combination (note the tradeoff between update
+ # frequency and database size):
ranking_interval = 3600 * 24 * 7 # secs in a week
# Rankings will be updated if at least one of the following
@@ -198,17 +193,12 @@ def updateRankings(host_id, platform_id, branch_id, sha1_id):
force_cond = force_ranking
if not force_cond:
- last_ranking_sha1_id = getLastRankingSnapshot(
- host_id, platform_id, branch_id, snapshots)[0]
- print "last_ranking_sha1_id:", last_ranking_sha1_id
+ last_ranking_sha1_id, last_ranking_timestamp = getLastRankingSnapshot(
+ host_id, platform_id, branch_id)
empty_cond = last_ranking_sha1_id < 0
if not empty_cond:
- last_ranking_timestamp = getFirstUploadTimestamp(
- snapshots, last_ranking_sha1_id)
- if last_ranking_timestamp < 0:
- print (
- "failed to extract last_ranking_timestamp (programming error?)")
- sys.exit(1)
+ assert last_ranking_timestamp >= 0
+
target_timestamp = getFirstUploadTimestamp(snapshots, sha1_id)
if target_timestamp < 0:
print (
@@ -273,9 +263,7 @@ def updateRankings(host_id, platform_id, branch_id, sha1_id):
for name in nameToIndex:
sys.stdout.write("registering ranking for " + name + " ...\r")
sys.stdout.flush()
- registerRanking(
- table, nameToIndex[name], name, host_id, platform_id, branch_id,
- sha1_id)
+ registerRanking(table, nameToIndex[name], name, context_id)
sys.stdout.write("\n")
@@ -320,8 +308,13 @@ if sha1_id == -1:
print "no such SHA-1:", sha1
sys.exit(1)
+context_id = getContext(host_id, platform_id, branch_id, sha1_id)
+if context_id == -1:
+ print "no results found for this host/platform/branch/SHA-1 combination"
+ sys.exit(1)
+
-updateRankings(host_id, platform_id, branch_id, sha1_id)
+updateRankings(host_id, platform_id, branch_id, sha1_id, context_id)
# Make sure everything is written to the database: