Skip to content

Webpage to display a set of benchmarks from RustPython #43

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 13 commits into from
Apr 6, 2021
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ navigation:
url: /blog
- title: Docs
url: /docs
- title: Benchmarks
url: /benchmarks
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should hold off on adding this to the main menu.

The main menu should have something like "dashboards", then under it a drop-down where we can list benchmarks, cpython compatibility, what is left (and maybe others).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with this, I will edit it. But before I do, I have a question about this:
To what should the "CPython compatibility" and "What's left" options link to?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mireille-raad I have moved the link to the benchmarks page to the dashboard for now and removed it from the navbar. Let me know if this is good enough or whether you still want to have a dropdown menu added to the navbar for the dasboard.

- title: GitHub
url: https://github.com/RustPython/RustPython/
- title: Gitter
Expand Down
1 change: 1 addition & 0 deletions _includes/head.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
<!-- google fonts -->
<link defer async href="https://fonts.googleapis.com/css?family=Fira+Sans|Sen:800&display=swap" rel="stylesheet">
<!-- stylesheet -->
<link defer async rel="stylesheet" href="{{ "/assets/tabs.css" | relative_url }}">
<link defer async rel="stylesheet" href="{{ "/assets/style.css" | relative_url }}">
<link defer async rel="stylesheet" href="{{ "/assets/media.css" | relative_url }}">
<link defer async rel="stylesheet" href="{{ "/assets/github.css" | relative_url }}">
Expand Down
78 changes: 78 additions & 0 deletions _layouts/benchmarks.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
---
layout: default
---

<section>
<div class="w-80 m-auto mt-2">
<div class="d-md-flex">
<div class="d-sm-none">
<img class="logo" src="{{site.baseurl}}/assets/img/rust-python-logo.svg" alt="RustPython Logo">
</div>
<div class="pl-md-2">
<div class="section-title">RustPython</div>
<div class="title">{{ page.title | escape }}</div>
<small>{{ site.benchmarks-intro }}</small>
</div>
</div>
</div>
</section>

<div class="w-80 m-auto mt-2">
<div class="benchmarks-intro">
{{ content }}
</div>

{% assign folders = "" | split: ", " %}
{% for image in site.static_files %}
{% if image.path contains 'criterion/' %}
{% assign imagepath = image.path | split: "/" %}
{% for subpath in imagepath %}
{% if forloop.index0 == 3 %}
{% assign folders = folders | append: pathName %}
{% endif %}
{% endfor %}
{% endif %}
{% endfor %}
{% assign folders = folders | uniq %}

<!-- The code block below does exactly the same as the one above, which one is cleaner? -->
<!-- {% assign folders = "" | split: ", " %}
{% for folder in site.static_files %}
{% if folder.path contains 'criterion/' %}
{% assign temp = folder.path | split: 'criterion/' %}
{% assign pathName = temp[1] | split: '/' | first %}
{% assign pathName = pathName | split: ", " %}
{% assign folders = folders | concat: pathName %}
{% endif %}
{% endfor%}
{% assign folders = folders | uniq %} -->

{% if folders.size == 0 %}
<p style="color: red;">There are no benchmarks to be displayed.</p>
<p>This shouldn't be happening, please contact one of the maintainers
through <a href="https://gitter.im/rustpython/Lobby">Gitter</a> to report this problem.</p>
{% else %}
<ul class="tab" data-tab="benchmarks">
{% for folder in folders %}
<li {% if forloop.index==1 %} class="active" {% endif %}>
<a href="">{{ folder }}</a>
</li>
{% endfor%}
</ul>
<ul class="tab-content" id="benchmarks">
{% for folder in folders %}
<li {% if forloop.index==1 %} class="active" {% endif %}>
<br>
{% for image in site.static_files %}
{% if image.path contains folder %}
<figure>
<img src="{{ site.baseurl }}{{ image.path }}" alt="image" />
<figcaption>{{ image.name }}</figcaption>
</figure>
{% endif %}
{% endfor%}
</li>
{% endfor%}
</ul>
{% endif %}
</div>
1 change: 1 addition & 0 deletions _layouts/default.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

{%- include footer.html -%}

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

</html>
43 changes: 43 additions & 0 deletions assets/js/tabs.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
const removeActiveClasses = function (ulElement) {
const lis = ulElement.querySelectorAll('li');
Array.prototype.forEach.call(lis, function(li) {
li.classList.remove('active');
});
}

const getChildPosition = function (element) {
var parent = element.parentNode;
var i = 0;
for (var i = 0; i < parent.children.length; i++) {
if (parent.children[i] === element) {
return i;
}
}

throw new Error('No parent found');
}

window.addEventListener('load', function () {
const tabLinks = document.querySelectorAll('ul.tab li a');

Array.prototype.forEach.call(tabLinks, function(link) {
link.addEventListener('click', function (event) {
event.preventDefault();

liTab = link.parentNode;
ulTab = liTab.parentNode;
position = getChildPosition(liTab);
if (liTab.className.includes('active')) {
return;
}

removeActiveClasses(ulTab);
tabContentId = ulTab.getAttribute('data-tab');
tabContentElement = document.getElementById(tabContentId);
removeActiveClasses(tabContentElement);

tabContentElement.querySelectorAll('li')[position].classList.add('active');
liTab.classList.add('active');
}, false);
});
});
48 changes: 48 additions & 0 deletions assets/tabs.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
.tab {
display: flex;
flex-wrap: wrap;
margin-left: -20px;
padding: 0;
list-style: none;
position: relative;
}

.tab > * {
flex: none;
padding-left: 20px;
position: relative;
}

.tab > * > a {
display: block;
text-align: center;
padding: 9px 20px;
color: #999;
border-bottom: 2px solid transparent;
border-bottom-color: transparent;
font-size: 12px;
text-transform: uppercase;
transition: color .1s ease-in-out;
line-height: 20px;
}

.tab > .active > a {
color:#222;
border-color: #1e87f0;
}

.tab li a {
text-decoration: none;
cursor: pointer;
}

.tab-content{
padding: 0;
}

.tab-content li {
display: none;
}
.tab-content li.active {
display: initial;
}
10 changes: 10 additions & 0 deletions benchmarks.markdown
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
layout: benchmarks
title: Benchmarks
---

This page displays some benchmarks that determine the performance of RustPython.

Most of these benchmarks compare RustPython to CPython.

More information about the benchmarks can be found on [the RustPython GitHub repo](https://github.com/RustPython/RustPython/tree/master/benches).