Skip to content

Commit 9a17e46

Browse files
authored
Merge pull request #84 from mattip/pypy3.12
use pypy 3.12 for the home page graphs
2 parents 0e95517 + 075d671 commit 9a17e46

10 files changed

Lines changed: 44 additions & 21 deletions

File tree

‎codespeed/results.py‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ def validate_result(item):
3232
'benchmark',
3333
'environment',
3434
'result_value',
35+
'source',
3536
]
3637

3738
error = True
@@ -41,7 +42,7 @@ def validate_result(item):
4142
elif key in item and item[key] == "":
4243
return 'Value for key "' + key + '" empty in request', error
4344

44-
if 'source' in item and item['source'] not in dict(Benchmark.S_TYPES):
45+
if item['source'] not in dict(Benchmark.S_TYPES):
4546
return 'Invalid source "%s"' % item['source'], error
4647

4748
try:
@@ -73,9 +74,8 @@ def save_result(data, update_repo=True):
7374
p, created = Project.objects.get_or_create(name=data["project"])
7475
branch, created = Branch.objects.get_or_create(name=data["branch"],
7576
project=p)
76-
source = data.get("source", "legacy")
7777
b, created = Benchmark.objects.get_or_create(
78-
name=data["benchmark"], source=source)
78+
name=data["benchmark"], source=data["source"])
7979

8080
if created:
8181
if "description" in data:

‎codespeed/tests/test_views.py‎

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ def setUp(self):
2929
'benchmark': 'float',
3030
'environment': 'Dual Core',
3131
'result_value': 456,
32+
'source': 'legacy',
3233
}
3334

3435
def test_add_correct_result(self):
@@ -190,11 +191,13 @@ def test_source_set_on_new_benchmark(self):
190191
b = Benchmark.objects.get(name='newbench')
191192
self.assertEqual(b.source, 'pyperformance')
192193

193-
def test_source_defaults_to_legacy(self):
194-
"""A payload without a source creates a 'legacy' Benchmark"""
195-
self.client.post(self.path, self.data)
196-
b = Benchmark.objects.get(name='float')
197-
self.assertEqual(b.source, 'legacy')
194+
def test_missing_source_rejected(self):
195+
"""A payload without a source is rejected instead of defaulting"""
196+
modified_data = copy.deepcopy(self.data)
197+
del modified_data['source']
198+
response = self.client.post(self.path, modified_data)
199+
self.assertEqual(response.status_code, 400)
200+
self.assertFalse(Benchmark.objects.filter(name='float').exists())
198201

199202
def test_same_name_different_source_are_distinct(self):
200203
"""The same name in a different suite is a separate Benchmark"""
@@ -245,28 +248,32 @@ def setUp(self):
245248
'executable': 'pypy-c',
246249
'benchmark': 'Richards',
247250
'environment': 'bigdog',
248-
'result_value': 456},
251+
'result_value': 456,
252+
'source': 'legacy'},
249253
{'commitid': '456',
250254
'project': 'pypy',
251255
'branch': 'default',
252256
'executable': 'pypy-c',
253257
'benchmark': 'Richards',
254258
'environment': 'bigdog',
255-
'result_value': 457},
259+
'result_value': 457,
260+
'source': 'legacy'},
256261
{'commitid': '456',
257262
'project': 'pypy',
258263
'branch': 'default',
259264
'executable': 'pypy-c',
260265
'benchmark': 'Richards2',
261266
'environment': 'bigdog',
262-
'result_value': 34},
267+
'result_value': 34,
268+
'source': 'legacy'},
263269
{'commitid': '789',
264270
'project': 'pypy',
265271
'branch': 'default',
266272
'executable': 'pypy-c',
267273
'benchmark': 'Richards',
268274
'environment': 'bigdog',
269-
'result_value': 458},
275+
'result_value': 458,
276+
'source': 'legacy'},
270277
]
271278

272279
def test_get_returns_405(self):
@@ -452,6 +459,7 @@ def setUp(self):
452459
'benchmark': 'float',
453460
'environment': 'Dual Core',
454461
'result_value': 200,
462+
'source': 'legacy',
455463
}
456464
resp = self.client.post(reverse('add-result'),
457465
self.data)

‎codespeed/views.py‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,9 @@ def embed_comparison(request):
114114

115115
@require_GET
116116
def gethistoricaldata(request):
117-
data = {'results': {}, 'benchmarks': []}
117+
# 'labels' maps each key in tagged_revs (plus baseline and 'latest') to
118+
# a two-line label [tag, project] for the x axis of the history chart.
119+
data = {'results': {}, 'benchmarks': [], 'labels': {}}
118120
env = Environment.objects.all()
119121
if settings.DEF_ENVIRONMENT:
120122
env = env.get(name=settings.DEF_ENVIRONMENT)
@@ -134,6 +136,7 @@ def gethistoricaldata(request):
134136
)
135137
rev0 = rev[0]
136138
resname = '{} {}'.format(b['executable'], rev0.tag)
139+
data['labels'][resname] = [rev0.tag, baseline_exe.project.name]
137140
baseline_results.append((resname, Result.objects.filter(
138141
executable=baseline_exe, revision=rev0, environment=env,
139142
benchmark__source='legacy')))
@@ -165,12 +168,14 @@ def gethistoricaldata(request):
165168
logger.info("no results for '%s' '%s' '%s'" % (str(_default_exe), str(rev), str(env)))
166169
continue
167170
default_results[rev.tag] = res
171+
data['labels'][rev.tag] = [rev.tag, _default_exe.project.name]
168172
data['tagged_revs'] = [rev.tag for rev in all_taggedrevs if rev.tag in default_results]
169173
# Fetch data for latest results
170174
executable = settings.DEF_EXECUTABLES[0]
171175
def_name = executable['name']
172176
def_project = Project.objects.get(name=executable['project'])
173177
default_exe = Executable.objects.get(name=def_name, project=def_project)
178+
data['labels']['latest'] = ['latest', default_exe.project.name]
174179
default_branch = Branch.objects.get(
175180
name=default_exe.project.default_branch,
176181
project=default_exe.project)

