From 07b04c19152157a38510f30ebdd1b8dceb5c07ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Kijewski?= Date: Thu, 15 Aug 2024 01:23:35 +0200 Subject: [PATCH] Split interpreted and compiled engines --- Cargo.toml | 4 +-- src/lib.rs | 76 +++++++++++++++++++++++++++++++++--------------------- 2 files changed, 48 insertions(+), 32 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 7091ac1..b4a7b8e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -28,8 +28,8 @@ compiled = ["askama", "horrorshow", "markup", "maud", "rinja", "ructe", "sailfis interpreted = ["handlebars", "minijinja", "tera", "tinytemplate"] askama = ["dep:askama", "_contains_compiled"] -handlebars = ["dep:handlebars", "_contains_compiled"] -horrorshow = ["dep:horrorshow", "_contains_interpreted"] +handlebars = ["dep:handlebars", "_contains_interpreted"] +horrorshow = ["dep:horrorshow", "_contains_compiled"] markup = ["dep:markup", "_contains_compiled"] maud = ["dep:maud", "_contains_compiled"] minijinja = ["dep:minijinja", "_contains_interpreted"] diff --git a/src/lib.rs b/src/lib.rs index b43f3ad..e32089a 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -20,36 +20,52 @@ macro_rules! for_each { }}; ($c:ident, $input:ident : $Input:ident, $func:ident) => {{ - let mut group = $c.benchmark_group(stringify!($func)); - - #[cfg(all(feature = "_contains_compiled", feature = "_contains_interpreted"))] - group.plot_config(criterion::PlotConfiguration::default() - .summary_scale(criterion::AxisScale::Logarithmic)); - - #[cfg(feature = "askama")] - for_each!(askama, group, $input:$Input, $func); - #[cfg(feature = "handlebars")] - for_each!(handlebars, group, $input:$Input, $func); - #[cfg(feature = "horrorshow")] - for_each!(horrorshow, group, $input:$Input, $func); - #[cfg(feature = "markup")] - for_each!(markup, group, $input:$Input, $func); - #[cfg(feature = "maud")] - for_each!(maud, group, $input:$Input, $func); - #[cfg(feature = "minijinja")] - for_each!(minijinja, group, $input:$Input, $func); - #[cfg(feature = "rinja")] - for_each!(rinja, group, $input:$Input, $func); - #[cfg(feature = "ructe")] - for_each!(ructe, group, $input:$Input, $func); - #[cfg(feature = "sailfish")] - for_each!(sailfish, group, $input:$Input, $func); - #[cfg(feature = "tera")] - for_each!(tera, group, $input:$Input, $func); - #[cfg(feature = "tinytemplate")] - for_each!(tinytemplate, group, $input:$Input, $func); - - group.finish(); + #[cfg(feature = "_contains_compiled")] + let _ = { + #[cfg(not(feature = "_contains_interpreted"))] + const NAME: &str = stringify!($func); + #[cfg(feature = "_contains_interpreted")] + const NAME: &str = concat!(stringify!($func), " (compiled)"); + + let mut group = $c.benchmark_group(NAME); + + #[cfg(feature = "askama")] + for_each!(askama, group, $input:$Input, $func); + #[cfg(feature = "horrorshow")] + for_each!(horrorshow, group, $input:$Input, $func); + #[cfg(feature = "markup")] + for_each!(markup, group, $input:$Input, $func); + #[cfg(feature = "maud")] + for_each!(maud, group, $input:$Input, $func); + #[cfg(feature = "rinja")] + for_each!(rinja, group, $input:$Input, $func); + #[cfg(feature = "ructe")] + for_each!(ructe, group, $input:$Input, $func); + #[cfg(feature = "sailfish")] + for_each!(sailfish, group, $input:$Input, $func); + + group.finish(); + }; + #[cfg(feature = "_contains_interpreted")] + let _ = { + #[cfg(not(feature = "_contains_compiled"))] + const NAME: &str = stringify!($func); + #[cfg(feature = "_contains_compiled")] + const NAME: &str = concat!(stringify!($func), " (interpreted)"); + + let mut group = $c.benchmark_group(NAME); + + #[cfg(feature = "handlebars")] + for_each!(handlebars, group, $input:$Input, $func); + #[cfg(feature = "minijinja")] + for_each!(minijinja, group, $input:$Input, $func); + #[cfg(feature = "tera")] + for_each!(tera, group, $input:$Input, $func); + #[cfg(feature = "tinytemplate")] + for_each!(tinytemplate, group, $input:$Input, $func); + + group.finish(); + }; }}; }