Skip to content

Commit

Permalink
Don't show std dev column when not present
Browse files Browse the repository at this point in the history
Adjust changes table width
Some more data presence checks
  • Loading branch information
tobami committed Jan 11, 2011
1 parent 83aae3c commit bfc6b45
Show file tree
Hide file tree
Showing 4 changed files with 79 additions and 24 deletions.
57 changes: 42 additions & 15 deletions speedcenter/codespeed/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ def no_executables_error():
'message': 'There needs to be at least one executable'
})

def no_data_found():
return render_to_response('codespeed/nodata.html', {
'message': 'No data found'
})

def getbaselineexecutables():
baseline = [{'key': "none", 'name': "None", 'executable': "none", 'revision': "none"}]
revs = Revision.objects.exclude(tag="")
Expand Down Expand Up @@ -98,7 +103,8 @@ def getcomparisonexes():
if rev.tag == "":
for exe in Executable.objects.filter(project=rev.project):
exestring = str(exe)
if len(exestring) > maxlen: exestring = str(exe)[0:maxlen] + "..."
if len(exestring) > maxlen:
exestring = str(exe)[0:maxlen] + "..."
name = exestring + " latest"
key = str(exe.id) + "+L"
executablekeys.append(key)
Expand Down Expand Up @@ -163,10 +169,13 @@ def comparison(request):
if not checkedenviros:
checkedenviros = enviros

if not len(Project.objects.all()): return no_default_project_error()
if not len(Project.objects.all()):
return no_default_project_error()

defaultexecutable = getdefaultexecutable()
if not defaultexecutable: return no_executables_error()

if not defaultexecutable:
return no_executables_error()

executables, exekeys = getcomparisonexes()
checkedexecutables = []
Expand Down Expand Up @@ -374,8 +383,10 @@ def timeline(request):
pass

defaultproject = Project.objects.filter(track=True)
if not len(defaultproject): return no_default_project_error()
else: defaultproject = defaultproject[0]
if not len(defaultproject):
return no_default_project_error()
else:
defaultproject = defaultproject[0]

checkedexecutables = []
if 'exe' in data:
Expand All @@ -389,7 +400,8 @@ def timeline(request):
if not checkedexecutables:
checkedexecutables = Executable.objects.filter(project__track=True)

if not len(checkedexecutables): return no_executables_error()
if not len(checkedexecutables):
return no_executables_error()

baseline = getbaselineexecutables()
defaultbaseline = None
Expand All @@ -410,8 +422,12 @@ def timeline(request):
defaultlast = data['revs']

benchmarks = Benchmark.objects.all()
if len(benchmarks) > 1: defaultbenchmark = "grid"
else: defaultbenchmark = benchmarks[0]
if not len(benchmarks):
return no_data_found()
elif len(benchmarks) == 1:
defaultbenchmark = benchmarks[0]
else:
defaultbenchmark = "grid"

if 'ben' in data and data['ben'] != defaultbenchmark:
defaultbenchmark = get_object_or_404(Benchmark, name=data['ben'])
Expand Down Expand Up @@ -476,24 +492,31 @@ def getchangestable(request):
units_title = ""
hasmin = False
hasmax = False
has_stddev = False
smallest = 1000
totals = {'change': [], 'trend': [],}
for bench in Benchmark.objects.filter(units=units['units']):
units_title = bench.units_title
lessisbetter = bench.lessisbetter
resultquery = result_list.filter(benchmark=bench)
if not len(resultquery): continue

resobj = resultquery.filter(benchmark=bench)[0]

std_dev = resobj.std_dev
result = resobj.value
if std_dev is not None: has_stddev = True
else: std_dev = "-"

val_min = resobj.val_min
if val_min is not None: hasmin = True
else: val_min = "-"

val_max = resobj.val_max
if val_max is not None: hasmax = True
else: val_max = "-"

