Skip to content

rinja-rs/template-benchmark

Repository files navigation

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 pre-compiled
handlebars interpreted
horrorshow pre-compiled
markup pre-compiled
maud pre-compiled
minijinja interpreted
rinja pre-compiled
ructe pre-compiled
sailfish pre-compiled
tera interpreted
tinytemplate interpreted

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.

More information can be found in: https://rinja-rs.github.io/template-benchmark/.

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.