Skip to content

Commit

Permalink
Add maybe_xml to comparison
Browse files Browse the repository at this point in the history
It is number 264 (at time of commit) in "Parser implementations" topic
without usages according to https://lib.rs/crates/maybe_xml
  • Loading branch information
Mingun committed May 21, 2022
1 parent 53d292b commit dda8879
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
1 change: 1 addition & 0 deletions compare/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ edition = "2018"

[dev-dependencies]
criterion = "0.3"
maybe_xml = "0.2"
quick-xml = { path = "..", features = ["serialize"] }
rapid-xml = "0.2"
xml_oxide = "0.3"
Expand Down
24 changes: 24 additions & 0 deletions compare/benches/bench.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,30 @@ fn low_level_comparison(c: &mut Criterion) {
})
});

group.bench_function("maybe_xml", |b| {
use maybe_xml::eval::recv::RecvEvaluator;
use maybe_xml::token::borrowed::Token;

b.iter(|| {
let mut input = SOURCE.as_bytes();
let mut eval = RecvEvaluator::new();

let mut count = criterion::black_box(0);
loop {
let consumed = eval.recv(input);
match eval.next_token() {
Ok(Some(Token::StartTag(_))) => count += 1,
Ok(Some(Token::EmptyElementTag(_))) => count += 1,
Ok(Some(Token::Eof)) => break,
Ok(Some(Token::EofWithBytesNotEvaluated(_))) => break,
_ => (),
}
input = &input[consumed..];
}
assert_eq!(count, 1550, "Overall tag count in ./tests/sample_rss.xml");
})
});

group.bench_function("rapid-xml", |b| {
use rapid_xml::parser::{EventCode, Parser};

Expand Down

0 comments on commit dda8879

Please sign in to comment.