diff options
author | Canop <cano.petrole@gmail.com> | 2021-03-21 21:20:40 +0100 |
---|---|---|
committer | Canop <cano.petrole@gmail.com> | 2021-03-21 21:20:40 +0100 |
commit | b95dc507280795e095626d401f1cc347e8e2a0c6 (patch) | |
tree | fca05f8c875546eb53d7c4a97146764c64930529 /benches | |
parent | ea193538fcc04a14070d3e1584bc9430c31ed729 (diff) |
add composite pattern évaluation to benches
Diffstat (limited to 'benches')
-rw-r--r-- | benches/composite.rs | 34 | ||||
-rw-r--r-- | benches/fuzzy.rs | 120 | ||||
-rw-r--r-- | benches/shared/mod.rs | 3 | ||||
-rw-r--r-- | benches/shared/names.rs | 115 |
4 files changed, 156 insertions, 116 deletions
diff --git a/benches/composite.rs b/benches/composite.rs new file mode 100644 index 0000000..5ae8f9f --- /dev/null +++ b/benches/composite.rs @@ -0,0 +1,34 @@ +mod shared; + +use { + broot::{ + command::CommandParts, + pattern::*, + }, + criterion::{black_box, criterion_group, criterion_main, Criterion}, +}; + +// this file benches composite patterns on file names so don't +// use file content sub patterns here +static PATTERNS: &[&str] = &[ + "r&!e", +]; + +fn score_of_composite_benchmark(c: &mut Criterion) { + let search_modes = SearchModeMap::default(); + for pattern in PATTERNS { + let task = format!("Pattern({:?})::score_of", &pattern); + let parts = CommandParts::from(pattern.to_string()); + c.bench_function(&task, |b| { + let cp = Pattern::new(&parts.pattern, &search_modes).unwrap(); + b.iter(|| { + for name in shared::NAMES { + black_box(cp.score_of_string(name)); + } + }); + }); + } +} + +criterion_group!(benches, score_of_composite_benchmark); +criterion_main!(benches); diff --git a/benches/fuzzy.rs b/benches/fuzzy.rs index 979c3bc..bfbd79d 100644 --- a/benches/fuzzy.rs +++ b/benches/fuzzy.rs @@ -1,124 +1,12 @@ +mod shared; + use { broot::pattern::FuzzyPattern, criterion::{black_box, criterion_group, criterion_main, Criterion}, + shared::*, }; static PATTERNS: &[&str] = &["réveil", "AB", "e", "brt", "brootz"]; -static NAMES: &[&str] = &[ - " brr ooT", - "Réveillon", - "dys", - "test", - " tetsesstteststt ", - "a rbrroot", - "Ab", - "test again", - "des réveils", - "pi", - "a quite longuer name", - "compliqué - 这个大象有多重", - "brrooT", - "1", - "another name.jpeg", - "aaaaaab", - "a ab abba aab", - "abcdrtodota", - "palimpsestes désordonnés", - "a", - "π", - "normal.dot", - "ùmeé9$njfbaù rz&é", - "FactoryFactoryFactoryFactory.java", - "leftPad.js", - "Cargo.toml", - "Cargo.lock", - "main.rs", - ".gitignore", - "lib.rs", - " un réveil", - "aaaaaaaaaaaaaaaaabbbbbbb", - "BABABC B AB", - "réveils", - "paem", - "poëme", - "mjrzemrjzm mrjz mrzr rb root", - "&cq", - "..a", - "~~~~~", - "ba", - "bar", - "bar ro ot", - "& aé &a é", - "mùrz*jfzùenfzeùrjmùe", - "krz", - "q", - "mjrfzm e", - "dystroy.org", - "www", - "termimad", - "minimad", - "regex", - "lazy_regex", - "jaquerie", - "Tillon", - "Tellini", - "Garo", - "Portequoi", - "Terdi", - "Ploplo", - "le dragon", - "l'ours", - "la tortue géante", - "le chamois", - "dystroy", - "bra ernre rjrz a e3 broorar/ e/ smallvec/memmap;r b oot4 Z", - "un petit peu n'importe quoi", - "dans", - "cette", - "liste", - "Broot", - " broot", - " broot ", - "b-root", - "biroute", - "Miaou", - "meow", - "et", - "surtout", - "La Grande Roulette", - "this list is", - "very obviously", - "tailored at stressing", - "the engine", - "and the reader", - "C++", - "javascript", - "SQL", - "C#", - "Haskell", - "Lisp", - "Pascal", - "and", - "Fortran", - "are just missing from this codebase", - "denys", - "seguret", - "is", - "the", - "author", - "bro o o o o o o o o o o o o ot", - "bro o o o o o o o o o o o o otz", - "br bro boo broot brootz", - "b b bb bb ca e 1234 oooot", - "Bo br BBBroo OOOOOt", - "kir ba lrbvr b rbaz broot", - "nrel ora hr rbooo t roo jrzz 7 tz", - "not matching anything, is it ?", - "ae/r/re /reee/ea", - "era", - "lrlb rre o", - "rjre nr", -]; fn score_of_benchmark(c: &mut Criterion) { for pattern in PATTERNS { @@ -126,7 +14,7 @@ fn score_of_benchmark(c: &mut Criterion) { c.bench_function(&task, |b| { let fp = FuzzyPattern::from(pattern); b.iter(|| { - for name in NAMES { + for name in shared::NAMES { black_box(fp.score_of(name)); } }); diff --git a/benches/shared/mod.rs b/benches/shared/mod.rs new file mode 100644 index 0000000..3d85602 --- /dev/null +++ b/benches/shared/mod.rs @@ -0,0 +1,3 @@ +mod names; + +pub use names::*; diff --git a/benches/shared/names.rs b/benches/shared/names.rs new file mode 100644 index 0000000..064422c --- /dev/null +++ b/benches/shared/names.rs @@ -0,0 +1,115 @@ +pub static NAMES: &[&str] = &[ + " brr ooT", + "Réveillon", + "dys", + "test", + " tetsesstteststt ", + "a rbrroot", + "Ab", + "test again", + "des réveils", + "pi", + "a quite longuer name", + "compliqué - 这个大象有多重", + "brrooT", + "1", + "another name.jpeg", + "aaaaaab", + "a ab abba aab", + "abcdrtodota", + "palimpsestes désordonnés", + "a", + "π", + "normal.dot", + "ùmeé9$njfbaù rz&é", + "FactoryFactoryFactoryFactory.java", + "leftPad.js", + "Cargo.toml", + "Cargo.lock", + "main.rs", + ".gitignore", + "lib.rs", + " un réveil", + "aaaaaaaaaaaaaaaaabbbbbbb", + "BABABC B AB", + "réveils", + "paem", + "poëme", + "mjrzemrjzm mrjz mrzr rb root", + "&cq", + "..a", + "~~~~~", + "ba", + "bar", + "bar ro ot", + "& aé &a é", + "mùrz*jfzùenfzeùrjmùe", + "krz", + "q", + "mjrfzm e", + "dystroy.org", + "www", + "termimad", + "minimad", + "regex", + "lazy_regex", + "jaquerie", + "Tillon", + "Tellini", + "Garo", + "Portequoi", + "Terdi", + "Ploplo", + "le dragon", + "l'ours", + "la tortue géante", + "le chamois", + "dystroy", + "bra ernre rjrz a e3 broorar/ e/ smallvec/memmap;r b oot4 Z", + "un petit peu n'importe quoi", + "dans", + "cette", + "liste", + "Broot", + " broot", + " broot ", + "b-root", + "biroute", + "Miaou", + "meow", + "et", + "surtout", + "La Grande Roulette", + "this list is", + "very obviously", + "tailored at stressing", + "the engine", + "and the reader", + "C++", + "javascript", + "SQL", + "C#", + "Haskell", + "Lisp", + "Pascal", + "and", + "Fortran", + "are just missing from this codebase", + "denys", + "seguret", + "is", + "the", + "author", + "bro o o o o o o o o o o o o ot", + "bro o o o o o o o o o o o o otz", + "br bro boo broot brootz", + "b b bb bb ca e 1234 oooot", + "Bo br BBBroo OOOOOt", + "kir ba lrbvr b rbaz broot", + "nrel ora hr rbooo t roo jrzz 7 tz", + "not matching anything, is it ?", + "ae/r/re /reee/ea", + "era", + "lrlb rre o", + "rjre nr", +]; |