changeset 61:987e10c9e6fe

bench: Add super simple benchmark case
author Lewin Bormann <lbo@spheniscida.de>
date Fri, 30 Aug 2019 16:36:51 +0200
parents 197ee4af43af
children d761adfe9cdf
files benches/e2e.rs
diffstat 1 files changed, 20 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/benches/e2e.rs	Fri Aug 30 16:30:59 2019 +0200
+++ b/benches/e2e.rs	Fri Aug 30 16:36:51 2019 +0200
@@ -1,4 +1,3 @@
-
 #[macro_use]
 extern crate bencher;
 extern crate regex;
@@ -7,7 +6,11 @@
 
 fn bench_simple_re(b: &mut Bencher) {
     b.iter(|| {
-        assert!(rex::match_re_str("^(Hello)? [Ww]orld!?$", "Hello world").unwrap().0);
+        assert!(
+            rex::match_re_str("^(Hello)? [Ww]orld!?$", "Hello world")
+                .unwrap()
+                .0
+        );
     });
 }
 
@@ -18,6 +21,13 @@
     });
 }
 
+fn bench_simplest_precompile(b: &mut Bencher) {
+    let re = rex::compile("^Hello world$").unwrap();
+    b.iter(|| {
+        assert!(rex::match_re(&re, "Hello world").0);
+    });
+}
+
 fn bench_notorious(b: &mut Bencher) {
     let re = rex::compile("(x+x+)+y").unwrap();
     b.iter(|| {
@@ -32,5 +42,12 @@
     });
 }
 
-benchmark_group!(benchs, bench_simple_re, bench_simple_precompile, bench_notorious, bench_regex_crate);
+benchmark_group!(
+    benchs,
+    bench_simple_re,
+    bench_simple_precompile,
+    bench_notorious,
+    bench_regex_crate,
+    bench_simplest_precompile
+);
 benchmark_main!(benchs);