[llvm-commits] [zorg] r105565 - in /zorg/trunk/lnt/lnt: db/perfdbsummary.py viewer/PerfDB.py viewer/simple.ptl
Daniel Dunbar
daniel at zuster.org
Mon Jun 7 16:00:23 PDT 2010
Author: ddunbar
Date: Mon Jun 7 18:00:23 2010
New Revision: 105565
URL: http://llvm.org/viewvc/llvm-project?rev=105565&view=rev
Log:
LNT/viewer: Add a cache for 'simple' style test suite test metadata.
Modified:
zorg/trunk/lnt/lnt/db/perfdbsummary.py
zorg/trunk/lnt/lnt/viewer/PerfDB.py
zorg/trunk/lnt/lnt/viewer/simple.ptl
Modified: zorg/trunk/lnt/lnt/db/perfdbsummary.py
URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/db/perfdbsummary.py?rev=105565&r1=105564&r2=105565&view=diff
==============================================================================
--- zorg/trunk/lnt/lnt/db/perfdbsummary.py (original)
+++ zorg/trunk/lnt/lnt/db/perfdbsummary.py Mon Jun 7 18:00:23 2010
@@ -2,7 +2,7 @@
Classes for caching metadata about a PerfDB instance.
"""
-from lnt.viewer.PerfDB import RunInfo
+from lnt.viewer.PerfDB import RunInfo, Test
class SuiteSummary:
def __init__(self, name, path):
@@ -33,4 +33,65 @@
self.suites = suites
def is_up_to_date(self, db):
- return self.revision == db.get_revision("Run")
+ return self.revision == db.get_revision_number("Run")
+
+class SimpleSuiteSummary:
+ @staticmethod
+ def fromdb(db, tag):
+ revision = db.get_revision_number("Test")
+
+ # Find all test names.
+ q = db.session.query(Test)
+ q = q.filter(Test.name.startswith(tag))
+ tests = list(q)
+
+ # Collect all the test data.
+ test_names = set()
+ parameter_sets = set()
+ test_map = {}
+ for t in tests:
+ name = t.name.split(str('.'),1)[1]
+ test_names.add(name)
+
+ items = [(k,v.value) for k,v in t.info.items()]
+ items.sort()
+ key = tuple(items)
+
+ parameter_sets.add(key)
+ test_map[(name, key)] = t
+
+ # Order the test names.
+ test_names = list(test_names)
+ test_names.sort()
+
+ # Collect the set of all parameter keys.
+ parameter_keys = list(set([k for pset in parameter_sets
+ for k,v in pset]))
+ parameter_keys.sort()
+
+ # Order the parameter sets and convert to dictionaries.
+ parameter_sets = list(parameter_sets)
+ parameter_sets.sort()
+
+ return SimpleSuiteSummary(revision, tag, test_names, test_map,
+ parameter_keys, parameter_sets)
+
+ def __init__(self, revision, tag, test_names, test_map,
+ parameter_keys, parameter_sets):
+ self.revision = revision
+ self.tag = tag
+ self.test_names = test_names
+ self.test_map = test_map
+ self.parameter_keys = parameter_keys
+ self.parameter_sets = parameter_sets
+
+ def is_up_to_date(self, db):
+ return self.revision == db.get_revision_number("Test")
+
+_cache = {}
+def get_simple_suite_summary(db, tag):
+ key = (db.path, tag)
+ entry = _cache.get(key)
+ if entry is None or not entry.is_up_to_date(db):
+ _cache[key] = entry = SimpleSuiteSummary.fromdb(db, tag)
+ return entry
Modified: zorg/trunk/lnt/lnt/viewer/PerfDB.py
URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/viewer/PerfDB.py?rev=105565&r1=105564&r2=105565&view=diff
==============================================================================
--- zorg/trunk/lnt/lnt/viewer/PerfDB.py (original)
+++ zorg/trunk/lnt/lnt/viewer/PerfDB.py Mon Jun 7 18:00:23 2010
@@ -173,6 +173,7 @@
if (not path.startswith('mysql://') and
not path.startswith('sqlite://')):
path = 'sqlite:///' + path
+ self.path = path
self.engine = sqlalchemy.create_engine(path, echo=echo)
# Create the tables in case this is a new database.
Modified: zorg/trunk/lnt/lnt/viewer/simple.ptl
URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/viewer/simple.ptl?rev=105565&r1=105564&r2=105565&view=diff
==============================================================================
--- zorg/trunk/lnt/lnt/viewer/simple.ptl (original)
+++ zorg/trunk/lnt/lnt/viewer/simple.ptl Mon Jun 7 18:00:23 2010
@@ -13,6 +13,8 @@
from quixote.directory import Directory
from quixote.errors import TraversalError
+from lnt.db import perfdbsummary
+
import Util, NTStyleBrowser
from Util import safediv
from NTUtil import *
@@ -225,10 +227,8 @@
run,runs,has_order,compareTo = self.getInfo(db)
machine = run.machine
- # Load the metadata.
-
- test_names,test_map,parameter_keys,parameter_sets = self.\
- get_simple_metadata(db)
+ # Load the test suite summary.
+ ts_summary = perfdbsummary.get_simple_suite_summary(db, self.tag)
# Load the form data.
graph_tests = []
@@ -237,10 +237,10 @@
if name.startswith(str('test.')):
graph_tests.append(name[5:])
elif name.startswith(str('pset.')):
- graph_psets.append(parameter_sets[int(name[5:])])
+ graph_psets.append(ts_summary.parameter_sets[int(name[5:])])
# Get the test ids we want data for.
- test_ids = [test_map[(name,pset)].id
+ test_ids = [ts_summary.test_map[(name,pset)].id
for name in graph_tests
for pset in graph_psets]
@@ -272,7 +272,8 @@
d[run_key] = value
# Build the graph data
- pset_id_map = dict([(pset,i) for i,pset in enumerate(parameter_sets)])
+ pset_id_map = dict([(pset,i)
+ for i,pset in enumerate(ts_summary.parameter_sets)])
legend = []
plot_points = []
plots = ""
@@ -284,7 +285,7 @@
show_all_points = False
for name in graph_tests:
for pset in graph_psets:
- test_id = test_map[(name,pset)].id
+ test_id = ts_summary.test_map[(name,pset)].id
# Get the plot for this test.
#
@@ -447,7 +448,6 @@
%s
<p>""" % (' '.join(map(str, new_sample_list)),
' '.join(map(str, Util.sorted(resample_list))))
-
if has_order:
xAxis_format = 'graph.xAxis.formats.normal'
@@ -462,57 +462,20 @@
graph.draw();
}
""" % (plots,xAxis_format)
- self.root.getHeader('Run Results', "../..",
- components=(('simple','simple'),
+ self.root.getHeader('Run Results', "../../..",
+ components=((self.tag,
+ '%s/%s' % ('simple',self.tag)),
('machine',
- 'simple/machines/%d' % machine.id),
- ('run', 'simple/%d' % run.id)),
+ 'simple/%s/machines/%d' %(self.tag,
+ machine.id)),
+ ('run', 'simple/%s/%d' % (self.tag,
+ run.id))),
addPopupJS=True, addGraphJS=True,
addJSScript=graph_init,
onload="init()")
self.show_run_page(db, run, runs, compareTo, graph_body)
- def get_simple_metadata(self, db):
- """Compute the metadata about tests, parameter sets, etc."""
-
- # FIXME: We can cache this in a number of ways.
-
- # Find all test names.
- q = db.session.query(Test)
- q = q.filter(Test.name.startswith(self.tag))
- tests = list(q)
-
- # Collect all the test data.
- test_names = set()
- parameter_sets = set()
- test_map = {}
- for t in tests:
- name = t.name.split(str('.'),1)[1]
- test_names.add(name)
-
- items = [(k,v.value) for k,v in t.info.items()]
- items.sort()
- key = tuple(items)
-
- parameter_sets.add(key)
- test_map[(name, key)] = t
-
- # Order the test names.
- test_names = list(test_names)
- test_names.sort()
-
- # Collect the set of all parameter keys.
- parameter_keys = list(set([k for pset in parameter_sets
- for k,v in pset]))
- parameter_keys.sort()
-
- # Order the parameter sets and convert to dictionaries.
- parameter_sets = list(parameter_sets)
- parameter_sets.sort()
-
- return test_names,test_map,parameter_keys,parameter_sets
-
def _q_index_body [html] (self, db, run, runs, compare_to):
# Find the tests. The simple UI maps all tests that start with
# 'simple.'.
@@ -529,13 +492,10 @@
prev_id = None
interesting_runs = (run.id,)
- # Load the metadata.
-
- test_names,test_map,parameter_keys,parameter_sets = self.\
- get_simple_metadata(db)
+ # Load the test suite summary.
+ ts_summary = perfdbsummary.get_simple_suite_summary(db, self.tag)
# Load the run sample data.
-
q = db.session.query(Sample.value, Sample.run_id, Sample.test_id)
q = q.filter(Sample.run_id.in_(interesting_runs))
@@ -579,18 +539,18 @@
<tr>
<th rowspan=2>Name</th>
<th colspan=%d>Parameters</th>
- </tr><tr>""" % len(parameter_sets)
- for key in parameter_keys:
+ </tr><tr>""" % len(ts_summary.parameter_sets)
+ for key in ts_summary.parameter_keys:
"""
<th>%s</th>""" % key
"""
</tr>"""
- for (i,pset) in enumerate(parameter_sets):
+ for (i,pset) in enumerate(ts_summary.parameter_sets):
"""
<tr>
<td>P%s</td>""" % (i,)
pmap = dict(pset)
- for key in parameter_keys:
+ for key in ts_summary.parameter_keys:
item = pmap.get(key)
if item is None:
item = "-"
@@ -609,19 +569,19 @@
<table border=1>
<tr>
<th></th><th>Name</th>"""
- for i in range(len(parameter_sets)):
+ for i in range(len(ts_summary.parameter_sets)):
"""
<th><input type="checkbox" name="pset.%d">P%d</th>
<th>%%</th>""" % (i, i)
"""
</tr>"""
- for name in test_names:
+ for name in ts_summary.test_names:
"""
<tr>
<td><input type="checkbox" name="test.%s"></td>
<td>%s</td>""" % (name, name)
- for pset in parameter_sets:
- test = test_map.get((name,pset))
+ for pset in ts_summary.parameter_sets:
+ test = ts_summary.test_map.get((name,pset))
if test is None:
"""
<td></td><td></td>"""
More information about the llvm-commits
mailing list