Commit 0c11474e authored by Denis Salem's avatar Denis Salem
Browse files

Add Nikola benchmmark

parent 477eb55f
......@@ -29,7 +29,7 @@ Pour compiler le blog avec ce thème bien à vous :
VenC utilise par défaut le thème local quand aucun nom de thème ne lui est précisé.
Pour en savoir plus sur les thèmes, rendez-vous [ici](.:GetRelativeOrigin:.Les-Themes)
Pour en savoir plus sur les thèmes, rendez-vous [ici](.:GetChapterAttributeByIndex::path::4.6:.)
Le contenu de votre site est maintenant disponible dans le répertoire
_blog_ de votre blog. Pour visualiser le résultat, vous pouvez utiliser la commande :
......
......@@ -333,10 +333,10 @@ renseignant son index.
Typiquement ce pattern sert à récupérer le titre
du chapitre, ou son chemin. Par exemple
> .:GetChapterAttributeByIndex::path::1.2.3:.
> .:Escape:: .:GetChapterAttributeByIndex::path::1.2.3:. ::EndEscape:.
Renverra le permalien relatif du chapitre 1.2.3.
> .:GetChapterAttributeByIndex::title::4.2:.
> .:Escape:: .:GetChapterAttributeByIndex::title::4.2:. ::EndEscape:.
Renverra le permalien relatif du chapitre 4.2
......@@ -178,6 +178,7 @@
DONE | Fix chapters rendering (only first level sub-chapter were rendered)
# version 2.1.x
TODO | venc -xb should also work in subdirectories
TODO | Replace aside element by nav
TODO | Improve context / ressource naming for error management
TODO | Because of fully recursive pattern, some contextual variable are now useless, like {relative_origin}
......@@ -196,9 +197,8 @@
TODO | Fix gvim / -ex.
TODO | Fix encoding issue in JSON-LD document.
TODO | Catch "OSError: [Errno 98] Address already in use".
TODO | Catch invalid encoding at startup.
TODO | Catch invalid encoding at startup. (???)
TODO | Create entry with default template, if defined.
TODO | Add support for access metadata by key.
TODO | Make some dependencies optional.
TODO | Split themes from main branch.
TODO | Add translation for Deutsch and Spanish.
......@@ -216,11 +216,11 @@
TODO | Add more informations into JSON-LD document.
TODO | Optimize and refine JSON-LD processing.
TODO | Embed as much as possible microdata/JSON-LD into blog.
TODO | Automatically add entries categories to entries tags.
TODO | Improve sub folder management in Entry and EntriesThread.
TODO | Optimize objects dereferencing.
TODO | Add draft support.
TODO | Add CPU threads support.
TODO | Enhance FTP transfert with multiple connections.
TODO | Regenerate any missing folders.
TODO | Override server port with extra arg.
TODO | Try to install an up to date oembed providers from https://oembed.com/providers.json with pip
......
This diff is collapsed.
{# -*- coding: utf-8 -*- #}
{% import 'base_helper.tmpl' as base with context %}
{% import 'base_header.tmpl' as header with context %}
{% import 'base_footer.tmpl' as footer with context %}
{{ set_locale(lang) }}
{# <html> tag is included by base.html_headstart #}
{{ base.html_headstart() }}
{% block extra_head %}
{# Leave this block alone. #}
{% endblock %}
{{ template_hooks['extra_head']() }}
</head>
<body>
<div id="container">
{{ header.html_header() }}
<main id="content">
{% block content %}{% endblock %}
</main>
{{ footer.html_footer() }}
</div>
{{ body_end }}
{{ template_hooks['body_end']() }}
</body>
</html>
{# -*- coding: utf-8 -*- #}
{% macro html_footer() %}
{% if content_footer %}
<footer id="footer">
<p>{{ content_footer }}</p>
{{ template_hooks['page_footer']() }}
</footer>
{% endif %}
{% endmacro %}
{# -*- coding: utf-8 -*- #}
{% import 'base_helper.tmpl' as base with context %}
{% macro html_header() %}
<header id="header">
{{ html_site_title() }}
{{ html_navigation_links() }}
</header>
{{ template_hooks['page_header']() }}
{% endmacro %}
{% macro html_site_title() %}
<h1 id="brand">
<a href="{{ _link("root", None, lang) }}" title="{{ blog_title|e }}" rel="home">
{{ blog_title|e }}
</a>
</h1>
{% endmacro %}
{% macro html_navigation_links() %}
<nav id="menu">
<ul>
{{ html_navigation_links_entries(navigation_links) }}
{{ html_navigation_links_entries(navigation_alt_links) }}
{{ template_hooks['menu']() }}
{{ template_hooks['menu_alt']() }}
</ul>
</nav>
{% endmacro %}
{% macro html_navigation_links_entries(navigation_links_source) %}
{% for url, text in navigation_links_source[lang] %}
{% if isinstance(url, tuple) %}
<li> {{ text }}
<ul>
{% for suburl, text in url %}
{% if rel_link(permalink, suburl) == "#" %}
<li class="active"><a href="{{ permalink }}">{{ text }}<span class="sr-only"> {{ messages("(active)", lang) }}</span></a></li>
{% else %}
<li><a href="{{ suburl }}">{{ text }}</a></li>
{% endif %}
{% endfor %}
</ul>
{% else %}
{% if rel_link(permalink, url) == "#" %}
<li class="active"><a href="{{ permalink }}">{{ text }}<span class="sr-only"> {{ messages("(active)", lang) }}</span></a></li>
{% else %}
<li><a href="{{ url }}">{{ text }}</a></li>
{% endif %}
{% endif %}
{% endfor %}
{% endmacro %}
{# -*- coding: utf-8 -*- #}
{% import 'feeds_translations_helper.tmpl' as feeds_translations with context %}
{% macro html_headstart() %}
<!DOCTYPE html>
<html lang="{{ lang }}">
<head>
<meta charset="utf-8">
{% if title == blog_title %}
<title>{{ blog_title|e }}</title>
{% else %}
<title>{{ title|e }} | {{ blog_title|e }}</title>
{% endif %}
{{ feeds_translations.head(classification=None, kind='index', other=False) }}
{% if prevlink %}
<link rel="prev" href="{{ prevlink }}" type="text/html">
{% endif %}
{% if nextlink %}
<link rel="next" href="{{ nextlink }}" type="text/html">
{% endif %}
{{ extra_head_data }}
{% endmacro %}
{# -*- coding: utf-8 -*- #}
{% macro _head_feed_link(link_type, link_name, link_postfix, classification, kind, language) %}
{% if translations|length > 1 %}
<link rel="alternate" type="{{ link_type }}" title="{{ link_name|e }} ({{ language }})" hreflang="{{ language }}" href="{{ _link(kind + '_' + link_postfix, classification, language) }}">
{% else %}
<link rel="alternate" type="{{ link_type }}" title="{{ link_name|e }}" hreflang="{{ language }}" href="{{ _link(kind + '_' + link_postfix, classification, language) }}">
{% endif %}
{% endmacro %}
{% macro _html_feed_link(link_type, link_name, link_postfix, classification, kind, language, name=None) %}
{% if translations|length > 1 %}
{% if name and kind != "archive" and kind != "author" %}
<a href="{{ _link(kind + '_' + link_postfix, classification, language) }}" hreflang="{{ language }}" type="{{ link_type }}">{{ messages(link_name, language) }} ({{ name|e }}, {{ language }})</a>
{% else %}
<a href="{{ _link(kind + '_' + link_postfix, classification, language) }}" hreflang="{{ language }}" type="{{ link_type }}">{{ messages(link_name, language) }} ({{ language }})</a>
{% endif %}
{% else %}
{% if name and kind != "archive" and kind != "author" %}
<a href="{{ _link(kind + '_' + link_postfix, classification, language) }}" hreflang="{{ language }}" type="{{ link_type }}">{{ messages(link_name, language) }} ({{ name|e }})</a>
{% else %}
<a href="{{ _link(kind + '_' + link_postfix, classification, language) }}" hreflang="{{ language }}" type="{{ link_type }}">{{ messages(link_name, language) }}</a>
{% endif %}
{% endif %}
{% endmacro %}
{% macro _html_translation_link(classification, kind, language, name=None) %}
{% if name and kind != "archive" and kind != "author" %}
<a href="{{ _link(kind, classification, language) }}" hreflang="{{ language }}" rel="alternate">{{ messages("LANGUAGE", language) }} ({{ name|e }})</a>
{% else %}
<a href="{{ _link(kind, classification, language) }}" hreflang="{{ language }}" rel="alternate">{{ messages("LANGUAGE", language) }}</a>
{% endif %}
{% endmacro %}
{% macro _head_rss(classification=None, kind='index', rss_override=True) %}
{% if rss_link and rss_override %}
{{ rss_link }}
{% endif %}
{% if generate_rss and not (rss_link and rss_override) and kind != 'archive' %}
{% if translations|length > 1 and has_other_languages and classification and kind != 'index' %}
{% for language, classification, name in all_languages %}
<link rel="alternate" type="application/rss+xml" title="RSS for {{ kind }} {{ name|e }} ({{ language }})" hreflang="{{ language }}" href="{{ _link(kind + "_rss", classification, language) }}">
{% endfor %}
{% else %}
{% for language in translations_feedorder %}
{% if (classification or classification == '') and kind != 'index' %}
{{ _head_feed_link('application/rss+xml', 'RSS for ' + kind + ' ' + classification, 'rss', classification, kind, language) }}
{% else %}
{{ _head_feed_link('application/rss+xml', 'RSS', 'rss', classification, 'index', language) }}
{% endif %}
{% endfor %}
{% endif %}
{% endif %}
{% endmacro %}
{% macro _head_atom(classification=None, kind='index') %}
{% if generate_atom %}
{% if translations|length > 1 and has_other_languages and classification and kind != 'index' %}
{% for language, classification, name in all_languages %}
<link rel="alternate" type="application/atom+xml" title="Atom for {{ kind }} {{ name|e }} ({{ language }})" hreflang="{{ language }}" href="{{ _link(kind + "_atom", classification, language) }}">
{% endfor %}
{% else %}
{% for language in translations_feedorder %}
{% if (classification or classification == '') and kind != 'index' %}
{{ _head_feed_link('application/atom+xml', 'Atom for ' + kind + ' ' + classification, 'atom', classification, kind, language) }}
{% else %}
{{ _head_feed_link('application/atom+xml', 'Atom', 'atom', classification, 'index', language) }}
{% endif %}
{% endfor %}
{% endif %}
{% endif %}
{% endmacro %}
{# Handles both feeds and translations #}
{% macro head(classification=None, kind='index', feeds=True, other=True, rss_override=True, has_no_feeds=False) %}
{% if feeds and not has_no_feeds %}
{{ _head_rss(classification, 'index' if (kind == 'archive' and rss_override) else kind, rss_override) }}
{{ _head_atom(classification, kind) }}
{% endif %}
{% if other and has_other_languages and other_languages %}
{% for language, classification, _ in other_languages %}
<link rel="alternate" hreflang="{{ language }}" href="{{ _link(kind, classification, language) }}">
{% endfor %}
{% endif %}
{% endmacro %}
{% macro feed_link(classification, kind) %}
{% if generate_atom or generate_rss %}
{% if translations|length > 1 and has_other_languages and kind != 'index' %}
{% for language, classification, name in all_languages %}
<p class="feedlink">
{% if generate_atom %}
{{ _html_feed_link('application/atom+xml', 'Atom feed', 'atom', classification, kind, language, name) }}
{% endif %}
{% if generate_rss and kind != 'archive' %}
{{ _html_feed_link('application/rss+xml', 'RSS feed', 'rss', classification, kind, language, name) }}
{% endif %}
</p>
{% endfor %}
{% else %}
{% for language in translations_feedorder %}
<p class="feedlink">
{% if generate_atom %}
{{ _html_feed_link('application/atom+xml', 'Atom feed', 'atom', classification, kind, language) }}
{% endif %}
{% if generate_rss and kind != 'archive' %}
{{ _html_feed_link('application/rss+xml', 'RSS feed', 'rss', classification, kind, language) }}
{% endif %}
</p>
{% endfor %}
{% endif %}
{% endif %}
{% endmacro %}
{% macro translation_link(kind) %}
{% if has_other_languages and other_languages %}
<div class="translationslist translations">
<h3 class="translationslist-intro">{{ messages("Also available in:") }}</h3>
{% for language, classification, name in other_languages %}
<p>{{ _html_translation_link(classification, kind, language, name) }}</p>
{% endfor %}
</div>
{% endif %}
{% endmacro %}
{# -*- coding: utf-8 -*- #}
{% import 'post_helper.tmpl' as helper with context %}
{% import 'comments_helper.tmpl' as comments with context %}
{% macro html_title() %}
<h1 class="p-name entry-title" itemprop="headline name"><a href="{{ post.permalink() }}" class="u-url">{{ post.title()|e }}</a></h1>
{% endmacro %}
{% macro html_translations(post) %}
{% if post.translated_to|length > 1 %}
<div class="metadata posttranslations translations">
<h3 class="posttranslations-intro">{{ messages("Also available in:") }}</h3>
{% for langname in translations|sort %}
{% if langname != lang and post.is_translation_available(langname) %}
<p><a href="{{ post.permalink(langname) }}" rel="alternate" hreflang="{{ langname }}">{{ messages("LANGUAGE", langname) }}</a></p>
{% endif %}
{% endfor %}
</div>
{% endif %}
{% endmacro %}
{% macro html_post_header() %}
<header>
{{ html_title() }}
<div class="metadata">
</div>
{{ html_translations(post) }}
</header>
{% endmacro %}
......@@ -37,7 +37,8 @@ Nature of the benchmark:
# Comment items you want to ignore
WILL_TESTS = [
"VenC",
"Pelican"
"Pelican",
"Nikola"
]
########################################################################
......@@ -46,6 +47,11 @@ import datetime
import time
import vencbenchmark
from vencbenchmark.nikola import init_nikola_blog
from vencbenchmark.nikola import gen_nikola_entry
from vencbenchmark.nikola import benchmark_nikola
from vencbenchmark.nikola import clear_nikola_blog
from vencbenchmark.pelican import init_pelican_blog
from vencbenchmark.pelican import gen_pelican_entry
from vencbenchmark.pelican import benchmark_pelican
......@@ -61,19 +67,23 @@ import json
stages = {
"init": {
"VenC" : init_venc_blog,
"Pelican" : init_pelican_blog
"Pelican" : init_pelican_blog,
"Nikola" : init_nikola_blog,
},
"gen_entries" : {
"VenC" : gen_venc_entry,
"Pelican" : gen_pelican_entry
"VenC" : gen_venc_entry,
"Pelican" : gen_pelican_entry,
"Nikola" : gen_nikola_entry,
},
"benchmark": {
"VenC": benchmark_venc,
"Pelican": benchmark_pelican
"VenC" : benchmark_venc,
"Pelican" : benchmark_pelican,
"Nikola" : benchmark_nikola,
},
"clear" : {
"VenC" : clear_venc_blog,
"Pelican" : clear_pelican_blog
"VenC" : clear_venc_blog,
"Pelican" : clear_pelican_blog,
"Nikola" : clear_nikola_blog,
}
}
......@@ -90,11 +100,13 @@ def benchmark():
series.append(
stages["benchmark"][item]()
)
benchmark_data[item].append({
"time" : sum([ v["time"] for v in series ]) / len(series),
"internal" : sum([ v["internal"] for v in series ]) / len(series)
})
average = {}
average["time"] = sum([ v["time"] for v in series ]) / len(series)
if series[0]["internal"] != None:
average["internal"] = sum([ v["internal"] for v in series ]) / len(series)
benchmark_data[item].append(average)
vencbenchmark.update_context()
......@@ -113,11 +125,12 @@ def init():
stages["init"][item]()
print("VenC Comparative Benchmark v"+vencbenchmark.BENCHMARCH_VERSION)
try:
clear()
init()
benchmark()
clear()
#clear()
results = {
"environment" : vencbenchmark.ENVIRONMENT,
"benchmark_data": benchmark_data
......
#! /usr/bin/env python3
# Copyright 2016, 2020 Denis Salem
#
# This file is part of VenC.
#
# VenC is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# VenC is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with VenC. If not, see <http://www.gnu.org/licenses/>.
import datetime
import os
import shutil
import sys
import time
from . import CONTEXT
from . import ENVIRONMENT
from . import LOREM_IPSUM
from . import get_command_output
from . import set_python_version
PATH_TO_NIKOLA = os.path.expanduser("~")+"/.local/bin/nikola"
def init_nikola_blog():
set_python_version()
ENVIRONMENT["Nikola"] = get_command_output([PATH_TO_NIKOLA, "version"]).strip().replace("Nikola v", '')
from distutils.dir_util import copy_tree
copy_tree("nikola-benchmark-config", "nikola-benchmark")
shutil.os.mkdir("nikola-benchmark/posts")
def gen_nikola_entry():
ID = CONTEXT["ENTRY_ID_COUNTER"]
date = datetime.datetime.fromtimestamp(CONTEXT["DATETIME"])
entry = "---\n"
entry += "category: "+CONTEXT["SAMPLE_CATEGORIES"][CONTEXT["CATEGORY_INDEX"]]+'\n'
entry += "date: "+date.strftime("%Y-%m-%d %H:%M:%S")+'\n'
entry += "description: ''\n"
entry += "link: ''\n"
entry += "slug: benchmark-entry-"+str(ID)+'\n'
entry += "tags: ''\n"
entry += "title: benchmark entry "+str(ID)+'\n'
entry += "type: 'text'\n"
entry += "---\n"
entry += LOREM_IPSUM*CONTEXT["CONTENT_SIZE_MULTIPLIER"]
open("nikola-benchmark/posts/benchmark-entry-"+str(ID)+".md", 'w').write(entry)
def benchmark_nikola():
os.chdir("nikola-benchmark")
try:
shutil.rmtree("cache")
except FileNotFoundError:
pass
try:
os.remove(".doit.db")
except FileNotFoundError:
pass
start_timestamp = time.time()
output = get_command_output([PATH_TO_NIKOLA,"build"])
time_command = time.time() - start_timestamp
start_timestamp = time.time()
output = get_command_output([PATH_TO_NIKOLA,"build"])
time_cache = time.time() - start_timestamp
time_internal = None
os.chdir("..")
return {"time":time_command, "internal":time_internal, "time_cache":time_cache}
def clear_nikola_blog():
try:
shutil.rmtree("nikola-benchmark")
except FileNotFoundError:
pass
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment