Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ memchr = "2.1"
# required, `dev-dependencies` are not used). `criterion` 0.6 has msrv = 1.80, so
# we cannot check minimal versions with it. We allow to use `criterion` 0.4 for that
# See https://github.com/rust-lang/cargo/issues/10958
criterion = ">=0.4,<0.8"
criterion = ">=0.4,<0.9"
pretty_assertions = "1.4"
regex = "1"
# https://github.com/serde-rs/serde/issues/1904 is fixed since 1.0.206
Expand All @@ -47,6 +47,11 @@ tokio-test = "0.4"
[lib]
bench = false

[profile.bench]
# For better information from cargo flamegraph
debug = true
lto = true

[[bench]]
name = "microbenches"
harness = false
Expand Down
8 changes: 7 additions & 1 deletion compare/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dev-dependencies]
criterion = { version = "0.7", features = ["html_reports"] }
criterion = { version = "0.8", features = ["html_reports"] }
markup5ever = "0.36"
# maybe_xml 0.11 regressed performance by x2, and because this was the fastest
# XML parser, we keep benchmarking version 0.10 as well
Expand All @@ -17,6 +17,7 @@ maybe_xml = "0.11"
quick-xml = { path = "..", features = ["serialize"] }
rapid-xml = "0.2"
rusty_xml = { version = "0.3", package = "RustyXML" }
rxml = "0.13"
serde-xml-rs = "0.8"
xml_oxide = "0.3"
xml-rs = "1.0"
Expand All @@ -35,3 +36,8 @@ harness = false
[[bench]]
name = "serde"
harness = false

[profile.bench]
# For better information from cargo flamegraph
debug = true
lto = true
36 changes: 36 additions & 0 deletions compare/benches/low-level.rs
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,42 @@ fn low_level_comparison(c: &mut Criterion) {
},
);

group.bench_with_input(BenchmarkId::new("rxml:borrowed", filename), *data, |b, input| {
use rxml::{Event, Parser, Parse};

b.iter(|| {
let mut doc = input.as_bytes();
let mut p = Parser::new();
let mut count = black_box(0);
while doc.len() > 0 {
// true = doc contains the entire document
match p.parse(&mut doc, true).unwrap() {
Some(Event::StartElement(..)) => count += 1,
None => break,
_ => (),
}
}
assert_eq!(count, total_tags, "Overall tag count in {}", filename);
})
});

group.bench_with_input(BenchmarkId::new("rxml:buffered", filename), *data, |b, input| {
use rxml::{as_eof_flag, Event, Reader};
use std::io::BufReader;

b.iter(|| {
let reader = BufReader::new(input.as_bytes());
let mut reader = Reader::new(reader);
let mut count = black_box(0);
let result = as_eof_flag(reader.read_all(|event| match event {
Event::StartElement(..) => count += 1,
_ => (),
}));
assert_eq!(result.unwrap(), true); // true indicates eof
assert_eq!(count, total_tags, "Overall tag count in {}", filename);
})
});

group.bench_with_input(BenchmarkId::new("RustyXml", filename), *data, |b, input| {
use rusty_xml::{Event, Parser};

Expand Down