[llvm-commits] [LNT] r162054 - in /lnt/trunk/lnt/server/ui: templates/v4_graph.html views.py

Michael Gottesman mgottesman at apple.com
Fri Aug 17 11:59:49 PDT 2012


I fixed all but the color stuff. I have a few questions about that that I am going to ask you offline.

On Aug 16, 2012, at 4:11 PM, Daniel Dunbar <daniel at zuster.org> wrote:

> On Thu, Aug 16, 2012 at 3:43 PM, Michael Gottesman <mgottesman at apple.com> wrote:
>> Author: mgottesman
>> Date: Thu Aug 16 17:43:33 2012
>> New Revision: 162054
>> 
>> URL: http://llvm.org/viewvc/llvm-project?rev=162054&view=rev
>> Log:
>> [LNT] Added code that allows for moving median and moving average graphs to be created. Additionally I added a button to turn off the revision range highlighting feature in case anyone is so inclined.
> 
> Awesome, thanks. Comments inline...
> 
>> Modified:
>>    lnt/trunk/lnt/server/ui/templates/v4_graph.html
>>    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=162054&r1=162053&r2=162054&view=diff
>> ==============================================================================
>> --- lnt/trunk/lnt/server/ui/templates/v4_graph.html (original)
>> +++ lnt/trunk/lnt/server/ui/templates/v4_graph.html Thu Aug 16 17:43:33 2012
>> @@ -69,6 +69,21 @@
>> <input type="checkbox" name="normalize_by_median" value="yes" {{
>>        'checked' if options.normalize_by_median else ""}}><br>
>> 
>> +<b>Show Moving Average</b>
>> +<input type="checkbox" name="show_moving_average" value="yes" {{
>> +       'checked' if options.show_moving_average else ""}}><br>
>> +
>> +<b>Show Moving Median</b>
>> +<input type="checkbox" name="show_moving_median" value="yes" {{
>> +       'checked' if options.show_moving_median else ""}}><br>
>> +
>> +<b>Moving Average/Median Window Size</b>
>> +<input type="text" name="moving_window_size" value="{{ options.moving_window_size }}"/><br>
>> +
>> +<b>Hide Revision Comparison Region Highlight</b>
>> +<input type="checkbox" name="hide_highlight" value="yes" {{
>> +       'checked' if options.hide_highlight else ""}}><br>
>> +
>> {# Add all the hidden fields. #}
>> {% for name,value in request.args.items() %}
>>   {% if name.startswith('test.') %}
>> 
>> Modified: lnt/trunk/lnt/server/ui/views.py
>> URL: http://llvm.org/viewvc/llvm-project/lnt/trunk/lnt/server/ui/views.py?rev=162054&r1=162053&r2=162054&view=diff
>> ==============================================================================
>> --- lnt/trunk/lnt/server/ui/views.py (original)
>> +++ lnt/trunk/lnt/server/ui/views.py Thu Aug 16 17:43:33 2012
>> @@ -394,7 +394,16 @@
>>         request.args.get('show_failures'))
>>     options['normalize_by_median'] = normalize_by_median = bool(
>>         request.args.get('normalize_by_median'))
>> -
>> +    options['show_moving_average'] = moving_average = bool(
>> +        request.args.get('show_moving_average'))
>> +    options['show_moving_median'] = moving_median = bool(
>> +        request.args.get('show_moving_median'))
>> +    options['moving_window_size'] = moving_window_size = int(
>> +        request.args.get('moving_window_size', 10))
>> +    options['hide_highlight'] = bool(
>> +        request.args.get('hide_highlight'))
>> +    show_highlight = not options['hide_highlight']
>> +
>>     # Load the graph parameters.
>>     graph_tests = []
>>     for name,value in request.args.items():
>> @@ -495,10 +504,12 @@
>>         errorbar_data = []
>>         points_data = []
>>         pts = []
>> +        moving_median_data = []
>> +        moving_average_data = []
>> 
>>         # Create region of interest for run data region if
>>         # we are performing a comparison.
>> -        if compare_to:
>> +        if compare_to and show_highlight:
>>             start_rev = compare_to.order.llvm_project_revision
>>             end_rev = run.order.llvm_project_revision
>>             revision_range_region = (
>> @@ -511,7 +522,8 @@
>>                                            for _,values in data])
>>         else:
>>             normalize_by = 1.0
>> -        for x,orig_values in data:
>> +        for i in range(len(data)):
>> +            x, orig_values = data[i]
>>             values = [v*normalize_by for v in orig_values]
>>             min_value = min(values)
>>             pts.append((x, min_value))
>> @@ -534,9 +546,28 @@
>>                 med = stats.median(values)
>>                 mad = stats.median_absolute_deviation(values, med)
>>                 errorbar_data.append((x, med - mad, med + mad))
>> -
>> +
>> +            if moving_average:
>> +                len_pts = len(pts)
>> +                start_index = max(0, i - moving_window_size)
>> +                end_index = min(len_pts, i + moving_window_size)
>> +
>> +                window_pts = [x[1] for x in pts[start_index:end_index]]
>> +                window_average = sum(window_pts)/len(window_pts)
>> +                moving_average_data.append((pts[i][0], window_average))
> 
> Please use stats.mean()...
> 
>> +            if moving_median:
>> +                len_pts = len(pts)
>> +                start_index = max(0, i - moving_window_size)
>> +                end_index = min(len_pts, i + moving_window_size)
>> +
>> +                window_pts = sorted([x[1] for x in pts[start_index:end_index]])
>> +                median = window_pts[len(window_pts)/2]
>> +                moving_median_data.append((pts[i][0], median))
> 
> and stats.median().
> 
> More important than that, there is a subtle bug here. Your moving
> window is not actually symmetric like it is trying to be. The pts
> array you are slicing over is getting built up in this loop, so you
> are only computing the trailing {average/median}. Best thing is
> probably just to leave the original loop as is and then do a separate
> pass over the pts array.
> 
>> +
>>         # Add the minimum line plot.
>>         num_points += len(data)
>> +
>>         graph_plots.append("graph.addPlot([%s], %s);" % (
>>                         ','.join(['[%.4f,%.4f]' % (t,v)
>>                                   for t,v in pts]),
>> @@ -577,7 +608,7 @@
>>                         pts,style))
>> 
>>         # If we are comparing two revisions,
>> -        if compare_to:
>> +        if compare_to and show_highlight:
>>             reg_col = [0.0, 0.0, 1.0]
>>             graph_plots.append("graph.addPlot([%i, %i],%s);" % (
>>                     revision_range_region[0], revision_range_region[1],
>> @@ -598,6 +629,23 @@
>>                 ','.join(['[%.4f,%.4f,%.4f]' % (x,y_min,y_max)
>>                           for x,y_min,y_max in errorbar_data]),
>>                 "new Graph2D_ErrorBarPlotStyle(1, %r)" % (bar_col,)))
>> +
>> +        # Add the moving average plot, if used.
>> +        if moving_average_data:
>> +            col = [0.32, 0.6, 0.0]
>> +            graph_plots.append("graph.addPlot([%s], %s);" % (
>> +                    ','.join(['[%.4f,%.4f]' % (t,v)
>> +                              for t,v in moving_average_data]),
>> +                    "new Graph2D_LinePlotStyle(1, %r)" % (col,)))
>> +
>> +
>> +        # Add the moving median plot, if used.
>> +        if moving_median_data:
>> +            col = [0.75, 0.0, 1.0]
> 
> Note that the graph page is capable of displaying more than one graph,
> so you shouldn't use fixed colors. The simplest way to get "other"
> colors than are "near" the one for the graph is to use something like:
>        moving_average_col = list(util.makeDarkColor(float(i) /
> num_plots + <insert small float constant here>))
> 
> Also, can you add these colors to the legend when those displays are active?
> 
> Thanks again for the feature!
> 
> - Daniel
> 
>> +            graph_plots.append("graph.addPlot([%s], %s);" % (
>> +                    ','.join(['[%.4f,%.4f]' % (t,v)
>> +                              for t,v in moving_median_data]),
>> +                    "new Graph2D_LinePlotStyle(1, %r)" % (col,)))
>> 
>>     return render_template("v4_graph.html", ts=ts, run=run,
>>                            compare_to=compare_to, options=options,
>> 
>> 
>> _______________________________________________
>> llvm-commits mailing list
>> llvm-commits at cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits




More information about the llvm-commits mailing list