Skip to content

Commit dd3b1ba

Browse files
committed
add comparison link to see all the benchmarks
1 parent af1c005 commit dd3b1ba

3 files changed

Lines changed: 66 additions & 10 deletions

File tree

‎speed_pypy/templates/embed_comparison.html‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,18 @@
2121
font-family: sans-serif;
2222
color: var(--chart-text);
2323
}
24+
#full-results {
25+
position: absolute;
26+
top: 4px;
27+
right: 8px;
28+
z-index: 1;
29+
font: 12px sans-serif;
30+
color: var(--chart-text);
31+
}
2432
</style>
2533
</head>
2634
<body>
35+
{% if full_results_url %}<a id="full-results" href="{{ full_results_url }}" target="_top" hidden>All benchmarks &rarr;</a>{% endif %}
2736
<div id="baseline-comparison-plot"></div>
2837

2938
<script type="text/javascript" src="{% static 'js/jquery-1.12.3.min.js' %}"></script>
@@ -96,6 +105,13 @@
96105
drawChart();
97106
}
98107

108+
// On our own home page the title carries this link; elsewhere (pypy.org)
109+
// it is the only way to the benchmarks the plot leaves out
110+
function embeddedOnOwnSite() {
111+
try { return window.parent !== window && !!window.parent.document; }
112+
catch (e) { return false; }
113+
}
114+
99115
function drawChart() {
100116
var rows = plotData.rows;
101117
var keep = narrow.matches ? 10 : 20;
@@ -129,6 +145,7 @@
129145
wrap.innerHTML = '';
130146
var canvas1 = document.createElement('canvas');
131147
wrap.appendChild(canvas1);
148+
$('#full-results').prop('hidden', embeddedOnOwnSite() || shown.length === rows.length);
132149
// Let the embedding page title the plot with how much of it is shown
133150
if (window.parent !== window) {
134151
window.parent.postMessage({codespeedBenchmarks: {

‎speed_pypy/templates/home.html‎

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,27 +28,27 @@ <h2>Comparison</h2>
2828
{% if show_historical %}
2929
<div id="historical">
3030
<h3>How fast is {{ default_exe.project }}?</h3>
31-
{% for source, label in sources %}
31+
{% for source, label, url in sources %}
3232
<div class="historical-cell">
33-
<h4 id="comparison-title-{{ source }}" data-label="{{ label }}">{{ label }} benchmarks</h4>
33+
<h4 id="comparison-title-{{ source }}" data-label="{{ label }}"><span class="title-text">{{ label }} benchmarks</span>{% if url %} <a class="see-all" href="{{ url }}" hidden>see all</a>{% endif %}</h4>
3434
<iframe src="{% url 'embed-comparison' %}?source={{ source }}" data-source="{{ source }}"
3535
title="{{ default_exe.project }} ({{ default_exe }}) vs {{ baseline }} {{ label }} benchmark comparison"
3636
loading="lazy"></iframe>
3737
</div>
3838
{% endfor %}
3939
<p class="plot-caption">{{ default_exe.project }} ({{ default_exe }}) benchmark times normalized to {{ baseline }}. Smaller is better.</p>
40-
<p>Performance depends greatly on the type of task being performed. The geometric average is{% for source, label in sources %}{% if not forloop.first %}{% if forloop.last %} and{% else %},{% endif %}{% endif %} <span id="geomean-{{ source }}"></span> or <strong id="geofaster-{{ source }}"></strong> times <em>faster</em> for the {{ label }} benchmarks{% endfor %}, compared to {{ baseline }}.</p>
40+
<p>Performance depends greatly on the type of task being performed. The geometric average is{% for source, label, url in sources %}{% if not forloop.first %}{% if forloop.last %} and{% else %},{% endif %}{% endif %} <span id="geomean-{{ source }}"></span> or <strong id="geofaster-{{ source }}"></strong> times <em>faster</em> for the {{ label }} benchmarks{% endfor %}, compared to {{ baseline }}.</p>
4141

4242
<h3>How has PyPy performance evolved over time?</h3>
4343
<div class="historical-grid">
44-
{% for source, label in sources %}
44+
{% for source, label, url in sources %}
4545
<div class="historical-cell">
4646
<h4>{{ label }} benchmarks</h4>
4747
<div id="historical-plot-{{ source }}" class="historical-plot"></div>
4848
</div>
4949
{% endfor %}
5050
</div>
51-
<p class="plot-caption">Speedup compared to {{ baseline }}, using the inverse of the geometric average of normalized times, out of{% for source, label in sources %}{% if not forloop.first %} and{% endif %} <span id="num_of_benchs-{{ source }}"></span> {{ label }}{% endfor %} benchmarks (see <a href="http://dl.acm.org/citation.cfm?id=5673" title="How not to lie with statistics: the correct way to summarize benchmark results">paper</a> on why the geometric mean is better for normalized results). Larger is better.</p>
51+
<p class="plot-caption">Speedup compared to {{ baseline }}, using the inverse of the geometric average of normalized times, out of{% for source, label, url in sources %}{% if not forloop.first %} and{% endif %} <span id="num_of_benchs-{{ source }}"></span> {{ label }}{% endfor %} benchmarks (see <a href="http://dl.acm.org/citation.cfm?id=5673" title="How not to lie with statistics: the correct way to summarize benchmark results">paper</a> on why the geometric mean is better for normalized results). Larger is better.</p>
5252
</div>
5353
{% endif %}
5454
</div>
@@ -128,8 +128,14 @@ <h4>{{ label }} benchmarks</h4>
128128
if (frame.contentWindow !== e.source) { return; }
129129
var source = frame.getAttribute('data-source');
130130
var counts = e.data.codespeedBenchmarks;
131-
$('#comparison-title-' + source).text(counts.total + ' ' +
132-
$('#comparison-title-' + source).data('label') + ' benchmarks (' + counts.shown + ' shown)');
131+
var $title = $('#comparison-title-' + source);
132+
var truncated = counts.shown < counts.total;
133+
$title.find('.title-text').text(counts.total + ' ' + $title.data('label') +
134+
' benchmarks (' + counts.shown + ' shown' + (truncated ? ',' : ')'));
135+
// Wrap the link into the parenthesis only when something is hidden
136+
$title.find('.see-all').prop('hidden', !truncated)
137+
.next('.see-all-close').remove();
138+
if (truncated) { $title.find('.see-all').after('<span class="see-all-close">)</span>'); }
133139
});
134140
});
135141

‎speed_pypy/views.py‎

Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
"""Views specific to speed.pypy.org."""
22
import logging
3+
from urllib.parse import urlencode
34

45
from django.conf import settings
56
from django.shortcuts import render
7+
from django.urls import reverse
68
from django.views.decorators.clickjacking import xframe_options_exempt
79
from django.views.decorators.http import require_GET
810

9-
from codespeed.models import Executable, Project
11+
from codespeed.models import Environment, Executable, Project, Revision
1012
from codespeed.views import HomeView
1113

1214
logger = logging.getLogger(__name__)
@@ -15,11 +17,42 @@
1517
HOME_SOURCES = [('legacy', 'Legacy'), ('pyperformance', 'pyperformance')]
1618

1719

20+
def full_results_url(request, source):
21+
"""Absolute comparison-page link showing every `source` benchmark for the
22+
latest default executable against the first baseline, or None."""
23+
try:
24+
def_project = Project.objects.get(name=settings.DEF_EXECUTABLES[0]['project'])
25+
default_exe = Executable.objects.get(
26+
name=settings.DEF_EXECUTABLES[0]['name'], project=def_project)
27+
baseline_exe = Executable.objects.get(name=settings.DEF_BASELINES[0]['executable'])
28+
baseline_rev = Revision.objects.filter(
29+
branch__project=baseline_exe.project,
30+
tag=settings.DEF_BASELINES[0]['revision']).first()
31+
if baseline_rev is None:
32+
return None
33+
baseline_key = '%d:%d' % (baseline_exe.id, baseline_rev.id)
34+
query = {
35+
'exe': '%d:L:%s,%s' % (default_exe.id, def_project.default_branch, baseline_key),
36+
'ben': source,
37+
'hor': 'true',
38+
'bas': baseline_key,
39+
'chart': 'normal bars',
40+
}
41+
if settings.DEF_ENVIRONMENT:
42+
query['env'] = Environment.objects.get(name=settings.DEF_ENVIRONMENT).id
43+
except Exception as e:
44+
logger.error('full_results_url: %s', e)
45+
return None
46+
return request.build_absolute_uri(
47+
reverse('comparison') + '?' + urlencode(query, safe=':,'))
48+
49+
1850
class PyPyHomeView(HomeView):
1951

2052
def get_context_data(self, **kwargs):
2153
context = super().get_context_data(**kwargs)
22-
context['sources'] = HOME_SOURCES
54+
context['sources'] = [(source, label, full_results_url(self.request, source))
55+
for source, label in HOME_SOURCES]
2356
return context
2457

2558

@@ -31,7 +64,7 @@ def embed_comparison(request):
3164
source = request.GET.get('source', 'legacy')
3265
if source not in ('legacy', 'pyperformance'):
3366
source = 'legacy'
34-
context = {'source': source}
67+
context = {'source': source, 'full_results_url': full_results_url(request, source)}
3568
try:
3669
context['baseline'] = Executable.objects.get(
3770
name=settings.DEF_BASELINES[0]['executable'])

0 commit comments

Comments
 (0)