diff --git a/benches/bench.rs b/benches/bench.rs index 94c0899..259e33e 100644 --- a/benches/bench.rs +++ b/benches/bench.rs @@ -10,6 +10,11 @@ fn simple_match(c: &mut Criterion) { b.iter(|| assert!(glob::Pattern::new(GLOB).unwrap().matches(PATH))) }); + group.bench_function("glob-pre-compiled", |b| { + let matcher = glob::Pattern::new(GLOB).unwrap(); + b.iter(|| assert!(matcher.matches(PATH))) + }); + group.bench_function("globset", |b| { b.iter(|| { assert!(globset::Glob::new(GLOB) @@ -19,6 +24,11 @@ fn simple_match(c: &mut Criterion) { }) }); + group.bench_function("globset-pre-compiled", |b| { + let matcher = globset::Glob::new(GLOB).unwrap().compile_matcher(); + b.iter(|| assert!(matcher.is_match(PATH))) + }); + group.bench_function("glob-match", |b| { b.iter(|| assert!(glob_match::glob_match(GLOB, PATH))) }); @@ -45,6 +55,11 @@ fn brace_expansion(c: &mut Criterion) { }) }); + group.bench_function("globset-pre-compiled", |b| { + let matcher = globset::Glob::new(GLOB).unwrap().compile_matcher(); + b.iter(|| assert!(matcher.is_match(PATH))) + }); + group.bench_function("glob-match", |b| { b.iter(|| assert!(glob_match::glob_match(GLOB, PATH))) });