mirror of
https://github.com/askama-rs/askama.git
synced 2025-10-02 15:25:19 +00:00
derive: bench in batches
Cloning a TokenStream is not for free. This change lets criterion do the cloning outside of the measured time, and blackboxing is done by criterion, too. The benchmark runs ~10% faster, now.
This commit is contained in:
parent
62b891ffc3
commit
cf2419b1a9
@ -1,4 +1,4 @@
|
||||
use criterion::{black_box, criterion_group, criterion_main, Criterion};
|
||||
use criterion::{criterion_group, criterion_main, BatchSize, Criterion};
|
||||
use quote::quote;
|
||||
|
||||
criterion_main!(benches);
|
||||
@ -19,7 +19,9 @@ fn hello_world(b: &mut criterion::Bencher<'_>) {
|
||||
user: &'a str,
|
||||
}
|
||||
};
|
||||
b.iter(|| {
|
||||
rinja_derive_standalone::derive_template2(black_box(&ts).clone());
|
||||
})
|
||||
b.iter_batched(
|
||||
|| ts.clone(),
|
||||
|ts| rinja_derive_standalone::derive_template2(ts),
|
||||
BatchSize::LargeInput,
|
||||
);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user