From 1c503a5069b63fa11efdf7c50af7445d0581e1ce Mon Sep 17 00:00:00 2001 From: Jimmy Vlekke Date: Thu, 18 Mar 2021 21:49:21 +0100 Subject: [PATCH 01/12] Adds a benchmark page to the website The page looks for images in a folder to display these --- _config.yml | 2 ++ _layouts/benchmarks.html | 33 +++++++++++++++++++++++++++++++++ benchmarks.markdown | 6 ++++++ 3 files changed, 41 insertions(+) create mode 100644 _layouts/benchmarks.html create mode 100644 benchmarks.markdown diff --git a/_config.yml b/_config.yml index 6d259e7a..4a6a0ea4 100644 --- a/_config.yml +++ b/_config.yml @@ -36,6 +36,8 @@ navigation: url: /blog - title: Docs url: /docs + - title: Benchmarks + url: /benchmarks - title: GitHub url: https://github.com/RustPython/RustPython/ - title: Gitter diff --git a/_layouts/benchmarks.html b/_layouts/benchmarks.html new file mode 100644 index 00000000..992898f6 --- /dev/null +++ b/_layouts/benchmarks.html @@ -0,0 +1,33 @@ +--- +layout: default +--- + +
+
+
+
+ +
+
+
Benchmarks
+
{{ site.title }} {{ page.title | escape }}
+ {{ site.benchmarks-intro }} +
+
+
+
+ +
+
+ {{ content }} +
+ + {% for image in site.static_files %} + {% if image.path contains 'benchmarks' %} +
+ image +
{{ image.name }}
+
+ {% endif %} + {% endfor %} +
\ No newline at end of file diff --git a/benchmarks.markdown b/benchmarks.markdown new file mode 100644 index 00000000..4e7d9416 --- /dev/null +++ b/benchmarks.markdown @@ -0,0 +1,6 @@ +--- +layout: benchmarks +title: Benchmarks +--- + +RustPython is an awesome Python interpreter! On this page you can see how it compares to CPython. From 6be15765c402be7ebe429171e98f9ef06b934397 Mon Sep 17 00:00:00 2001 From: Jimmy Vlekke Date: Thu, 25 Mar 2021 18:50:27 +0100 Subject: [PATCH 02/12] Create tabs on benchmakrs page with benchmakrs for each tab --- _includes/head.html | 1 + _layouts/benchmarks.html | 53 ++++++++++++++++++++++++++++++++++++---- _layouts/default.html | 1 + assets/js/tabs.js | 43 ++++++++++++++++++++++++++++++++ assets/tabs.css | 48 ++++++++++++++++++++++++++++++++++++ 5 files changed, 141 insertions(+), 5 deletions(-) create mode 100644 assets/js/tabs.js create mode 100644 assets/tabs.css diff --git a/_includes/head.html b/_includes/head.html index f2ec9a4e..8096a5b4 100644 --- a/_includes/head.html +++ b/_includes/head.html @@ -7,6 +7,7 @@ + diff --git a/_layouts/benchmarks.html b/_layouts/benchmarks.html index 992898f6..cacc52e1 100644 --- a/_layouts/benchmarks.html +++ b/_layouts/benchmarks.html @@ -22,12 +22,55 @@ {{ content }} + + + {% assign folders = "" | split: ", " %} {% for image in site.static_files %} - {% if image.path contains 'benchmarks' %} -
- image -
{{ image.name }}
-
+ {% 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 %} + + + + + + + + \ No newline at end of file diff --git a/_layouts/default.html b/_layouts/default.html index 58e141b7..d3f87a77 100644 --- a/_layouts/default.html +++ b/_layouts/default.html @@ -15,6 +15,7 @@ {%- include footer.html -%} + diff --git a/assets/js/tabs.js b/assets/js/tabs.js new file mode 100644 index 00000000..b9440c0a --- /dev/null +++ b/assets/js/tabs.js @@ -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); + }); +}); \ No newline at end of file diff --git a/assets/tabs.css b/assets/tabs.css new file mode 100644 index 00000000..b25e795d --- /dev/null +++ b/assets/tabs.css @@ -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; +} \ No newline at end of file From 038aad6246bd36b9cf8e3f8659322bb1f2c5f7bf Mon Sep 17 00:00:00 2001 From: Jimmy Vlekke Date: Tue, 30 Mar 2021 21:52:36 +0200 Subject: [PATCH 03/12] Add zero folders found check, thus no benchmarks to be displayed --- _layouts/benchmarks.html | 17 +++++++++-------- benchmarks.markdown | 6 +++++- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/_layouts/benchmarks.html b/_layouts/benchmarks.html index cacc52e1..a8dc0262 100644 --- a/_layouts/benchmarks.html +++ b/_layouts/benchmarks.html @@ -9,8 +9,8 @@
-
Benchmarks
-
{{ site.title }} {{ page.title | escape }}
+
RustPython
+
{{ page.title | escape }}
{{ site.benchmarks-intro }}
@@ -22,8 +22,6 @@ {{ content }} - - {% assign folders = "" | split: ", " %} {% for image in site.static_files %} {% if image.path contains 'criterion/' %} @@ -48,9 +46,11 @@ {% endfor%} {% assign folders = folders | uniq %} --> - - - + {% if folders.size == 0 %} +

