blob: 90054509ea9f1f5974a73ef8250d79f26581e755 [file] [log] [blame]
koder aka kdanilov6c491062015-04-09 22:33:13 +03001import re
2import json
koder aka kdanilov4a510ee2015-04-21 18:50:42 +03003import collections
koder aka kdanilov6c491062015-04-09 22:33:13 +03004
5
koder aka kdanilovcff7b2e2015-04-18 20:48:15 +03006from wally.utils import ssize_to_b
7from wally.statistic import med_dev
koder aka kdanilov6c491062015-04-09 22:33:13 +03008
koder aka kdanilov4a510ee2015-04-21 18:50:42 +03009PerfInfo = collections.namedtuple('PerfInfo',
10 ('name',
11 'bw', 'iops', 'dev',
12 'lat', 'lat_dev', 'raw'))
13
14
15def process_disk_info(test_output):
16 data = {}
17
18 for tp, pre_result in test_output:
19 if tp != 'io':
20 pass
21
22 for name, results in pre_result['res'].items():
23 bw, bw_dev = med_dev(results['bw'])
24 iops, iops_dev = med_dev(results['iops'])
25 lat, lat_dev = med_dev(results['lat'])
26 dev = bw_dev / float(bw)
27 data[name] = PerfInfo(name, bw, iops, dev, lat, lat_dev, results)
28 return data
29
koder aka kdanilov6c491062015-04-09 22:33:13 +030030
31def parse_output(out_err):
32 start_patt = r"(?ims)=+\s+RESULTS\(format=json\)\s+=+"
33 end_patt = r"(?ims)=+\s+END OF RESULTS\s+=+"
34
35 for block in re.split(start_patt, out_err)[1:]:
36 data, garbage = re.split(end_patt, block)
37 yield json.loads(data.strip())
38
39 start_patt = r"(?ims)=+\s+RESULTS\(format=eval\)\s+=+"
40 end_patt = r"(?ims)=+\s+END OF RESULTS\s+=+"
41
42 for block in re.split(start_patt, out_err)[1:]:
43 data, garbage = re.split(end_patt, block)
44 yield eval(data.strip())
45
46
47def filter_data(name_prefix, fields_to_select, **filters):
48 def closure(data):
49 for result in data:
50 if name_prefix is not None:
51 if not result['jobname'].startswith(name_prefix):
52 continue
53
54 for k, v in filters.items():
55 if result.get(k) != v:
56 break
57 else:
58 yield map(result.get, fields_to_select)
59 return closure
60
61
koder aka kdanilov4a510ee2015-04-21 18:50:42 +030062def filter_processed_data(name_prefix, fields_to_select, **filters):
63 def closure(data):
64 for name, result in data.items():
65 if name_prefix is not None:
66 if not name.startswith(name_prefix):
67 continue
68
69 for k, v in filters.items():
70 if result.raw.get(k) != v:
71 break
72 else:
73 yield map(result.raw.get, fields_to_select)
74 return closure
75
76
koder aka kdanilov6c491062015-04-09 22:33:13 +030077def load_data(raw_data):
78 data = list(parse_output(raw_data))[0]
79
80 for key, val in data['res'].items():
koder aka kdanilov6c491062015-04-09 22:33:13 +030081 val['blocksize_b'] = ssize_to_b(val['blocksize'])
82
koder aka kdanilov652cd802015-04-13 12:21:07 +030083 val['iops_mediana'], val['iops_stddev'] = med_dev(val['iops'])
koder aka kdanilov4e9f3ed2015-04-14 11:26:12 +030084 val['bw_mediana'], val['bw_stddev'] = med_dev(val['bw'])
koder aka kdanilov652cd802015-04-13 12:21:07 +030085 val['lat_mediana'], val['lat_stddev'] = med_dev(val['lat'])
koder aka kdanilov6c491062015-04-09 22:33:13 +030086 yield val
87
88
89def load_files(*fnames):
90 for fname in fnames:
91 for i in load_data(open(fname).read()):
92 yield i