Skip to content

Commit

Permalink
test: support cargo bench
Browse files Browse the repository at this point in the history
  • Loading branch information
xusd320 committed Jul 16, 2024
1 parent ffd5763 commit d448586
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
2 changes: 2 additions & 0 deletions rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[toolchain]
channel = "nightly-2024-07-16"
16 changes: 16 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
#![feature(test)]

#[macro_use]
extern crate napi_derive;

extern crate test;

use kuchikiki::{parse_html, traits::*};
use node_repr::NodeRepr;

Expand All @@ -16,3 +20,15 @@ pub fn parse(html: String) -> NodeRepr {
node_ref: document_node,
}
}

#[cfg(test)]
mod tests {
use super::parse;
use test::Bencher;

#[bench]
fn bench_parse(b: &mut Bencher) {
let html = include_str!("../test/jquery.html").to_string();
b.iter(|| parse(html.clone()));
}
}

0 comments on commit d448586

Please sign in to comment.