summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjasplin <qt-info@nokia.com>2011-02-03 09:09:33 +0100
committerjasplin <qt-info@nokia.com>2011-02-03 09:09:33 +0100
commit71030e53ceead30687702f17a72fe36c932ae22a (patch)
tree20c918af016047af077422bc195a855cecb6e322
parentd9765ea58c1db645f8225405dd3ca282812e355a (diff)
Fixed bugs that slipped through in the latest database restructuring.
-rw-r--r--database/scripts/privileges.sql4
-rw-r--r--scripts/getresultdetails2.py2
-rw-r--r--scripts/getstats1.py4
-rw-r--r--scripts/getstats2.py9
-rw-r--r--scripts/listcontexts.py5
-rw-r--r--scripts/listtestcases1.py23
-rw-r--r--scripts/listtestcases2.py37
-rw-r--r--scripts/misc.py23
-rw-r--r--scripts/singlecontextbmstats.py4
9 files changed, 56 insertions, 55 deletions
diff --git a/database/scripts/privileges.sql b/database/scripts/privileges.sql
index af11b1b..dba42f5 100644
--- a/database/scripts/privileges.sql
+++ b/database/scripts/privileges.sql
@@ -41,3 +41,7 @@ GRANT UPDATE ON metric_id_seq TO bmuser;
GRANT SELECT ON result TO bmuser;
GRANT INSERT ON result TO bmuser;
GRANT UPDATE ON result_id_seq TO bmuser;
+
+GRANT SELECT ON context TO bmuser;
+GRANT INSERT ON context TO bmuser;
+GRANT UPDATE ON context_id_seq TO bmuser;
diff --git a/scripts/getresultdetails2.py b/scripts/getresultdetails2.py
index c80c15f..20d128e 100644
--- a/scripts/getresultdetails2.py
+++ b/scripts/getresultdetails2.py
@@ -32,7 +32,7 @@ class GetResultDetails2:
self.metric_id = textToId("metric", metric)
def execute(self):
- self.sample2 = self.fetchSample(self.host1_id, self.platform1_id,
+ self.sample1 = self.fetchSample(self.host1_id, self.platform1_id,
self.branch1_id, self.sha11_id, self.benchmark_id,
self.metric_id)
self.sample2 = self.fetchSample(self.host2_id, self.platform2_id,
diff --git a/scripts/getstats1.py b/scripts/getstats1.py
index 8ed1cbc..c94123b 100644
--- a/scripts/getstats1.py
+++ b/scripts/getstats1.py
@@ -1,8 +1,8 @@
from dbaccess import execQuery, database
from singlecontextbmstats import (
SingleContextBMStats, extractSingleContextBMStats)
-from misc import idToText, textToId, benchmarkToComponents, printJSONHeader,
- getContext
+from misc import (
+ idToText, textToId, benchmarkToComponents, printJSONHeader, getContext)
class GetStats1:
diff --git a/scripts/getstats2.py b/scripts/getstats2.py
index 2352e5a..1fe3e2c 100644
--- a/scripts/getstats2.py
+++ b/scripts/getstats2.py
@@ -3,7 +3,8 @@ from singlecontextbmstats import (
SingleContextBMStats, extractSingleContextBMStats)
import math
from statlib import stats
-from misc import idToText, textToId, benchmarkToComponents, printJSONHeader
+from misc import (
+ idToText, textToId, benchmarkToComponents, getContext, printJSONHeader)
class GetStats2:
@@ -72,8 +73,10 @@ class GetStats2:
# context 1 and 2 respectively.
def computeBMStatsList(self):
- context1 = getContext(self.host1_id, self.platform1_id, self.branch1_id, self.sha1_id)
- context2 = getContext(self.host2_id, self.platform2_id, self.branch2_id, self.sha2_id)
+ context1 = getContext(
+ self.host1_id, self.platform1_id, self.branch1_id, self.sha11_id)
+ context2 = getContext(
+ self.host2_id, self.platform2_id, self.branch2_id, self.sha12_id)
# Get all distinct benchmark/metric combinations matching both contexts
# into a 'benchmarks' list:
diff --git a/scripts/listcontexts.py b/scripts/listcontexts.py
index 9f5a2b6..3de1d53 100644
--- a/scripts/listcontexts.py
+++ b/scripts/listcontexts.py
@@ -9,9 +9,10 @@ class ListContexts:
# Get all host/platform/branch/sha1 combinations:
contexts = execQuery(
- "SELECT id, hostId, platformId, branchId, sha1Id, EXTRACT(EPOCH FROM timestamp)::INT"
+ "SELECT id, hostId, platformId, branchId, sha1Id,"
+ " EXTRACT(EPOCH FROM timestamp)::INT"
" FROM context"
- " ORDER BY hostId, platformId, branchId, timestamp") \
+ " ORDER BY hostId, platformId, branchId, timestamp DESC;") \
+ [(-1, -1, -1, -1, -1, -1)] # Sentinel value
self.contexts = []
diff --git a/scripts/listtestcases1.py b/scripts/listtestcases1.py
index 666633e..9e50cab 100644
--- a/scripts/listtestcases1.py
+++ b/scripts/listtestcases1.py
@@ -1,5 +1,8 @@
+import sys
+import json
from dbaccess import execQuery
-from misc import idToText, textToId, benchmarkToComponents, printJSONHeader
+from misc import (
+ idToText, textToId, getContext, benchmarkToComponents, printJSONHeader)
class ListTestCases1:
@@ -17,10 +20,10 @@ class ListTestCases1:
# Get all distinct benchmarks matching the context:
bmark_ids = execQuery(
- "SELECT DISTINCT benchmarkId " +
- "FROM result WHERE hostId = " + str(self.host_id) +
- " AND platformId = " + str(self.platform_id) + " AND branchId = " +
- str(self.branch_id) + " AND sha1Id = " + str(self.sha1_id) + ";")
+ "SELECT DISTINCT benchmarkId "
+ "FROM result WHERE contextId = %d;"
+ % getContext(
+ self.host_id, self.platform_id, self.branch_id, self.sha1_id))
# Extract all distinct test case components:
tc_map = {}
@@ -36,15 +39,7 @@ class ListTestCases1:
def writeOutputAsJSON(self):
printJSONHeader()
- print "{ \"testcases\": ["
- first_test_case = True
- for test_case in self.test_cases:
- if not first_test_case:
- print ","
- first_test_case = False
-
- print "\"" + test_case + "\""
- print "]}"
+ json.dump({ 'testcases': self.test_cases }, sys.stdout)
class ListTestCases1AsJSON(ListTestCases1):
def writeOutput(self):
diff --git a/scripts/listtestcases2.py b/scripts/listtestcases2.py
index 30cec62..9cdcbda 100644
--- a/scripts/listtestcases2.py
+++ b/scripts/listtestcases2.py
@@ -1,5 +1,8 @@
+import sys
+import json
from dbaccess import execQuery
-from misc import idToText, textToId, benchmarkToComponents, printJSONHeader
+from misc import (
+ idToText, textToId, getContext, benchmarkToComponents, printJSONHeader)
class ListTestCases2:
@@ -27,16 +30,18 @@ class ListTestCases2:
# Get all distinct benchmarks matching both contexts:
bmark_ids = execQuery(
- "SELECT DISTINCT benchmarkId " +
- "FROM result WHERE hostId = " + str(self.host1_id) +
- " AND platformId = " + str(self.platform1_id) + " AND branchId = " +
- str(self.branch1_id) + " AND sha1Id = " + str(self.sha11_id) +
- " INTERSECT " +
- "SELECT DISTINCT benchmarkId " +
- "FROM result WHERE hostId = " + str(self.host2_id) +
- " AND platformId = " + str(self.platform2_id) + " AND branchId = " +
- str(self.branch2_id) + " AND sha1Id = " + str(self.sha12_id) +
- ";"
+ "SELECT DISTINCT benchmarkId"
+ " FROM result WHERE contextId = %d"
+ " INTERSECT "
+ "SELECT DISTINCT benchmarkId"
+ " FROM result WHERE contextId = %d;"
+ % (getContext(
+ self.host1_id, self.platform1_id, self.branch1_id,
+ self.sha11_id),
+ getContext(
+ self.host2_id, self.platform2_id, self.branch2_id,
+ self.sha12_id)
+ )
)
# Extract all distinct test case components:
@@ -53,15 +58,7 @@ class ListTestCases2:
def writeOutputAsJSON(self):
printJSONHeader()
- print "{ \"testcases\": ["
- first_test_case = True
- for test_case in self.test_cases:
- if not first_test_case:
- print ","
- first_test_case = False
-
- print "\"" + test_case + "\""
- print "]}"
+ json.dump({ 'testcases': self.test_cases }, sys.stdout)
class ListTestCases2AsJSON(ListTestCases2):
def writeOutput(self):
diff --git a/scripts/misc.py b/scripts/misc.py
index 660887f..c0c069a 100644
--- a/scripts/misc.py
+++ b/scripts/misc.py
@@ -14,8 +14,9 @@ def idToText(table, id_):
if id_ in idToTextCache[table]:
return idToTextCache[table][id_];
- text = execQuery(
- "SELECT value FROM " + table + " WHERE id = " + str(id_) + ";")[0][0]
+ text = ((execQuery(
+ "SELECT value FROM " + table + " WHERE id = " + str(id_) +
+ ";")[0][0]) if (id_ >= 0) else "")
idToTextCache[table][id_] = text;
return text;
@@ -85,14 +86,14 @@ def benchmarkToComponents(benchmark):
# (sha1, first upload timestamp).
def getSnapshots(host_id, platform_id, branch_id, sha11_id, sha12_id):
timestamp1 = execQuery(
- "SELECT timestamp FROM context " +
+ "SELECT EXTRACT(EPOCH FROM timestamp)::INT FROM context " +
"WHERE hostId = " + str(host_id) +
" AND platformId = " + str(platform_id) +
" AND branchId = " + str(branch_id) +
" AND sha1Id = " + str(sha11_id) + ";")[0][0]
timestamp2 = execQuery(
- "SELECT timestamp FROM context " +
+ "SELECT EXTRACT(EPOCH FROM timestamp)::INT FROM context " +
"WHERE hostId = " + str(host_id) +
" AND platformId = " + str(platform_id) +
" AND branchId = " + str(branch_id) +
@@ -114,7 +115,7 @@ def getSnapshots(host_id, platform_id, branch_id, sha11_id, sha12_id):
"WHERE hostId = %d"
" AND platformId = %d"
" AND branchId = %d"
- " AND timestamp BETWEEN %d AND %d"
+ " AND EXTRACT(EPOCH FROM timestamp)::INT BETWEEN %d AND %d"
" ORDER BY timestamp ASC;"
% (host_id, platform_id, branch_id, timestamp1, timestamp2))
@@ -205,18 +206,18 @@ def getTimeSeries(
host_id, platform_id, branch_id, snapshots, benchmark_id, metric_id):
contexts = []
- for snapshot in snapshots:
- contexts.append(getContext(host_id, platform_id, branch_id, snapshot))
+ for sha1_id, timestamp in snapshots:
+ contexts.append(getContext(host_id, platform_id, branch_id, sha1_id))
# Fetch raw values:
- raw_values = execQuery(
+ raw_values = (execQuery(
"SELECT value, valid, contextId FROM result"
" WHERE contextId IN (%s)"
" AND benchmarkId = %d"
" AND metricId = %d"
" ORDER BY contextId;"
% (", ".join(map(str, contexts)), benchmark_id, metric_id)) +
- [(-1, -1, -1)] # Note sentinel item
+ [(-1, -1, -1)]) # Note sentinel item
# Compute per-sample stats:
curr_context_id = -1
@@ -539,8 +540,8 @@ def getBMTimeSeriesStatsList(
progress_func(0.0, progress_arg)
contexts = []
- for snapshot in snapshots:
- contexts.append(getContext(host_id, platform_id, branch_id, snapshot))
+ for sha1_id, timestamp in snapshots:
+ contexts.append(getContext(host_id, platform_id, branch_id, sha1_id))
# Get all distinct benchmark/metric combinations that match the
# host/platform/branch context and are within the selected snapshot
diff --git a/scripts/singlecontextbmstats.py b/scripts/singlecontextbmstats.py
index 004c3b9..67e1838 100644
--- a/scripts/singlecontextbmstats.py
+++ b/scripts/singlecontextbmstats.py
@@ -1,6 +1,6 @@
from dbaccess import execQuery
from statlib import stats
-from misc import metricIdToLowerIsBetter
+from misc import metricIdToLowerIsBetter, getContext
class SingleContextBMStats:
def __init__(
@@ -64,7 +64,7 @@ def extractSingleContextBMStats(
values = []
- context = getContext(host_id, platform_id, branch_id)
+ context = getContext(host_id, platform_id, branch_id, sha1_id)
query_result = execQuery("SELECT value, valid FROM result"
" WHERE contextId = %d"
" AND benchmarkId = %d"