Skip to content

Commit

Permalink
Fix warning, add simple benchmark
Browse files Browse the repository at this point in the history
  • Loading branch information
gulshan committed Mar 25, 2024
1 parent 2039b30 commit 03b42ef
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,4 @@ poriborton = "0.2"

[dev-dependencies]
rustversion = "1.0"
easybench = "1.1"
18 changes: 18 additions & 0 deletions src/utility.rs
Original file line number Diff line number Diff line change
Expand Up @@ -257,4 +257,22 @@ mod test {

assert_eq!(smart_quoter(SplittedString::split("\"'Quotation'\"", true)), ("“‘".into(), "Quotation", "’”".into()));
}

use easybench::bench;
#[test]
fn bench_query() {
let stats = bench(|| {
smart_quoter(SplittedString::split("\"", true));
smart_quoter(SplittedString::split("'Till", true));
smart_quoter(SplittedString::split("\"Hey", true));
smart_quoter(SplittedString::split("'\"Hey", true));
smart_quoter(SplittedString::split("finished'", true));
smart_quoter(SplittedString::split("Hey\"", true));
smart_quoter(SplittedString::split("Hey'\"", true));
smart_quoter(SplittedString::split("'Awkward'", true));
smart_quoter(SplittedString::split("\"Nevertheless\"", true));
smart_quoter(SplittedString::split("\"'Quotation'\"", true));
});
println!("smart_quoter benchmark: {}", stats);
}
}

0 comments on commit 03b42ef

Please sign in to comment.