Skip to content

Commit

Permalink
Split interpreted and compiled engines
Browse files Browse the repository at this point in the history
  • Loading branch information
Kijewski committed Aug 14, 2024
1 parent e6d1ccc commit 07b04c1
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 32 deletions.
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down
76 changes: 46 additions & 30 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
};
}};
}

Expand Down

0 comments on commit 07b04c1

Please sign in to comment.