Skip to content

Commit

Permalink
Add tr_with_args (many-dynamic) and format! (many) benchmarks
Browse files Browse the repository at this point in the history
  • Loading branch information
varphone committed Jan 20, 2024
1 parent 0ab5a22 commit c927971
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions benches/bench.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "[email protected]",
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 = "[email protected]",
city = "Litteltown",
zip = 8408,
website = "https://snoopy-napkin.name"
);
})
});
}

criterion_group!(benches, bench_t);
Expand Down

0 comments on commit c927971

Please sign in to comment.