# Calculate percentage change relative to previous result
result = resobj.value
change = "-"
if len(change_list):
c = change_list.filter(benchmark=bench)
Expand Down Expand Up @@ -561,6 +584,7 @@ def getchangestable(request):
'units': units['units'],
'units_title': units_title,
'lessisbetter': lessisbetter,
'has_stddev': has_stddev,
'hasmin': hasmin,
'hasmax': hasmax,
'precission': digits,
Expand All @@ -585,7 +609,7 @@ def getchangestable(request):
def changes(request):
if request.method != 'GET': return HttpResponseNotAllowed('GET')
data = request.GET

# Configuration of default parameters
defaultchangethres = 3
defaulttrendthres = 3
Expand All @@ -609,11 +633,14 @@ def changes(request):
environments = Environment.objects.all()

defaultproject = Project.objects.filter(track=True)
if not len(defaultproject): return no_default_project_error()
else: defaultproject = defaultproject[0]
if not len(defaultproject):
return no_default_project_error()
else:
defaultproject = defaultproject[0]

defaultexecutable = getdefaultexecutable()
if not defaultexecutable: return no_executables_error()
if not defaultexecutable:
return no_executables_error()

if "exe" in data:
try:
Expand Down Expand Up @@ -641,8 +668,8 @@ def changes(request):
project=defaultexecutable.project
).order_by('-date')[:revlimit]
if not len(lastrevisions):
response = 'No data found for project "' + str(defaultexecutable.project) + '"'
return HttpResponse(response)
return no_data_found()

selectedrevision = lastrevisions[0]
if "rev" in data:
commitid = data['rev']
Expand Down
18 changes: 12 additions & 6 deletions speedcenter/media/css/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -212,14 +212,20 @@ p.errormessage { line-height: 10em; margin-bottom: 10em; }
/* Changes table layout */
div#contentwrap { display: table; table-layout: fixed; width: 100%; }
div#contentwrap div { display: table-cell; }
div#contentwrap div.leftcolumn { width: 28em;}
div#contentwrap div.leftcolumn { width: 55%;}
div#contentwrap div.rightcolumn { padding-left: 0.8em; }

div#contentwrap div div { display: block; }

/* For large screens don't expand the left colunm so much */
@media only screen and (min-width:1270px) {
div#contentwrap div.leftcolumn { width: 34em; }
}

