Skip to content

Commit 636a4e7

Browse files
Embed the comparison on home page to reduce duplication
1 parent f661d20 commit 636a4e7

1 file changed

Lines changed: 9 additions & 35 deletions

File tree

speed_pypy/templates/home.html

Lines changed: 9 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,10 @@ <h2>Comparison</h2>
2929
{% if show_historical %}
3030
<div id="historical">
3131
<h3>How fast is {{ default_exe.project }}?</h3>
32-
<div id="baseline-comparison-plot" style="position:relative;height:400px;"></div>
32+
<iframe src="{% url 'embed-comparison' %}"
33+
title="{{ default_exe.project }} ({{ default_exe }}) vs {{ baseline }} benchmark comparison"
34+
style="border:0;width:100%;height:400px"
35+
loading="lazy"></iframe>
3336
<p class="plot-caption">Plot 1: The above plot represents {{ default_exe.project }} ({{ default_exe }}) benchmark times normalized to {{ baseline }}. Smaller is better.</p>
3437
<p>It depends greatly on the type of task being performed. The geometric average of all benchmarks is <span id="geomean"></span> or <strong id="geofaster"></strong> times <em>faster</em> than {{ baseline }}</p>
3538

@@ -68,15 +71,15 @@ <h3>How has PyPy performance evolved over time?</h3>
6871

6972
function renderplot(data) {
7073
if (data === null || data.length === 0) {
71-
$("#baseline-comparison-plot").html(getLoadText('Error retrieving data', 0));
74+
$("#historical-plot").html(getLoadText('Error retrieving data', 0));
7275
return;
7376
}
7477
if (typeof data === 'string' || data instanceof String) {
75-
$("#baseline-comparison-plot").html(getLoadText('Error retrieving data ' + data, 0));
78+
$("#historical-plot").html(getLoadText('Error retrieving data ' + data, 0));
7679
return;
7780
}
7881

79-
var benchmarks = [], latestValues = [], baselineValues = [];
82+
var latestValues = [];
8083
var trunk_geomean = 1;
8184
var tagged_data = [];
8285
for (var i in data['tagged_revs']) { tagged_data[i] = []; }
@@ -90,46 +93,17 @@ <h3>How has PyPy performance evolved over time?</h3>
9093
tagged_data[i].push(data['results'][benchname][rev] / data['results'][benchname][data['baseline']]);
9194
}
9295
if (!add_to_tagged_data) { continue; }
93-
benchmarks.push(benchname);
9496
var rel = data['results'][benchname]['latest'] / data['results'][benchname][data['baseline']];
9597
latestValues.push(rel);
96-
baselineValues.push(1.0);
9798
if (rel > 0 && !isNaN(rel)) { trunk_geomean *= rel; }
9899
}
99100

100101
trunk_geomean = Math.pow(trunk_geomean, 1 / latestValues.length);
101102
$('#geomean').html(trunk_geomean.toFixed(2));
102103
$('#geofaster').html((1 / trunk_geomean).toFixed(1));
103104

104-
// Plot 1: per-benchmark normalized comparison
105-
// Needs to be kept in sync with the plot in embed_comparison.html
106-
var wrap1 = document.getElementById('baseline-comparison-plot');
107-
var canvas1 = document.createElement('canvas');
108-
wrap1.appendChild(canvas1);
109-
new Chart(canvas1, {
110-
type: 'bar',
111-
data: {
112-
labels: benchmarks,
113-
datasets: [
114-
{label: 'latest {{ default_exe }}', data: latestValues, backgroundColor: '#4e79a7'},
115-
{label: data['baseline'], data: baselineValues, type: 'line',
116-
borderColor: '#f28e2b', backgroundColor: 'transparent',
117-
pointRadius: 0, borderWidth: 2, fill: false}
118-
]
119-
},
120-
options: {
121-
animation: false,
122-
responsive: true,
123-
maintainAspectRatio: false,
124-
plugins: {
125-
tooltip: {position: 'cursor'}
126-
},
127-
scales: {
128-
x: {ticks: {maxRotation: 70, minRotation: 70, autoSkip: false, font: {size: 11}}},
129-
y: {min: 0, max: 2.0, ticks: {callback: function(v) { return v.toFixed(2); }}}
130-
}
131-
}
132-
});
105+
// Plot 1 (per-benchmark normalized comparison) is rendered by the
106+
// embed_comparison page shown in the iframe above.
133107

134108
// Plot 2: geomean speedup over tagged revisions
135109
var geomeans = [1.0];

0 commit comments

Comments
 (0)