@@ -82,6 +82,18 @@ protected string BuildPerformanceString()
82
82
83
83
protected abstract string GetEventMessage ( Trace2FormatTarget formatTarget ) ;
84
84
85
+ private string GetSource ( )
86
+ {
87
+ // Source column format is file:line
88
+ string source = $ "{ File } :{ Line } ";
89
+ if ( source . Length > SourceColumnMaxWidth )
90
+ {
91
+ return TraceUtils . FormatSource ( source , SourceColumnMaxWidth ) ;
92
+ }
93
+
94
+ return source ;
95
+ }
96
+
85
97
internal static string BuildTimeSpan ( double time )
86
98
{
87
99
var timeString = time . ToString ( "F6" ) ;
@@ -91,46 +103,72 @@ internal static string BuildTimeSpan(double time)
91
103
BeginPadding = 2 ,
92
104
EndPadding = 1
93
105
} ;
94
- AdjustPadding ( component , timeString ) ;
95
106
96
- var beginPadding = new string ( ' ' , component . BeginPadding ) ;
97
- var endPadding = new string ( ' ' , component . EndPadding ) ;
107
+ return BuildSpan ( component , timeString ) ;
108
+ }
98
109
99
- return $ "{ beginPadding } { timeString } { endPadding } ";
110
+ internal static string BuildCategorySpan ( string category )
111
+ {
112
+ var component = new PerformanceFormatSpan ( )
113
+ {
114
+ Size = 13 ,
115
+ BeginPadding = 1 ,
116
+ EndPadding = 1
117
+ } ;
118
+
119
+ return BuildSpan ( component , category ) ;
100
120
}
101
121
102
- private string GetSource ( )
122
+ internal static string BuildRepoSpan ( int repo )
103
123
{
104
- // Source column format is file:line
105
- string source = $ "{ File } :{ Line } ";
106
- if ( source . Length > SourceColumnMaxWidth )
124
+ var component = new PerformanceFormatSpan ( )
107
125
{
108
- return TraceUtils . FormatSource ( source , SourceColumnMaxWidth ) ;
109
- }
126
+ Size = 5 ,
127
+ BeginPadding = 1 ,
128
+ EndPadding = 2
129
+ } ;
110
130
111
- return source ;
131
+ return BuildSpan ( component , $ "r { repo } " ) ;
112
132
}
113
133
114
- private static void AdjustPadding ( PerformanceFormatSpan span , string data )
134
+ private static string BuildSpan ( PerformanceFormatSpan component , string data )
115
135
{
116
- var paddingTotal = span . BeginPadding + span . EndPadding ;
117
- // Size difference between the expected size and the actual size of the data
118
- var sizeDifference = span . Size - paddingTotal - data . Length ;
136
+ var paddingTotal = component . BeginPadding + component . EndPadding ;
137
+ var dataLimit = component . Size - paddingTotal ;
138
+ var sizeDifference = dataLimit - data . Length ;
119
139
120
- if ( sizeDifference < 0 )
140
+ if ( sizeDifference <= 0 )
121
141
{
122
- // Remove all padding for values that take up the entire span
123
- if ( Math . Abs ( sizeDifference ) == paddingTotal )
142
+ if ( double . TryParse ( data , out _ ) )
124
143
{
125
- span . BeginPadding = 0 ;
126
- span . EndPadding = 0 ;
144
+ // Remove all padding for values that take up the entire span
145
+ if ( Math . Abs ( sizeDifference ) == paddingTotal )
146
+ {
147
+ component . BeginPadding = 0 ;
148
+ component . EndPadding = 0 ;
149
+ }
150
+ else
151
+ {
152
+ // Decrease BeginPadding for large time values that don't occupy entire span
153
+ component . BeginPadding += sizeDifference ;
154
+ }
127
155
}
128
156
else
129
157
{
130
- // Decrease BeginPadding for large time values that don't occupy entire span
131
- span . BeginPadding += sizeDifference ;
158
+ // Truncate value
159
+ data = data . Substring ( 0 , dataLimit ) ;
132
160
}
133
161
}
162
+
163
+ if ( data . Length < dataLimit )
164
+ {
165
+ component . EndPadding += Math . Abs ( sizeDifference ) ;
166
+ }
167
+
168
+ var beginPadding = new string ( ' ' , component . BeginPadding ) ;
169
+ var endPadding = new string ( ' ' , component . EndPadding ) ;
170
+
171
+ return $ "{ beginPadding } { data } { endPadding } ";
134
172
}
135
173
}
136
174
0 commit comments