@@ -170,25 +170,56 @@ def to_lnt_test_obj(self, args):
170
170
}
171
171
172
172
173
+ AUXPATSTR = (r"(?P<module>[^-]+)-(?P<input>[^-]+)-(?P<triple>[^-]+)" +
174
+ r"-(?P<out>[^-]*)-(?P<opt>[^-]+)" )
175
+ AUXPAT = re .compile (AUXPATSTR )
176
+
177
+ TIMERPATSTR = (r"time\.swift-(?P<jobkind>\w+)\." + AUXPATSTR +
178
+ "\.(?P<timerkind>\w+)$" )
179
+ TIMERPAT = re .compile (TIMERPATSTR )
180
+
181
+ FILEPATSTR = (r"^stats-(?P<start>\d+)-swift-(?P<kind>\w+)-" +
182
+ AUXPATSTR +
183
+ r"-(?P<pid>\d+)(-.*)?.json$" )
184
+ FILEPAT = re .compile (FILEPATSTR )
185
+
186
+
187
+ def match_auxpat (s ):
188
+ m = AUXPAT .match (s )
189
+ if m is not None :
190
+ return m .groupdict ()
191
+ else :
192
+ return None
193
+
194
+
195
+ def match_timerpat (s ):
196
+ m = TIMERPAT .match (s )
197
+ if m is not None :
198
+ return m .groupdict ()
199
+ else :
200
+ return None
201
+
202
+
203
+ def match_filepat (s ):
204
+ m = FILEPAT .match (s )
205
+ if m is not None :
206
+ return m .groupdict ()
207
+ else :
208
+ return None
209
+
210
+
173
211
def load_stats_dir (path , select_module = [], select_stat = [],
174
- exclude_timers = False , ** kwargs ):
212
+ exclude_timers = False , merge_timers = False , ** kwargs ):
175
213
"""Loads all stats-files found in path into a list of JobStats objects"""
176
214
jobstats = []
177
- auxpat = (r"(?P<module>[^-]+)-(?P<input>[^-]+)-(?P<triple>[^-]+)" +
178
- r"-(?P<out>[^-]*)-(?P<opt>[^-]+)" )
179
- fpat = (r"^stats-(?P<start>\d+)-swift-(?P<kind>\w+)-" +
180
- auxpat +
181
- r"-(?P<pid>\d+)(-.*)?.json$" )
182
- fre = re .compile (fpat )
183
215
sre = re .compile ('.*' if len (select_stat ) == 0 else
184
216
'|' .join (select_stat ))
185
217
for root , dirs , files in os .walk (path ):
186
218
for f in files :
187
- m = fre . match (f )
188
- if not m :
219
+ mg = match_filepat (f )
220
+ if not mg :
189
221
continue
190
222
# NB: "pid" in fpat is a random number, not unix pid.
191
- mg = m .groupdict ()
192
223
jobkind = mg ['kind' ]
193
224
jobid = int (mg ['pid' ])
194
225
start_usec = int (mg ['start' ])
@@ -200,21 +231,22 @@ def load_stats_dir(path, select_module=[], select_stat=[],
200
231
with open (os .path .join (root , f )) as fp :
201
232
j = json .load (fp )
202
233
dur_usec = 1
203
- patstr = (r"time\.swift-" + jobkind + r"\." + auxpat +
204
- r"\.wall$" )
205
- pat = re .compile (patstr )
206
234
stats = dict ()
207
235
for (k , v ) in j .items ():
208
236
if sre .search (k ) is None :
209
237
continue
210
- if k .startswith ("time." ):
238
+ if k .startswith ('time.' ) and exclude_timers :
239
+ continue
240
+ tm = match_timerpat (k )
241
+ if tm :
211
242
v = int (1000000.0 * float (v ))
212
- if exclude_timers :
213
- continue
243
+ if tm ['jobkind' ] == jobkind and \
244
+ tm ['timerkind' ] == 'wall' :
245
+ dur_usec = v
246
+ if merge_timers :
247
+ k = "time.swift-%s.%s" % (tm ['jobkind' ],
248
+ tm ['timerkind' ])
214
249
stats [k ] = v
215
- tm = re .match (pat , k )
216
- if tm :
217
- dur_usec = v
218
250
219
251
e = JobStats (jobkind = jobkind , jobid = jobid ,
220
252
module = module , start_usec = start_usec ,
0 commit comments