/* 1024px wide screen Tablet, Netbook */
/* Remove outher margins so that it comfortably fits */
@media only screen and (max-width:1090px) {
@media only screen and (max-width:1100px) {
div#contentwrap div.leftcolumn { width: 28.1em; }
div#containter { width: 100%; margin: 0; }
div#workarea { padding-left: 0.3em; }
div#sidebar { width: 12.5em; }
Expand All @@ -231,7 +237,7 @@ div#contentwrap div div { display: block; }

/* Less than 1024px wide screens (Smartphones) */
/* The changes view should only show one colunm */
@media only screen and (max-width:1010px) {
@media only screen and (max-width:1005px) {
div#contentwrap div { display: table-row!important; }
table.info { margin-bottom: 0.8em; }
div#title { margin-bottom: -35px; background-color: transparent; }
Expand Down Expand Up @@ -262,14 +268,14 @@ table.tablesorter { margin-right: 0.8em; margin-bottom: 0.8em; }

table.tablesorter thead tr th {
padding: 4px;
padding-right: 12px;
width: 5.5em;
padding-right: 14px;
/* width: 5.5em;*/
text-align: center;
background-color: #9DADC6;
border: 1px solid #CDCDCD;
font-size: 8pt;
}
table.tablesorter thead tr .header {
table.tablesorter thead tr th.header {
background-image: url(/media/images/bg.gif);
background-repeat: no-repeat;
background-position: center right;
Expand Down
2 changes: 2 additions & 0 deletions speedcenter/media/js/codespeed.js
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,8 @@ function renderComparisonPlot(plotid, benchmarks, exes, enviros, baseline, chart
plotoptions.legend.xoffset = -offset;
$("#" + plotid).css("margin-right", offset + 10);
if (w + offset > plotwidth) { w = plotwidth - offset -20; }
} else if (!horizontal && ticks.length <= 2) {
plotoptions.legend = {show: true, location: 'se'};
}

// Set bar type
Expand Down
26 changes: 23 additions & 3 deletions speedcenter/templates/codespeed/changes_table.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,35 @@
<table class="tablesorter">
<thead>
<tr>
<th>Benchmark</th><th>{{ units.units_title }} in {{ units.units }}<label title="lessisbetter" style="display:none;">{{ units.lessisbetter }}</label></th><th>Std dev</th>{% if units.hasmin %}<th>Min</th>{% endif%}{% if units.hasmax %}<th>Max</th>{% endif%}<th>Current change</th><th title="Trend for the last {{ trendconfig }} revisions"">Trend</th>
<th>Benchmark</th>
<th>{{ units.units_title }} in {{ units.units }}<label title="lessisbetter" style="display:none;">{{ units.lessisbetter }}</label></th>
{% if units.has_stddev %}<th>Std dev</th>{% endif%}
{% if units.hasmin %}<th>Min</th>{% endif%}
{% if units.hasmax %}<th>Max</th>{% endif%}
<th title="Current change">Change</th>
<th title="Trend for the last {{ trendconfig }} revisions"">Trend</th>
</tr>
</thead>
<tfoot>
<tr><td class="text" title="Arithmetic mean">Average</td><td></td><td></td>{% if units.hasmin %}<td>{{ units.totals.min }}</td>{% endif%}{% if units.hasmax %}<td>{{ units.totals.max }}</td>{% endif%}<td>{% ifnotequal units.totals.change "-" %}{{ units.totals.change|floatformat:2 }}%{% else %}{{ units.totals.change }}{% endifnotequal %}</td><td>{% ifnotequal units.totals.trend "-" %}{{ units.totals.trend|floatformat:2 }}%{% else %}{{ units.totals.trend }}{% endifnotequal %}</td></tr>
<tr>
<td class="text" title="Arithmetic mean">Average</td>
<td></td>
{% if units.hasmin %}<td></td>
{% endif%}{% if units.has_stddev %}<td>{{ units.totals.min }}</td>
{% endif%}{% if units.hasmax %}<td>{{ units.totals.max }}</td>
{% endif%}<td>{% ifnotequal units.totals.change "-" %}{{ units.totals.change|floatformat:2 }}%{% else %}{{ units.totals.change }}{% endifnotequal %}</td>
<td>{% ifnotequal units.totals.trend "-" %}{{ units.totals.trend|floatformat:2 }}%{% else %}{{ units.totals.trend }}{% endifnotequal %}</td>
</tr>
</tfoot>
<tbody>
{% for row in units.rows %} <tr>
<td class="text" title="{{ row.benchmark.description }}">{{ row.benchmark.name }}</td><td>{{ row.result|floatformat:units.precission }}</td><td>{{ row.std_dev|floatformat:units.precission }}</td>{% if units.hasmin %}<td>{{ row.val_min|floatformat:units.precission }}</td>{% endif%}{% if units.hasmax %}<td>{{ row.val_max|floatformat:units.precission }}</td>{% endif%}<td>{% ifequal row.change "-" %}-{% else %}{{ row.change|floatformat:2 }}%{% endifequal %}</td><td>{% ifequal row.trend "-" %}-{% else %}{{ row.trend|floatformat:2 }}%{% endifequal %}</td>
<td class="text" title="{{ row.benchmark.description }}">{{ row.benchmark.name }}</td>
<td>{{ row.result|floatformat:units.precission }}</td>
{% if units.has_stddev %}<td>{{ row.std_dev|floatformat:units.precission }}</td>
{% endif%}{% if units.hasmin %}<td>{{ row.val_min|floatformat:units.precission }}</td>
{% endif%}{% if units.hasmax %}<td>{{ row.val_max|floatformat:units.precission }}</td>
{% endif%}<td>{% ifequal row.change "-" %}-{% else %}{{ row.change|floatformat:2 }}%{% endifequal %}</td>
<td>{% ifequal row.trend "-" %}-{% else %}{{ row.trend|floatformat:2 }}%{% endifequal %}</td>
</tr>{% endfor %}
</tbody>
</table>{% endfor %}
Expand Down

0 comments on commit bfc6b45

Please sign in to comment.