‎speed_pypy/settings.py‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@
9393
{'executable': 'cpython', 'revision': '3.11.15'},
9494
]
9595
DEF_EXECUTABLES = [
96+
{'name': 'pypy3.12-jit-64', 'project': 'PyPy3.12'},
9697
{'name': 'pypy3.11-jit-64', 'project': 'PyPy3.11'},
9798
]
9899
DEF_ENVIRONMENT = 'benchmarker2'

‎speed_pypy/templates/embed_comparison.html‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,13 @@
66
<meta name="viewport" content="width=device-width, initial-scale=1">
77
<title>PyPy vs CPython benchmark comparison</title>
88
<style>
9-
html, body { margin: 0; padding: 0; background: transparent; }
9+
html, body { margin: 0; padding: 0; background: transparent; height: 100%; overflow: hidden; }
10+
/* Fill the embedding iframe so the rotated benchmark labels are never
11+
clipped: the host page controls the height via the iframe. */
1012
#baseline-comparison-plot {
1113
position: relative;
1214
width: 100%;
13-
height: 480px;
15+
height: 100vh;
1416
font-family: sans-serif;
1517
}
1618
</style>

‎speed_pypy/templates/home.html‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ <h2>Comparison</h2>
3131
<h3>How fast is {{ default_exe.project }}?</h3>
3232
<iframe src="{% url 'embed-comparison' %}"
3333
title="{{ default_exe.project }} ({{ default_exe }}) vs {{ baseline }} benchmark comparison"
34-
style="border:0;width:100%;height:400px"
34+
style="border:0;width:100%;height:480px"
3535
loading="lazy"></iframe>
3636
<p class="plot-caption">Plot 1: The above plot represents {{ default_exe.project }} ({{ default_exe }}) benchmark times normalized to {{ baseline }}. Smaller is better.</p>
3737
<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>
@@ -120,9 +120,11 @@ <h3>How has PyPy performance evolved over time?</h3>
120120
geomeans.push(1 / trunk_geomean);
121121
$('#num_of_benchs').html(num_of_benchs);
122122

123-
var ticks2 = [data['baseline']];
124-
for (var i in data['tagged_revs']) { ticks2.push(data['tagged_revs'][i]); }
125-
ticks2.push('latest {{ default_exe.project }}');
123+
// Two-line labels: [tag, project]; fall back to the key itself.
124+
var labelFor = function(key) { return (data['labels'] || {})[key] || key; };
125+
var ticks2 = [labelFor(data['baseline'])];
126+
for (var i in data['tagged_revs']) { ticks2.push(labelFor(data['tagged_revs'][i])); }
127+
ticks2.push(labelFor('latest'));
126128

127129
var wrap2 = document.getElementById('historical-plot');
128130
var canvas2 = document.createElement('canvas');

‎tools/pypy/savecpython.py‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ def save(project, revision, results, options, executable, host, testing=False):
3131
'environment': host,
3232
'result_value': value,
3333
'result_date': current_date,
34+
'source': 'legacy',
3435
}
3536
if res_type == "ComparisonResult":
3637
data['std_dev'] = results['std_changed']

‎tools/pypy/saveresults.py‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ def save(project, revision, results, executable, host, url, testing=False,
7979
'environment': host,
8080
'result_value': value,
8181
'branch': branch,
82+
'source': 'legacy',
8283
}]
8384
if not value:
8485
print("Ignoring skipped result", data)

‎tools/save_multiple_results.py‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@
1818
"executable": "myexe O3 64bits",
1919
"benchmark": "float",
2020
"environment": "Dual Core",
21-
"result_value": 2500.0
21+
"result_value": 2500.0,
22+
"source": "legacy"
2223
},
2324
{
2425
"commitid": "8",
@@ -27,7 +28,8 @@
2728
"executable": "myexe O3 64bits",
2829
"benchmark": "int",
2930
"environment": "Dual Core",
30-
"result_value": 1100
31+
"result_value": 1100,
32+
"source": "legacy"
3133
}
3234
]
3335

‎tools/save_single_result.py‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
'benchmark': 'float',
2121
'environment': "Dual Core",
2222
'result_value': 4000,
23+
'source': 'legacy', # 'legacy' or 'pyperformance'
2324
}
2425

2526
# Optional fields

0 commit comments

Comments
 (0)