[llvm-commits] [zorg] r121643 - in /zorg/trunk/lnt/lnt/viewer: GraphUtil.py simple.ptl
Daniel Dunbar
daniel at zuster.org
Sun Dec 12 13:16:51 PST 2010
Author: ddunbar
Date: Sun Dec 12 15:16:51 2010
New Revision: 121643
URL: http://llvm.org/viewvc/llvm-project?rev=121643&view=rev
Log:
LNT.simple: Add optional (default=True) linear regression lines.
Modified:
zorg/trunk/lnt/lnt/viewer/GraphUtil.py
zorg/trunk/lnt/lnt/viewer/simple.ptl
Modified: zorg/trunk/lnt/lnt/viewer/GraphUtil.py
URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/viewer/GraphUtil.py?rev=121643&r1=121642&r2=121643&view=diff
==============================================================================
--- zorg/trunk/lnt/lnt/viewer/GraphUtil.py (original)
+++ zorg/trunk/lnt/lnt/viewer/GraphUtil.py Sun Dec 12 15:16:51 2010
@@ -5,12 +5,14 @@
import Util
from lnt.util import stats
+from lnt.external.stats import stats as ext_stats
from PerfDB import Machine, Run, RunInfo, Sample, Test
def get_test_plots(db, machine, test_ids, run_summary, ts_summary,
show_mad_error = False, show_points = False,
- show_all_points = False, show_stddev = False):
+ show_all_points = False, show_stddev = False,
+ show_linear_regression = False):
# Load all the samples for these tests and this machine.
q = db.session.query(Sample.run_id,Sample.test_id,
Sample.value).join(Run)
@@ -73,7 +75,29 @@
plot_js = ""
+ # Determine the base plot color.
col = list(Util.makeDarkColor(float(index) / num_plots))
+
+ # Add regression line, if requested.
+ if show_linear_regression:
+ xs = [t for t,v in data]
+ ys = [v for t,v in data]
+
+ # We compute the regression line in terms of a normalized X scale.
+ x_min, x_max = min(xs), max(xs)
+ norm_xs = [(x - x_min) / (x_max - x_min)
+ for x in xs]
+ slope, intercept,_,_,_ = ext_stats.linregress(norm_xs, ys)
+
+ reglin_col = [c*.5 for c in col]
+ pts = ','.join('[%.4f,%.4f]' % pt
+ for pt in [(x_min, 0.0 * slope + intercept),
+ (x_max, 1.0 * slope + intercept)])
+ style = "new Graph2D_LinePlotStyle(4, %r)" % ([.7, .7, .7],)
+ plot_js += " graph.addPlot([%s], %s);\n" % (pts,style)
+ style = "new Graph2D_LinePlotStyle(2, %r)" % (reglin_col,)
+ plot_js += " graph.addPlot([%s], %s);\n" % (pts,style)
+
pts = ','.join(['[%.4f,%.4f]' % (t,v)
for t,v in data])
style = "new Graph2D_LinePlotStyle(1, %r)" % col
Modified: zorg/trunk/lnt/lnt/viewer/simple.ptl
URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/viewer/simple.ptl?rev=121643&r1=121642&r2=121643&view=diff
==============================================================================
--- zorg/trunk/lnt/lnt/viewer/simple.ptl (original)
+++ zorg/trunk/lnt/lnt/viewer/simple.ptl Sun Dec 12 15:16:51 2010
@@ -221,14 +221,24 @@
compare_to))
def graph [html] (self):
+ def init_form(form):
+ # Add default fields, Quixote doesn't like missing values if the
+ # form data exists.
+ form['show_mad'] = form.get('show_mad') or '1'
+ form['show_stddev'] = form.get('show_stddev') or '0'
+ form['show_linear_regression'] = form.get(
+ 'show_linear_regression') or '1'
+
request = quixote.get_request()
+ init_form(request.form)
# Get the view options form.
form = quixote.form.Form(method=str("get"))
- form.add(quixote.form.CheckboxWidget, "show_mad", True,
- title="Show MAD")
- form.add(quixote.form.CheckboxWidget, "show_stddev", False,
+ form.add(quixote.form.IntWidget, "show_mad", title="Show MAD")
+ form.add(quixote.form.IntWidget, "show_stddev",
title="Show Standard Deviation")
+ form.add(quixote.form.IntWidget, "show_linear_regression",
+ title="Show Linear Regression Line")
# Add all the hidden fields.
for name,value in request.form.items():
@@ -249,8 +259,9 @@
ts_summary = perfdbsummary.get_simple_suite_summary(db, self.tag)
# Load the form data.
- show_stddev = bool(form['show_stddev'])
- show_mad = bool(form['show_mad'])
+ show_mad = form.get('show_mad')
+ show_stddev = form.get('show_stddev')
+ show_linear_regression = form.get('show_linear_regression')
graph_tests = []
graph_psets = []
for name,value in request.form.items():
@@ -271,11 +282,10 @@
num_points = 0
plot_points = []
plots = ""
- plots_iter = GraphUtil.get_test_plots(db, machine, test_ids,
- run_summary, ts_summary,
- show_mad_error = show_mad,
- show_stddev = show_stddev,
- show_points = True)
+ plots_iter = GraphUtil.get_test_plots(
+ db, machine, test_ids, run_summary, ts_summary,
+ show_mad_error = show_mad, show_stddev = show_stddev,
+ show_linear_regression = show_linear_regression, show_points = True)
for test_id, plot_js, col, points, ext_points in plots_iter:
test = db.getTest(test_id)
name = test.name
More information about the llvm-commits
mailing list