diff --git a/askama_derive_standalone/Cargo.toml b/askama_derive_standalone/Cargo.toml index 6bb5560c..90d619df 100644 --- a/askama_derive_standalone/Cargo.toml +++ b/askama_derive_standalone/Cargo.toml @@ -23,7 +23,7 @@ required-features = ["__standalone"] parser = { package = "askama_parser", version = "=0.13.0", path = "../askama_parser" } basic-toml = { version = "0.1.1", optional = true } -pulldown-cmark = { version = "0.12.0", optional = true, default-features = false } +pulldown-cmark = { version = "0.13.0", optional = true, default-features = false } serde = { version = "1.0", optional = true } serde_derive = { version = "1.0", optional = true } diff --git a/askama_derive_standalone/benches/derive-template.rs b/askama_derive_standalone/benches/derive-template.rs index b2795c85..28d12132 100644 --- a/askama_derive_standalone/benches/derive-template.rs +++ b/askama_derive_standalone/benches/derive-template.rs @@ -1,30 +1,37 @@ -use criterion::{BatchSize, Criterion, criterion_group, criterion_main}; +use criterion::{BatchSize, Criterion, Throughput, criterion_group, criterion_main}; use quote::quote; criterion_main!(benches); criterion_group!(benches, hello_world, librustdoc); fn hello_world(c: &mut Criterion) { + let source = "

Hello, {{user}}!

"; let ts = quote! { #[derive(Template)] #[template( - source = "

Hello, {{user}}!

", + source = #source, ext = "html" )] struct Hello<'a> { user: &'a str, } }; - c.bench_function("hello_world", |b| { + + let mut g = c.benchmark_group("synthetic"); + g.throughput(Throughput::Bytes(source.len().try_into().unwrap())); + g.bench_function("hello_world", |b| { b.iter_batched( || ts.clone(), askama_derive_standalone::derive_template, BatchSize::LargeInput, ); }); + g.finish(); } fn librustdoc(c: &mut Criterion) { + let mut g = c.benchmark_group("librustdoc"); + macro_rules! benches { ($($name:expr => $struct:item)*) => { $({ const SOURCE: &str = @@ -35,7 +42,8 @@ fn librustdoc(c: &mut Criterion) { #[template(source = #SOURCE, ext = "html")] $struct }; - c.bench_function($name, |b| { + g.throughput(Throughput::Bytes(SOURCE.len().try_into().unwrap())); + g.bench_function($name, |b| { b.iter_batched( || ts.clone(), askama_derive_standalone::derive_template, @@ -133,4 +141,5 @@ fn librustdoc(c: &mut Criterion) { size: u64, } } + g.finish(); }