20 lines
566 B
Rust
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 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)));
|
|
});
|
|
}
|
|
|
|
criterion_group!(benches, criterion_benchmark);
|
|
criterion_main!(benches);
|
|
|