Skip to content

Commit b37f36c

Browse files
committed
[process-stats-dir] Support --select-stat in csv operations.
1 parent 98322a3 commit b37f36c

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

utils/process-stats-dir.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import json
2121
import os
2222
import platform
23+
import re
2324
import sys
2425
import time
2526
import urllib
@@ -154,15 +155,19 @@ def update_epoch_value(d, name, epoch, value):
154155
return (epoch, value, changed)
155156

156157

157-
def read_stats_dict_from_csv(f):
158+
def read_stats_dict_from_csv(f, select_stat=''):
158159
infieldnames = ["epoch", "name", "value"]
159160
c = csv.DictReader(f, infieldnames,
160161
dialect='excel-tab',
161162
quoting=csv.QUOTE_NONNUMERIC)
162163
d = {}
164+
sre = re.compile('.*' if len(select_stat) == 0 else
165+
'|'.join(select_stat))
163166
for row in c:
164167
epoch = int(row["epoch"])
165168
name = row["name"]
169+
if sre.search(name) is None:
170+
continue
166171
value = int(row["value"])
167172
update_epoch_value(d, name, epoch, value)
168173
return d
@@ -189,7 +194,8 @@ def set_csv_baseline(args):
189194
existing = None
190195
if os.path.exists(args.set_csv_baseline):
191196
with open(args.set_csv_baseline, "r") as f:
192-
existing = read_stats_dict_from_csv(f)
197+
existing = read_stats_dict_from_csv(f,
198+
select_stat=args.select_stat)
193199
print ("updating %d baseline entries in %s" %
194200
(len(existing), args.set_csv_baseline))
195201
else:
@@ -273,7 +279,8 @@ def write_comparison(args, old_stats, new_stats):
273279

274280

275281
def compare_to_csv_baseline(args):
276-
old_stats = read_stats_dict_from_csv(args.compare_to_csv_baseline)
282+
old_stats = read_stats_dict_from_csv(args.compare_to_csv_baseline,
283+
select_stat=args.select_stat)
277284
m = merge_all_jobstats((s for d in args.remainder
278285
for s in load_stats_dir(d, **vars(args))),
279286
**vars(args))

0 commit comments

Comments
 (0)