Skip to content

Commit

Permalink
Add borrowed variant of quick-xml to compare benchmark
Browse files Browse the repository at this point in the history
quick-xml was benchmarked in buffered mode which a bit unfair
  • Loading branch information
Mingun committed Dec 1, 2023
1 parent 93e1731 commit d59f39f
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion compare/benches/bench.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,27 @@ fn low_level_comparison(c: &mut Criterion) {

group.throughput(Throughput::Bytes(data.len() as u64));
group.bench_with_input(
BenchmarkId::new("quick_xml", filename),
BenchmarkId::new("quick_xml:borrowed", filename),
*data,
|b, input| {
b.iter(|| {
let mut reader = Reader::from_str(input);
reader.config_mut().check_end_names = false;
let mut count = criterion::black_box(0);
loop {
match reader.read_event() {
Ok(Event::Start(_)) | Ok(Event::Empty(_)) => count += 1,
Ok(Event::Eof) => break,
_ => (),
}
}
assert_eq!(count, total_tags, "Overall tag count in {}", filename);
})
},
);

group.bench_with_input(
BenchmarkId::new("quick_xml:buffered", filename),
*data,
|b, input| {
b.iter(|| {
Expand Down

0 comments on commit d59f39f

Please sign in to comment.