Performance
Rendering Performance
When rendering a rinja template, you should prefer the methods
.render()(to render the content into a new string),.render_into()(to render the content into anfmt::Writeobject, e.g.String) or.write_into()(to render the content into anio::Writeobject, e.g.Vec<u8>)
over .to_string() or format!().
While .to_string() and format!() give you the same result, they generally perform much worse
than rinja's own methods, because fmt::Write uses dynamic methods calls instead of
monomorphised code. On average, expect .to_string() to be 100% to 200% slower than .render().
Slow Debug Recompilations
If you experience slow compile times when iterating with lots of templates, you can compile Rinja's derive macros with a higher optimization level. This can speed up recompilation times dramatically.
Add the following to Cargo.toml or .cargo/config.toml:
#![allow(unused)] fn main() { [profile.dev.package.rinja_derive] opt-level = 3 }
This may affect clean compile times in debug mode, but incremental compiles will be faster.