diff options
| author | Max Audron <audron@cocaine.farm> | 2021-09-07 12:53:01 +0200 |
|---|---|---|
| committer | Max Audron <audron@cocaine.farm> | 2021-09-07 12:53:01 +0200 |
| commit | d69a7f9405444e86475f615f91ba6c924a293096 (patch) | |
| tree | f0434edb78d4954db9da5787397fdd514aa6c736 /src/hooks | |
| parent | handle error cases in sed module (diff) | |
put benchmark behind feature flag we can compile using stable rust
Diffstat (limited to '')
| -rw-r--r-- | src/hooks/sed.rs | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/src/hooks/sed.rs b/src/hooks/sed.rs index 8ae1a18..d46a9bf 100644 --- a/src/hooks/sed.rs +++ b/src/hooks/sed.rs @@ -83,9 +83,8 @@ impl Sed { #[cfg(test)] mod tests { use super::*; - use test::Bencher; - fn populate_log() -> Sed { + pub fn populate_log() -> Sed { let mut sed = Sed::new(); sed.log_msg( @@ -210,10 +209,16 @@ mod tests { "<user> this is a long message which be will replaced" ) } +} + +#[cfg(all(test, feature = "bench"))] +mod bench { + use super::*; + use test::Bencher; #[bench] fn bench_replace(b: &mut Bencher) { - let mut sed = populate_log(); + let mut sed = tests::populate_log(); b.iter(|| { sed.find_and_replace(&Message { tags: None, @@ -225,7 +230,7 @@ mod tests { #[bench] fn bench_replace_complex(b: &mut Bencher) { - let mut sed = populate_log(); + let mut sed = tests::populate_log(); b.iter(|| { sed.find_and_replace(&Message { tags: None, |
