-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
new: configuration options to ignore and hide fields
- Loading branch information
Showing
10 changed files
with
225 additions
and
48 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
// std imports | ||
use std::alloc::System; | ||
|
||
// third-party imports | ||
use criterion::{criterion_group, criterion_main, Criterion}; | ||
use regex::Regex; | ||
use stats_alloc::{Region, StatsAlloc, INSTRUMENTED_SYSTEM}; | ||
|
||
#[global_allocator] | ||
static GLOBAL: &StatsAlloc<System> = &INSTRUMENTED_SYSTEM; | ||
|
||
fn criterion_benchmark(c: &mut Criterion) { | ||
let re = Regex::new(r"^_").unwrap(); | ||
|
||
let mut c1 = None; | ||
let mut n1 = 0; | ||
c.bench_function("regex-short-match", |b| { | ||
let reg = Region::new(&GLOBAL); | ||
b.iter(|| { | ||
assert_eq!(re.is_match("_TEST"), true); | ||
n1 += 1; | ||
}); | ||
c1 = Some(reg.change()); | ||
}); | ||
println!("allocations at 1 ({:?} iterations): {:#?}", n1, c1); | ||
|
||
let mut c2 = None; | ||
let mut n2 = 0; | ||
c.bench_function("regex-long-match", |b| { | ||
let reg = Region::new(&GLOBAL); | ||
b.iter(|| { | ||
assert_eq!(re.is_match("_TEST_SOME_VERY_VERY_LONG_NAME"), true); | ||
n2 += 1; | ||
}); | ||
c2 = Some(reg.change()); | ||
}); | ||
println!("allocations at 2 ({:?} iterations): {:#?}", n2, c2); | ||
|
||
c.bench_function("regex-short-non-match", |b| { | ||
b.iter(|| { | ||
assert_eq!(re.is_match("TEST"), false); | ||
}); | ||
}); | ||
c.bench_function("regex-long-non-match", |b| { | ||
b.iter(|| { | ||
assert_eq!(re.is_match("TEST_SOME_VERY_VERY_LONG_NAME"), false); | ||
}); | ||
}); | ||
} | ||
|
||
criterion_group!(benches, criterion_benchmark); | ||
criterion_main!(benches); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
// std imports | ||
use std::alloc::System; | ||
|
||
// third-party imports | ||
use criterion::{criterion_group, criterion_main, Criterion}; | ||
use stats_alloc::{Region, StatsAlloc, INSTRUMENTED_SYSTEM}; | ||
use wildmatch::WildMatch; | ||
|
||
#[global_allocator] | ||
static GLOBAL: &StatsAlloc<System> = &INSTRUMENTED_SYSTEM; | ||
|
||
fn criterion_benchmark(c: &mut Criterion) { | ||
let pattern = WildMatch::new(r"_*"); | ||
let prefix = String::from("_"); | ||
|
||
let mut c1 = None; | ||
let mut n1 = 0; | ||
c.bench_function("wild-short-match", |b| { | ||
let reg = Region::new(&GLOBAL); | ||
b.iter(|| { | ||
assert_eq!(pattern.matches("_TEST"), true); | ||
n1 += 1; | ||
}); | ||
c1 = Some(reg.change()); | ||
}); | ||
println!("allocations at 1 ({:?} iterations): {:#?}", n1, c1); | ||
|
||
let mut c2 = None; | ||
let mut n2 = 0; | ||
c.bench_function("wild-long-match", |b| { | ||
let reg = Region::new(&GLOBAL); | ||
b.iter(|| { | ||
assert_eq!(pattern.matches("_TEST_SOME_VERY_VERY_LONG_NAME"), true); | ||
n2 += 1; | ||
}); | ||
c2 = Some(reg.change()); | ||
}); | ||
println!("allocations at 2 ({:?} iterations): {:#?}", n2, c2); | ||
|
||
c.bench_function("wild-short-non-match", |b| { | ||
b.iter(|| { | ||
assert_eq!(pattern.matches("TEST"), false); | ||
}); | ||
}); | ||
c.bench_function("wild-long-non-match", |b| { | ||
b.iter(|| { | ||
assert_eq!(pattern.matches("TEST_SOME_VERY_VERY_LONG_NAME"), false); | ||
}); | ||
}); | ||
c.bench_function("compare-short-match", |b| { | ||
let what = String::from("_TEST"); | ||
b.iter(|| { | ||
assert_eq!(what.starts_with(&prefix), true); | ||
}); | ||
}); | ||
c.bench_function("compare-long-match", |b| { | ||
let what = String::from("_TEST_SOME_VERY_VERY_LONG_NAME"); | ||
b.iter(|| { | ||
assert_eq!(what.starts_with(&prefix), true); | ||
}); | ||
}); | ||
c.bench_function("compare-short-non-match", |b| { | ||
let what = String::from("TEST"); | ||
b.iter(|| { | ||
assert_eq!(what.starts_with(&prefix), false); | ||
}); | ||
}); | ||
c.bench_function("compare-long-non-match", |b| { | ||
let what = String::from("TEST_SOME_VERY_VERY_LONG_NAME"); | ||
b.iter(|| { | ||
assert_eq!(what.starts_with(&prefix), false); | ||
}); | ||
}); | ||
} | ||
|
||
criterion_group!(benches, criterion_benchmark); | ||
criterion_main!(benches); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.