Skip to content

Commit 099bf78

Browse files
committed
compare: Add benchmark for maybe_xml 0.11
Because maybe_xml 0.11 performance about x2 worse that maybe_xml 0.10, and because maybe_xml 0.10 is a leader, keep both versions
1 parent 5632256 commit 099bf78

File tree

2 files changed

+27
-2
lines changed

2 files changed

+27
-2
lines changed

compare/Cargo.toml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,10 @@ edition = "2021"
1010
[dev-dependencies]
1111
criterion = { version = "0.6", features = ["html_reports"] }
1212
markup5ever = "0.16"
13-
maybe_xml = "0.10.1"
13+
# maybe_xml 0.11 regressed perfomance by x2, and because this was the fastest
14+
# XML parser, we keep benchmarking version 0.10 as well
15+
maybe_xml_0_10 = { version = "0.10", package = "maybe_xml" }
16+
maybe_xml = "0.11"
1417
quick-xml = { path = "..", features = ["serialize"] }
1518
rapid-xml = "0.2"
1619
rusty_xml = { version = "0.3", package = "RustyXML" }

compare/benches/bench.rs

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,29 @@ fn low_level_comparison(c: &mut Criterion) {
9797
);
9898

9999
group.bench_with_input(
100-
BenchmarkId::new("maybe_xml", filename),
100+
BenchmarkId::new("maybe_xml:0.10", filename),
101+
*data,
102+
|b, input| {
103+
use maybe_xml_0_10::token::Ty;
104+
use maybe_xml_0_10::Reader;
105+
106+
b.iter(|| {
107+
let reader = Reader::from_str(input);
108+
109+
let mut count = black_box(0);
110+
for token in reader.into_iter() {
111+
match token.ty() {
112+
Ty::StartTag(_) | Ty::EmptyElementTag(_) => count += 1,
113+
_ => (),
114+
}
115+
}
116+
assert_eq!(count, total_tags, "Overall tag count in {}", filename);
117+
})
118+
},
119+
);
120+
121+
group.bench_with_input(
122+
BenchmarkId::new("maybe_xml:0.11", filename),
101123
*data,
102124
|b, input| {
103125
use maybe_xml::token::Ty;

0 commit comments

Comments
 (0)