Skip to content

Commit 05d780f

Browse files
committed
feat: add can_parse to benchmarks
1 parent e46e848 commit 05d780f

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

bench/parse.rs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,5 +34,19 @@ pub fn parse_benchmark(c: &mut Criterion) {
3434
group.finish();
3535
}
3636

37-
criterion_group!(benches, parse_benchmark);
37+
pub fn can_parse_benchmark(c: &mut Criterion) {
38+
let mut group = c.benchmark_group("can_parse");
39+
group.throughput(Throughput::Bytes(URLS.iter().map(|u| u.len() as u64).sum()));
40+
group.bench_function("ada_url", |b| {
41+
b.iter(|| {
42+
URLS.iter().for_each(|url| {
43+
let _ = ada_url::Url::can_parse(*black_box(url), None);
44+
})
45+
})
46+
});
47+
// TODO: Add `url` crate when it supports can_parse function.
48+
group.finish();
49+
}
50+
51+
criterion_group!(benches, parse_benchmark, can_parse_benchmark);
3852
criterion_main!(benches);

0 commit comments

Comments
 (0)