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

20 lines
566 B
Rust

use criterion::{black_box, criterion_group, criterion_main, Criterion};
use rust_benchmark::{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 plus", |b| {
b.iter(|| concat_with_plus(black_box(A), black_box(B)));
});
c.bench_function("concat with format", |b| {
b.iter(|| concat_with_format(black_box(A), black_box(B)));
});
}
criterion_group!(benches, criterion_benchmark);
criterion_main!(benches);