rust-benchmark/benches/my_benchmark.rs
2024-02-11 12:59:38 +00:00

23 lines
761 B
Rust

use criterion::{black_box, criterion_group, criterion_main, Criterion};
use rust_benchmark::{concat_with_concat_string_macro_crate, concat_with_format, concat_with_plus};
const A: &str = "post";
const B: &str = "/fasjhiofasihofas";
pub fn criterion_benchmark(c: &mut Criterion) {
c.bench_function("concat with format", |b| {
b.iter(|| concat_with_format(black_box(A), black_box(B)));
});
c.bench_function("concat with plus", |b| {
b.iter(|| concat_with_plus(black_box(A), black_box(B)));
});
c.bench_function("concat with concat-string crate", |b| {
b.iter(|| concat_with_concat_string_macro_crate(black_box(A), black_box(B)));
});
}
criterion_group!(benches, criterion_benchmark);
criterion_main!(benches);