# HG changeset patch
# User Raphaël Gomès <rgomes@octobus.net>
# Date 2020-05-07 08:10:13
# Node ID 83c97c0bd31904b7d32a404ff1a7fcc249940b8f
# Parent  cfe86fbc722e490a87fd0181e77619246bea9e7f

rust-matchers: add timing tracing to regex compilation

This might be useful to diagnose later performance issues or just to show
the difference between engines.

Differential Revision: https://phab.mercurial-scm.org/D8498

diff --git a/rust/hg-core/src/matchers.rs b/rust/hg-core/src/matchers.rs
--- a/rust/hg-core/src/matchers.rs
+++ b/rust/hg-core/src/matchers.rs
@@ -31,6 +31,8 @@ use std::iter::FromIterator;
 use std::ops::Deref;
 use std::path::{Path, PathBuf};
 
+use micro_timer::timed;
+
 #[derive(Debug, PartialEq)]
 pub enum VisitChildrenSet<'a> {
     /// Don't visit anything
@@ -322,6 +324,7 @@ impl<'a> Matcher for IncludeMatcher<'a> 
 ///
 /// This can fail when the pattern is invalid or not supported by the
 /// underlying engine `Re2`, for instance anything with back-references.
+#[timed]
 fn re_matcher(
     pattern: &[u8],
 ) -> PatternResult<impl Fn(&HgPath) -> bool + Sync> {
@@ -337,6 +340,7 @@ fn re_matcher(
 /// This can fail when the pattern is invalid or not supported by the
 /// underlying engine (the `regex` crate), for instance anything with
 /// back-references.
+#[timed]
 fn re_matcher(
     pattern: &[u8],
 ) -> PatternResult<impl Fn(&HgPath) -> bool + Sync> {