From a054c6e973c70df28d7033f60b8f04a90beed8ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Kijewski?= Date: Thu, 15 Aug 2024 06:29:00 +0200 Subject: [PATCH] Add README --- README.md | 148 +++++++++++++++++++++++++++++++++++++++++ generate-table.py | 6 +- tmpls/rinja/Cargo.toml | 2 +- 3 files changed, 154 insertions(+), 2 deletions(-) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..34d76f6 --- /dev/null +++ b/README.md @@ -0,0 +1,148 @@ +# Rust Template Benchmark + +This benchmark tries to compare different template engines in Rust. +We consider both precompiled and dynamic engines, which of course have wildly different runtime +performances. + +**Beware:** One engine might be faster than the other. +But if the other engine is more ergonomical to work with, +e.g. because you have no re-compilation times, then it might still be the better fit for you. +Only you can decide which characteristics of a template engine +(runtime speed, simplicity of programming, …) are important to you. + +Currently, we compare eleven different template engines. +All of them are well maintained, mature and perform HTML escaping automatically. + +| Crate | Docs | Repo | Code | Recent
Downloads | Github
Stars | Contrib-
utors | Recent
Commits | +| -------------- | ----------------------------------------------- | ------------------- | -------------| ------------------------------------ | -------------------------------------------- | -------------------------------------------- | ------------------------------------------ | +| [askama] | [![][docs-img-askama]][docs-askama] | [![][img-repo]][repo-askama] | pre-compiled | [![][dl-askama]][askama] | [![][stars-askama]][repo-askama] | [![][contr-askama]][repo-askama] | [![][act-askama]][repo-askama] | +| [handlebars] | [![][docs-img-handlebars]][docs-handlebars] | [![][img-repo]][repo-handlebars] | interpreted | [![][dl-handlebars]][handlebars] | [![][stars-handlebars]][repo-handlebars] | [![][contr-handlebars]][repo-handlebars] | [![][act-handlebars]][repo-handlebars] | +| [horrorshow] | [![][docs-img-horrorshow]][docs-horrorshow] | [![][img-repo]][repo-horrorshow] | pre-compiled | [![][dl-horrorshow]][horrorshow] | [![][stars-horrorshow]][repo-horrorshow] | [![][contr-horrorshow]][repo-horrorshow] | [![][act-horrorshow]][repo-horrorshow] | +| [markup] | [![][docs-img-markup]][docs-markup] | [![][img-repo]][repo-markup] | pre-compiled | [![][dl-markup]][markup] | [![][stars-markup]][repo-markup] | [![][contr-markup]][repo-markup] | [![][act-markup]][repo-markup] | +| [maud] | [![][docs-img-maud]][docs-maud] | [![][img-repo]][repo-maud] | pre-compiled | [![][dl-maud]][maud] | [![][stars-maud]][repo-maud] | [![][contr-maud]][repo-maud] | [![][act-maud]][repo-maud] | +| [minijinja] | [![][docs-img-minijinja]][docs-minijinja] | [![][img-repo]][repo-minijinja] | interpreted | [![][dl-minijinja]][minijinja] | [![][stars-minijinja]][repo-minijinja] | [![][contr-minijinja]][repo-minijinja] | [![][act-minijinja]][repo-minijinja] | +| [rinja] | [![][docs-img-rinja]][docs-rinja] | [![][img-repo]][repo-rinja] | pre-compiled | [![][dl-rinja]][rinja] | [![][stars-rinja]][repo-rinja] | [![][contr-rinja]][repo-rinja] | [![][act-rinja]][repo-rinja] | +| [ructe] | [![][docs-img-ructe]][docs-ructe] | [![][img-repo]][repo-ructe] | pre-compiled | [![][dl-ructe]][ructe] | [![][stars-ructe]][repo-ructe] | [![][contr-ructe]][repo-ructe] | [![][act-ructe]][repo-ructe] | +| [sailfish] | [![][docs-img-sailfish]][docs-sailfish] | [![][img-repo]][repo-sailfish] | pre-compiled | [![][dl-sailfish]][sailfish] | [![][stars-sailfish]][repo-sailfish] | [![][contr-sailfish]][repo-sailfish] | [![][act-sailfish]][repo-sailfish] | +| [tera] | [![][docs-img-tera]][docs-tera] | [![][img-repo]][repo-tera] | interpreted | [![][dl-tera]][tera] | [![][stars-tera]][repo-tera] | [![][contr-tera]][repo-tera] | [![][act-tera]][repo-tera] | +| [tinytemplate] | [![][docs-img-tinytemplate]][docs-tinytemplate] | [![][img-repo]][repo-tinytemplate] | interpreted | [![][dl-tinytemplate]][tinytemplate] | [![][stars-tinytemplate]][repo-tinytemplate] | [![][contr-tinytemplate]][repo-tinytemplate] | [![][act-tinytemplate]][repo-tinytemplate] | + +Please see also [*Rust web framework comparison*]. + +## Benchmark Results + +The benchmarking was done on Github's action runners, on an AMD-64 Linux system. +The absolute performance can vary, but the relative performance of crate *X* to *Y* should be stable. + +[![](https://kijewski.github.io/template-benchmark/results.svg)](https://kijewski.github.io/template-benchmark/) + +More information can be found in: . + +The "big table" benchmark generates a 100×100 cell HTML table. +The "teams" benchmark contains a list of four sport teams and their scores. +The former test contains only raw data, but a lot of it. +The latter test includes texts that (might) need escaping, and "if" conditions. + +To run the benchmarks on your machine, clone the repo, and execute `cargo benchmark`. +The console will contain performance numbers, +and the file `target/criterion/report/index.html` will contain more information. +Run `./generate-table.py` to generate the table you see above. + +[*Rust web framework comparison*]: +[img-repo]: + +[askama]: +[handlebars]: +[horrorshow]: +[markup]: +[maud]: +[minijinja]: +[rinja]: +[ructe]: +[sailfish]: +[tera]: +[tinytemplate]: + +[docs-askama]: +[docs-handlebars]: +[docs-horrorshow]: +[docs-markup]: +[docs-maud]: +[docs-minijinja]: +[docs-rinja]: +[docs-ructe]: +[docs-sailfish]: +[docs-tera]: +[docs-tinytemplate]: + +[docs-img-askama]: +[docs-img-handlebars]: +[docs-img-horrorshow]: +[docs-img-markup]: +[docs-img-maud]: +[docs-img-minijinja]: +[docs-img-rinja]: +[docs-img-ructe]: +[docs-img-sailfish]: +[docs-img-tera]: +[docs-img-tinytemplate]: + +[dl-askama]: +[dl-handlebars]: +[dl-horrorshow]: +[dl-markup]: +[dl-maud]: +[dl-minijinja]: +[dl-rinja]: +[dl-ructe]: +[dl-sailfish]: +[dl-tera]: +[dl-tinytemplate]: + +[stars-askama]: +[stars-handlebars]: +[stars-horrorshow]: +[stars-markup]: +[stars-maud]: +[stars-minijinja]: +[stars-rinja]: +[stars-ructe]: +[stars-sailfish]: +[stars-tera]: +[stars-tinytemplate]: + +[contr-askama]: +[contr-handlebars]: +[contr-horrorshow]: +[contr-markup]: +[contr-maud]: +[contr-minijinja]: +[contr-rinja]: +[contr-ructe]: +[contr-sailfish]: +[contr-tera]: +[contr-tinytemplate]: + +[act-askama]: +[act-handlebars]: +[act-horrorshow]: +[act-markup]: +[act-maud]: +[act-minijinja]: +[act-rinja]: +[act-ructe]: +[act-sailfish]: +[act-tera]: +[act-tinytemplate]: + +[repo-askama]: +[repo-handlebars]: +[repo-horrorshow]: +[repo-markup]: +[repo-maud]: +[repo-minijinja]: +[repo-rinja]: +[repo-ructe]: +[repo-sailfish]: +[repo-tera]: +[repo-tinytemplate]: diff --git a/generate-table.py b/generate-table.py index fd6a4ef..7a9ac25 100755 --- a/generate-table.py +++ b/generate-table.py @@ -1,6 +1,7 @@ #!/usr/bin/env python3 from dataclasses import dataclass +from datetime import datetime, timezone from glob import glob from io import StringIO from json import load @@ -134,8 +135,11 @@ def main(root_dir: Path): print("", file=f) print("", file=f) print( - '', + '', + datetime.now(timezone.utc).isoformat().replace("T", " ").split(".")[0], + "", file=f, + sep="", ) print( 'median; lower is better', diff --git a/tmpls/rinja/Cargo.toml b/tmpls/rinja/Cargo.toml index 2ba320d..90789d7 100644 --- a/tmpls/rinja/Cargo.toml +++ b/tmpls/rinja/Cargo.toml @@ -8,4 +8,4 @@ license = "Apache-2.0" [dependencies] tmpls = { version = "*", path = ".." } -rinja = { version = "0.3.0", git = "https://github.com/rinja-rs/rinja", branch = "master" } +rinja = "0.3.0"