There are no benchmarks to be displayed.

+

This shouldn't be happening, please contact one of the maintainers + through Gitter to report this problem.

+ {% else %}
    {% for folder in folders %}
  • @@ -65,7 +65,7 @@ {% for image in site.static_files %} {% if image.path contains folder %}
    - image + image
    {{ image.name }}
    {% endif %} @@ -73,4 +73,5 @@
  • {% endfor%}
+ {% endif %} \ No newline at end of file diff --git a/benchmarks.markdown b/benchmarks.markdown index 4e7d9416..c96fb8da 100644 --- a/benchmarks.markdown +++ b/benchmarks.markdown @@ -3,4 +3,8 @@ layout: benchmarks title: Benchmarks --- -RustPython is an awesome Python interpreter! On this page you can see how it compares to CPython. +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). From c47d73bbc3a203a6fdef0e323bdc3338d40d7dc5 Mon Sep 17 00:00:00 2001 From: Jimmy Vlekke Date: Tue, 30 Mar 2021 22:02:08 +0200 Subject: [PATCH 04/12] Update indentation --- _layouts/benchmarks.html | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/_layouts/benchmarks.html b/_layouts/benchmarks.html index a8dc0262..09ff5160 100644 --- a/_layouts/benchmarks.html +++ b/_layouts/benchmarks.html @@ -24,17 +24,18 @@ {% 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 %} + {% 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 %} + - + {% assign folders = folders | uniq %} {% if folders.size == 0 %}

There are no benchmarks to be displayed.

From aaffc4c7981cd07b37adbee67bb7ec59aeaa0635 Mon Sep 17 00:00:00 2001 From: Jimmy Vlekke Date: Thu, 1 Apr 2021 21:42:51 +0200 Subject: [PATCH 11/12] Adds benchmark intro to _config file and updates the UI a bit --- _config.yml | 1 + _layouts/benchmarks.html | 4 ++-- assets/style.css | 2 +- benchmarks.markdown | 2 -- 4 files changed, 4 insertions(+), 5 deletions(-) diff --git a/_config.yml b/_config.yml index 4a6a0ea4..668a3f60 100644 --- a/_config.yml +++ b/_config.yml @@ -30,6 +30,7 @@ gitter: https://gitter.im/rustpython/Lobby show_excerpts: true contributor_excerpt: "" # TODO: write something here, goes right under "Contributors" heading blog-intro: Create an issue if you see something wrong. Edit posts or create new ones via PR on github.com/RustPython/rustpython.github.io +benchmarks-intro: More information about the benchmarks can be found on github.com/RustPython/RustPython navigation: - title: Blog diff --git a/_layouts/benchmarks.html b/_layouts/benchmarks.html index e3f4c263..5302c49c 100644 --- a/_layouts/benchmarks.html +++ b/_layouts/benchmarks.html @@ -21,7 +21,7 @@
{{ content }}
- + {% assign folders = "" | split: ", " %} {% for folder in site.static_files %} {% if folder.path contains 'criterion/' %} @@ -40,7 +40,7 @@ {% else %}
    {% for folder in folders %} -
  • +
  • {{ folder }}
  • {% endfor%} diff --git a/assets/style.css b/assets/style.css index aeabe70f..eb8fec17 100644 --- a/assets/style.css +++ b/assets/style.css @@ -279,7 +279,7 @@ ul.list-inline { line-height: 1.5em; } -.blog-intro { +.blog-intro, .benchmarks-intro { background-color: #f6f8fa; padding-left: 2em; padding-right: 2em; diff --git a/benchmarks.markdown b/benchmarks.markdown index c96fb8da..7b7fe774 100644 --- a/benchmarks.markdown +++ b/benchmarks.markdown @@ -6,5 +6,3 @@ 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). From 903a873be7beb50566eb1d3c9554bd89f716341d Mon Sep 17 00:00:00 2001 From: Jimmy Vlekke Date: Thu, 1 Apr 2021 21:58:46 +0200 Subject: [PATCH 12/12] Removes the benchmarks from the navbar --- _config.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/_config.yml b/_config.yml index 668a3f60..12516116 100644 --- a/_config.yml +++ b/_config.yml @@ -37,8 +37,6 @@ navigation: url: /blog - title: Docs url: /docs - - title: Benchmarks - url: /benchmarks - title: GitHub url: https://github.com/RustPython/RustPython/ - title: Gitter