2
2
3
3
namespace TestUtils ;
4
4
5
- public static class OutputLogParser
5
+ public static partial class OutputLogParser
6
6
{
7
7
public static List < string > ParseLogSegments ( string log , out ( string duration , string maxMemoryUsed , string initDuration ) report )
8
8
{
9
9
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 ( ) ;
13
11
var matches = regex . Matches ( log ) ;
14
12
report = ( "N/A" , "N/A" , "N/A" ) ;
15
13
@@ -30,9 +28,7 @@ public static List<string> ParseLogSegments(string log, out (string duration, st
30
28
31
29
public static ( string duration , string maxMemoryUsed , string initDuration ) ExtractReportMetrics ( string report )
32
30
{
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 ( ) ;
36
32
var match = regex . Match ( report ) ;
37
33
38
34
if ( ! match . Success ) return ( "N/A" , "N/A" , "N/A" ) ;
@@ -43,4 +39,9 @@ public static (string duration, string maxMemoryUsed, string initDuration) Extra
43
39
44
40
return ( duration , maxMemoryUsed , initDuration ) ;
45
41
}
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 ( ) ;
46
47
}
0 commit comments