From a1c9e88964cd99f2b7a23477f4b0c0f34d753d8b Mon Sep 17 00:00:00 2001 From: Ivan Matantsev Date: Thu, 25 Oct 2018 15:00:01 -0700 Subject: [PATCH 1/2] move regex out of function --- test/Microsoft.ML.TestFramework/BaseTestBaseline.cs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/test/Microsoft.ML.TestFramework/BaseTestBaseline.cs b/test/Microsoft.ML.TestFramework/BaseTestBaseline.cs index 4b14152011..e6b1dfcc2f 100644 --- a/test/Microsoft.ML.TestFramework/BaseTestBaseline.cs +++ b/test/Microsoft.ML.TestFramework/BaseTestBaseline.cs @@ -504,16 +504,17 @@ protected bool CheckEqualityFromPathsCore(string relPath, string basePath, strin } } + private static Regex MatchNumbers = new Regex(@"\b[0-9]+\.?[0-9]*(E-[0-9]*)?\b", RegexOptions.IgnoreCase | RegexOptions.Compiled); + private void GetNumbersFromFile(ref string firstString, ref string secondString, int digitsOfPrecision) { - Regex _matchNumer = new Regex(@"\b[0-9]+\.?[0-9]*(E-[0-9]*)?\b", RegexOptions.IgnoreCase | RegexOptions.Compiled); - MatchCollection firstCollection = _matchNumer.Matches(firstString); - MatchCollection secondCollection = _matchNumer.Matches(secondString); + MatchCollection firstCollection = MatchNumbers.Matches(firstString); + MatchCollection secondCollection = MatchNumbers.Matches(secondString); if (firstCollection.Count == secondCollection.Count) MatchNumberWithTolerance(firstCollection, secondCollection, digitsOfPrecision); - firstString = _matchNumer.Replace(firstString, "%Number%"); - secondString = _matchNumer.Replace(secondString, "%Number%"); + firstString = MatchNumbers.Replace(firstString, "%Number%"); + secondString = MatchNumbers.Replace(secondString, "%Number%"); } private void MatchNumberWithTolerance(MatchCollection firstCollection, MatchCollection secondCollection, int digitsOfPrecision) From 0bea87ad6fc6567f587384a139fb40dac023f340 Mon Sep 17 00:00:00 2001 From: Ivan Matantsev Date: Thu, 25 Oct 2018 15:20:41 -0700 Subject: [PATCH 2/2] right place, right attribute --- test/Microsoft.ML.TestFramework/BaseTestBaseline.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/test/Microsoft.ML.TestFramework/BaseTestBaseline.cs b/test/Microsoft.ML.TestFramework/BaseTestBaseline.cs index e6b1dfcc2f..eb3d37d0ac 100644 --- a/test/Microsoft.ML.TestFramework/BaseTestBaseline.cs +++ b/test/Microsoft.ML.TestFramework/BaseTestBaseline.cs @@ -59,6 +59,7 @@ protected BaseTestBaseline(ITestOutputHelper output) : base(output) private const string OutputRootUnixRegExp = @"\/[^\\\t ]+\/TestOutput" + @"\/[^\\\t ]+"; private static readonly string BinRegUnixExp = @"\/[^\\\t ]+\/bin\/" + Mode; private static readonly string Bin64RegUnixExp = @"\/[^\\\t ]+\/bin\/x64\/" + Mode; + private static readonly Regex MatchNumbers = new Regex(@"\b[0-9]+\.?[0-9]*(E-[0-9]*)?\b", RegexOptions.IgnoreCase | RegexOptions.Compiled); /// /// When the progress log is appended to the end of output (in test runs), this line precedes the progress log. @@ -504,8 +505,6 @@ protected bool CheckEqualityFromPathsCore(string relPath, string basePath, strin } } - private static Regex MatchNumbers = new Regex(@"\b[0-9]+\.?[0-9]*(E-[0-9]*)?\b", RegexOptions.IgnoreCase | RegexOptions.Compiled); - private void GetNumbersFromFile(ref string firstString, ref string secondString, int digitsOfPrecision) { MatchCollection firstCollection = MatchNumbers.Matches(firstString);