Skip to content

Commit 33500a9

Browse files
authored
Merge pull request #43 from theangryhobbit/master
Webpage to display a set of benchmarks from RustPython
2 parents 03864e8 + 903a873 commit 33500a9

File tree

8 files changed

+169
-1
lines changed

8 files changed

+169
-1
lines changed

Diff for: _config.yml

+1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ gitter: https://gitter.im/rustpython/Lobby
3030
show_excerpts: true
3131
contributor_excerpt: "" # TODO: write something here, goes right under "Contributors" heading
3232
blog-intro: Create an issue if you see something wrong. Edit posts or create new ones via PR on <a target="_blank" href="https://github.com/RustPython/rustpython.github.io">github.com/RustPython/rustpython.github.io</a>
33+
benchmarks-intro: More information about the benchmarks can be found on <a target="_blank" href="https://github.com/RustPython/RustPython">github.com/RustPython/RustPython</a>
3334

3435
permalink: /blog/:year/:month/:day/:title:output_ext
3536

Diff for: _includes/head.html

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
<!-- google fonts -->
88
<link defer async href="https://fonts.googleapis.com/css?family=Fira+Sans|Sen:800&display=swap" rel="stylesheet">
99
<!-- stylesheet -->
10+
<link defer async rel="stylesheet" href="{{ "/assets/tabs.css" | relative_url }}">
1011
<link defer async rel="stylesheet" href="{{ "/assets/style.css" | relative_url }}">
1112
<link defer async rel="stylesheet" href="{{ "/assets/media.css" | relative_url }}">
1213
<link defer async rel="stylesheet" href="{{ "/assets/github.css" | relative_url }}">

Diff for: _layouts/benchmarks.html

+64
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
---
2+
layout: default
3+
---
4+
5+
<section>
6+
<div class="w-80 m-auto mt-2">
7+
<div class="d-md-flex">
8+
<div class="d-sm-none">
9+
<img class="logo" src="{{site.baseurl}}/assets/img/rust-python-logo.svg" alt="RustPython Logo">
10+
</div>
11+
<div class="pl-md-2">
12+
<div class="section-title">RustPython</div>
13+
<div class="title">{{ page.title | escape }}</div>
14+
<small>{{ site.benchmarks-intro }}</small>
15+
</div>
16+
</div>
17+
</div>
18+
</section>
19+
20+
<div class="w-80 m-auto mt-2">
21+
<div class="benchmarks-intro">
22+
{{ content }}
23+
</div>
24+
25+
{% assign folders = "" | split: ", " %}
26+
{% for folder in site.static_files %}
27+
{% if folder.path contains 'criterion/' %}
28+
{% assign temp = folder.path | split: 'criterion/' %}
29+
{% assign pathName = temp[1] | split: '/' | first %}
30+
{% assign pathName = pathName | split: ", " %}
31+
{% assign folders = folders | concat: pathName %}
32+
{% endif %}
33+
{% endfor%}
34+
{% assign folders = folders | uniq %}
35+
36+
{% if folders.size == 0 %}
37+
<p style="color: red;">There are no benchmarks to be displayed.</p>
38+
<p>This shouldn't be happening, please contact one of the maintainers
39+
through <a href="https://gitter.im/rustpython/Lobby">Gitter</a> to report this problem.</p>
40+
{% else %}
41+
<ul class="tab" data-tab="benchmarks">
42+
{% for folder in folders %}
43+
<li {% if forloop.index==1 %} class="active" {% endif %} style="font-weight: bold;">
44+
<a href="">{{ folder }}</a>
45+
</li>
46+
{% endfor%}
47+
</ul>
48+
<ul class="tab-content" id="benchmarks">
49+
{% for folder in folders %}
50+
<li {% if forloop.index==1 %} class="active" {% endif %}>
51+
<br>
52+
{% for image in site.static_files %}
53+
{% if image.path contains folder %}
54+
<figure>
55+
<img src="{{ site.baseurl }}{{ image.path }}" alt="image" />
56+
<figcaption>{{ image.name }}</figcaption>
57+
</figure>
58+
{% endif %}
59+
{% endfor%}
60+
</li>
61+
{% endfor%}
62+
</ul>
63+
{% endif %}
64+
</div>

Diff for: _layouts/default.html

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
{%- include footer.html -%}
1717

18+
<script src="{{ "/assets/js/tabs.js" | relative_url }}"></script>
1819
</body>
1920

2021
</html>

Diff for: assets/js/tabs.js

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
function removeActiveClasses(ulElement) {
2+
3+
const lis = ulElement.querySelectorAll('li');
4+
Array.prototype.forEach.call(lis, function(li) {
5+
li.classList.remove('active');
6+
});
7+
}
8+
9+
function getChildPosition(element) {
10+
var parent = element.parentNode;
11+
var i = 0;
12+
for (var i = 0; i < parent.children.length; i++) {
13+
if (parent.children[i] === element) {
14+
return i;
15+
}
16+
}
17+
18+
throw new Error('No parent found');
19+
}
20+
21+
window.addEventListener('load', function () {
22+
const tabLinks = document.querySelectorAll('ul.tab li a');
23+
24+
Array.prototype.forEach.call(tabLinks, function(link) {
25+
link.addEventListener('click', function (event) {
26+
event.preventDefault();
27+
28+
const liTab = link.parentNode;
29+
const ulTab = liTab.parentNode;
30+
const position = getChildPosition(liTab);
31+
if (liTab.className.includes('active')) {
32+
return;
33+
}
34+
35+
removeActiveClasses(ulTab);
36+
const tabContentId = ulTab.getAttribute('data-tab');
37+
const tabContentElement = document.getElementById(tabContentId);
38+
39+
removeActiveClasses(tabContentElement);
40+
41+
tabContentElement.querySelectorAll('li')[position].classList.add('active');
42+
liTab.classList.add('active');
43+
}, false);
44+
});
45+
});

Diff for: assets/style.css

+1-1
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ ul.list-inline {
283283
line-height: 1.5em;
284284
}
285285

286-
.blog-intro {
286+
.blog-intro, .benchmarks-intro {
287287
background-color: #f6f8fa;
288288
padding-left: 2em;
289289
padding-right: 2em;

Diff for: assets/tabs.css

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
.tab {
2+
display: flex;
3+
flex-wrap: wrap;
4+
margin-left: -20px;
5+
padding: 0;
6+
list-style: none;
7+
position: relative;
8+
}
9+
10+
.tab > * {
11+
flex: none;
12+
padding-left: 20px;
13+
position: relative;
14+
}
15+
16+
.tab > * > a {
17+
display: block;
18+
text-align: center;
19+
padding: 9px 20px;
20+
color: #999;
21+
border-bottom: 2px solid transparent;
22+
border-bottom-color: transparent;
23+
font-size: 12px;
24+
text-transform: uppercase;
25+
transition: color .1s ease-in-out;
26+
line-height: 20px;
27+
}
28+
29+
.tab > .active > a {
30+
color:#222;
31+
border-color: #1e87f0;
32+
}
33+
34+
.tab li a {
35+
text-decoration: none;
36+
cursor: pointer;
37+
}
38+
39+
.tab-content{
40+
padding: 0;
41+
}
42+
43+
.tab-content li {
44+
display: none;
45+
}
46+
.tab-content li.active {
47+
display: initial;
48+
}

Diff for: benchmarks.markdown

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
layout: benchmarks
3+
title: Benchmarks
4+
---
5+
6+
This page displays some benchmarks that determine the performance of RustPython.
7+
8+
Most of these benchmarks compare RustPython to CPython.

0 commit comments

Comments
 (0)