[LNT] r205063 - Add simple baseline run graphing

Chris Matthews cmatthews5 at apple.com
Fri Mar 28 15:04:19 PDT 2014


Author: cmatthews
Date: Fri Mar 28 17:04:19 2014
New Revision: 205063

URL: http://llvm.org/viewvc/llvm-project?rev=205063&view=rev
Log:
Add simple baseline run graphing

Add visual representation of baselines in graphs.  When passing a "baseline.<n>=<run_num>" argument to graph, a horizontal baseline will be drawn on the graph derived from the run passed.  The same test and metric are used for each plot.  The baseline is drawn as a thick darker line, in the same color as the original plot. The intended use is to compare something like trunk to the previous release.  This setting is off by default.

Modified:
    lnt/trunk/lnt/server/ui/templates/v4_graph.html
    lnt/trunk/lnt/server/ui/util.py
    lnt/trunk/lnt/server/ui/views.py

Modified: lnt/trunk/lnt/server/ui/templates/v4_graph.html
URL: http://llvm.org/viewvc/llvm-project/lnt/trunk/lnt/server/ui/templates/v4_graph.html?rev=205063&r1=205062&r2=205063&view=diff
==============================================================================
--- lnt/trunk/lnt/server/ui/templates/v4_graph.html (original)
+++ lnt/trunk/lnt/server/ui/templates/v4_graph.html Fri Mar 28 17:04:19 2014
@@ -40,6 +40,7 @@ function init() {
   // Set up the primary graph.
   var graph = $("#graph");
   var graph_plots = {{graph_plots|tojson|safe}};
+  var baseline_plots = {{baseline_plots|tojson|safe}};
   var graph_options = {
       series : {
         lines : {
@@ -59,6 +60,9 @@ function init() {
       grid : {
         hoverable : true }
       };
+
+  // Add baseline lines
+  graph_options['grid']['markings'] = baseline_plots;
   $.plot(graph, graph_plots, graph_options);
 
   // Add tooltips.
@@ -268,6 +272,9 @@ function update_tooltip(event, pos, item
           {% if name.startswith('plot.') %}
           <input type="hidden" name="{{name}}" value="{{value}}">
           {% endif %}
+          {% if name.startswith('baseline.') %}
+          <input type="hidden" name="{{name}}" value="{{value}}">
+          {% endif %}
           {% endfor %}
             
           <input class="btn btn-primary" style="clear: left; width: 100%"

Modified: lnt/trunk/lnt/server/ui/util.py
URL: http://llvm.org/viewvc/llvm-project/lnt/trunk/lnt/server/ui/util.py?rev=205063&r1=205062&r2=205063&view=diff
==============================================================================
--- lnt/trunk/lnt/server/ui/util.py (original)
+++ lnt/trunk/lnt/server/ui/util.py Fri Mar 28 17:04:19 2014
@@ -36,10 +36,12 @@ def safediv(a, b, default=None):
     except ZeroDivisionError:
         return default
 
-def makeDarkColor(h):
+def makeDarkerColor(h):
+    return makeDarkColor(h, 0.50)
+
+def makeDarkColor(h, v=0.8):
     h = h%1.
     s = 0.95
-    v = 0.8
     return colorsys.hsv_to_rgb(h,0.9+s*.1,v)
 
 def makeMediumColor(h):

Modified: lnt/trunk/lnt/server/ui/views.py
URL: http://llvm.org/viewvc/llvm-project/lnt/trunk/lnt/server/ui/views.py?rev=205063&r1=205062&r2=205063&view=diff
==============================================================================
--- lnt/trunk/lnt/server/ui/views.py (original)
+++ lnt/trunk/lnt/server/ui/views.py Fri Mar 28 17:04:19 2014
@@ -26,6 +26,7 @@ from lnt.server.ui.decorators import fro
 import lnt.server.ui.util
 import lnt.server.reporting.dailyreport
 import lnt.server.reporting.summaryreport
+from collections import namedtuple
 
 integral_rex = re.compile(r"[\d]+")
 
@@ -402,6 +403,8 @@ def v4_run_graph(id):
 
     return redirect(v4_url_for("v4_graph", **args))
 
+BaselineLegendItem = namedtuple('BaselineLegendItem', 'name id')
+
 @v4_route("/graph")
 def v4_graph():
     from lnt.server.ui import util
@@ -478,6 +481,31 @@ def v4_graph():
     if not graph_parameters:
         return render_template("error.html", message="Nothing to graph.")
 
+    # Extract requested baselines.
+    baseline_parameters = []
+    for name,value in request.args.items():
+        # Baselines to graph are passed as:
+        #
+        #  baseline.<unused>=<run id>
+        if not name.startswith(str('baseline.')):
+            continue
+
+        # Ignore the extra part of the key, it is unused.
+        run_id_str = value
+        try:
+            run_id = int(run_id_str)
+        except:
+            return abort(400)
+
+        try:
+            run = ts.query(ts.Run).join(ts.Machine).filter(ts.Run.id == run_id).one()
+        except:
+            err_msg = "The run {} was not found in the database.".format(run_id)
+            return render_template("error.html",
+                                   message=err_msg)
+
+        baseline_parameters.append(run)
+
     # Create region of interest for run data region if we are performing a
     # comparison.
     revision_range = None
@@ -501,6 +529,7 @@ def v4_graph():
     legend = []
     graph_plots = []
     overview_plots = []
+    baseline_plots = []
     num_plots = len(graph_parameters)
     for i,(machine,test,field) in enumerate(graph_parameters):
         # Determine the base plot color.
@@ -529,6 +558,27 @@ def v4_graph():
         data = util.multidict((rev, (val, date)) for val,rev,date in q).items()
         data.sort(key=lambda sample: convert_revision(sample[0]))
 
+        # Get baselines for this line
+        for baseline in baseline_parameters:
+            q_baseline = ts.query(field.column, ts.Order.llvm_project_revision, ts.Run.start_time, ts.Machine.name).\
+                         join(ts.Run).join(ts.Order).join(ts.Machine).\
+                         filter(ts.Run.id == baseline.id).\
+                         filter(ts.Sample.test == test).\
+                         filter(field.column != None)
+            # In the event of many samples, use the mean of the samples as the baseline.
+            samples = []
+            for sample in q_baseline:
+                samples.append(sample[0])
+            mean = sum(samples)/len(samples)
+            # Darken the baseline color distinguish from real line.
+            dark_col = list(util.makeDarkerColor(float(i) / num_plots))
+            str_dark_col =  util.toColorString(dark_col)
+            baseline_plots.append({'color': str_dark_col,
+                                   'lineWidth': 2,
+                                   'yaxis': {'from': mean, 'to': mean},
+                                   'name': q_baseline[0].llvm_project_revision})
+            baseline_name = "Baseline {} on {}".format(q_baseline[0].llvm_project_revision,  q_baseline[0].name)
+            legend.append((BaselineLegendItem(baseline_name, baseline.id), test.name, field.name, dark_col))
         # Compute the graph points.
         errorbar_data = []
         points_data = []
@@ -700,23 +750,23 @@ def v4_graph():
         simple_type_legend = []
         for machine, test, unit, color in legend:
             # Flatten name, make color a dict.
-            new_entry = {'name':machine.name,
-                         'test':test,
+            new_entry = {'name': machine.name,
+                         'test': test,
                          'unit': unit,
-                         'color': {'r': color[0],
-                                   'g': color[1],
-                                   'b': color[2]}}
+                         'color': util.toColorString(color),}
             simple_type_legend.append(new_entry)
         json_obj['legend'] = simple_type_legend
         json_obj['revision_range'] = revision_range
         json_obj['current_options'] = options
         json_obj['test_suite_name'] = ts.name
+        json_obj['baselines'] = baseline_plots
         return flask.jsonify(**json_obj)
 
     return render_template("v4_graph.html", ts=ts, options=options,
                            revision_range=revision_range,
                            graph_plots=graph_plots,
-                           overview_plots=overview_plots, legend=legend)
+                           overview_plots=overview_plots, legend=legend,
+                           baseline_plots=baseline_plots)
 
 @v4_route("/global_status")
 def v4_global_status():





More information about the llvm-commits mailing list