22
33namespace TestUtils ;
44
5- public static class OutputLogParser
5+ public static partial class OutputLogParser
66{
77 public static List < string > ParseLogSegments ( string log , out ( string duration , string maxMemoryUsed , string initDuration ) report )
88 {
99 var segments = new List < string > ( ) ;
10- var regex = new Regex (
11- @"(\{(?:[^{}]|(?<open>\{)|(?<-open>\}))*\}(?(open)(?!)))|(REPORT RequestId:.*?)(?=START RequestId:|\z)" ,
12- RegexOptions . Singleline ) ;
10+ var regex = ParseLogRegex ( ) ;
1311 var matches = regex . Matches ( log ) ;
1412 report = ( "N/A" , "N/A" , "N/A" ) ;
1513
@@ -30,9 +28,7 @@ public static List<string> ParseLogSegments(string log, out (string duration, st
3028
3129 public static ( string duration , string maxMemoryUsed , string initDuration ) ExtractReportMetrics ( string report )
3230 {
33- var regex = new Regex (
34- @"Duration: (?<duration>\d+\.\d+) ms.*?Max Memory Used: (?<maxMemory>\d+) MB(?:.*?Init Duration: (?<initDuration>\d+\.\d+) ms)?" ,
35- RegexOptions . Singleline ) ;
31+ var regex = ExtractMetricsRegex ( ) ;
3632 var match = regex . Match ( report ) ;
3733
3834 if ( ! match . Success ) return ( "N/A" , "N/A" , "N/A" ) ;
@@ -43,4 +39,9 @@ public static (string duration, string maxMemoryUsed, string initDuration) Extra
4339
4440 return ( duration , maxMemoryUsed , initDuration ) ;
4541 }
42+
43+ [ GeneratedRegex ( @"Duration: (?<duration>\d+\.\d+) ms.*?Max Memory Used: (?<maxMemory>\d+) MB(?:.*?Init Duration: (?<initDuration>\d+\.\d+) ms)?" , RegexOptions . Singleline ) ]
44+ private static partial Regex ExtractMetricsRegex ( ) ;
45+ [ GeneratedRegex ( @"(\{(?:[^{}]|(?<open>\{)|(?<-open>\}))*\}(?(open)(?!)))|(REPORT RequestId:.*?)(?=START RequestId:|\z)" , RegexOptions . Singleline ) ]
46+ private static partial Regex ParseLogRegex ( ) ;
4647}
0 commit comments