From c927971323f76dd08fd7219403e6255fdaa27ed8 Mon Sep 17 00:00:00 2001 From: Varphone Wong Date: Sat, 20 Jan 2024 22:27:58 +0800 Subject: [PATCH] Add tr_with_args (many-dynamic) and format! (many) benchmarks --- benches/bench.rs | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/benches/bench.rs b/benches/bench.rs index c85f80b..ac10f03 100644 --- a/benches/bench.rs +++ b/benches/bench.rs @@ -144,6 +144,43 @@ fn bench_t(c: &mut Criterion) { ) }) }); + + c.bench_function("tr_with_args (many-dynamic)", |b| { + let msg = + r#"Hello %{name} %{surname}, your account id is %{id}, email address is %{email}. + You live in %{city} %{zip}. + Your website is %{website}."# + .to_string(); + b.iter(|| { + tr!( + &msg, + id = 123, + name = "Marion", + surname = "Christiansen", + email = "Marion_Christiansen83@hotmail.com", + city = "Litteltown", + zip = 8408, + website = "https://snoopy-napkin.name" + ) + }) + }); + + c.bench_function("format! (many)", |b| { + b.iter(|| { + format!( + r#"Hello {name} %{surname}, your account id is {id}, email address is {email}. + You live in {city} {zip}. + Your website is {website}."#, + id = 123, + name = "Marion", + surname = "Christiansen", + email = "Marion_Christiansen83@hotmail.com", + city = "Litteltown", + zip = 8408, + website = "https://snoopy-napkin.name" + ); + }) + }); } criterion_group!(benches, bench_t);