Skip to content

Commit

Permalink
Merge pull request #668 from Mingun/compare
Browse files Browse the repository at this point in the history
Update maybe_xml dependency 0.3 -> 0.6
  • Loading branch information
Mingun committed Oct 17, 2023
2 parents 7fbe4bc + b9a0fa2 commit 27a93b3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 13 deletions.
2 changes: 1 addition & 1 deletion compare/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ edition = "2021"

[dev-dependencies]
criterion = { version = "0.5", features = ["html_reports"] }
maybe_xml = "0.3"
maybe_xml = "0.6"
quick-xml = { path = "..", features = ["serialize"] }
rapid-xml = "0.2"
rusty_xml = { version = "0.3", package = "RustyXML" }
Expand Down
18 changes: 6 additions & 12 deletions compare/benches/bench.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,24 +79,18 @@ fn low_level_comparison(c: &mut Criterion) {
BenchmarkId::new("maybe_xml", filename),
*data,
|b, input| {
use maybe_xml::eval::recv::Evaluator;
use maybe_xml::token::borrowed::Token;
use maybe_xml::Lexer;
use maybe_xml::token::Ty;

b.iter(|| {
let mut input = input.as_bytes();
let mut eval = Evaluator::new();
let lexer = Lexer::from_slice(input.as_bytes());

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,
for token in lexer.into_iter() {
match token.ty() {
Ty::StartTag(_) | Ty::EmptyElementTag(_) => count += 1,
_ => (),
}
input = &input[consumed..];
}
assert_eq!(count, total_tags, "Overall tag count in {}", filename);
})
Expand Down

0 comments on commit 27a93b3

Please sign in to comment.