Skip to content

Commit d59f39f

Browse files
committed
Add borrowed variant of quick-xml to compare benchmark
quick-xml was benchmarked in buffered mode which a bit unfair
1 parent 93e1731 commit d59f39f

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

compare/benches/bench.rs

+21-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,27 @@ fn low_level_comparison(c: &mut Criterion) {
5454

5555
group.throughput(Throughput::Bytes(data.len() as u64));
5656
group.bench_with_input(
57-
BenchmarkId::new("quick_xml", filename),
57+
BenchmarkId::new("quick_xml:borrowed", filename),
58+
*data,
59+
|b, input| {
60+
b.iter(|| {
61+
let mut reader = Reader::from_str(input);
62+
reader.config_mut().check_end_names = false;
63+
let mut count = criterion::black_box(0);
64+
loop {
65+
match reader.read_event() {
66+
Ok(Event::Start(_)) | Ok(Event::Empty(_)) => count += 1,
67+
Ok(Event::Eof) => break,
68+
_ => (),
69+
}
70+
}
71+
assert_eq!(count, total_tags, "Overall tag count in {}", filename);
72+
})
73+
},
74+
);
75+
76+
group.bench_with_input(
77+
BenchmarkId::new("quick_xml:buffered", filename),
5878
*data,
5979
|b, input| {
6080
b.iter(|| {

0 commit comments

Comments
 (0)