blob: 06357896c2330d12f53cd1befba6caf5706fc795 [file] [log] [blame]
koder aka kdanilov4643fd62015-02-10 16:20:13 -08001import re
2import sys
3import json
4
5splitter_rr = "(?ms)=====+\n"
6
7
8def get_data_from_output(fname):
9 results = {}
10 fc = open(fname).read()
11
12 for block in re.split(splitter_rr, fc):
13 block = block.strip()
koder aka kdanilove21d7472015-02-14 19:02:04 -080014
koder aka kdanilov4643fd62015-02-10 16:20:13 -080015 if not block.startswith("[{u'__meta__':"):
16 continue
koder aka kdanilove21d7472015-02-14 19:02:04 -080017
18 print
19 print
20 print block
21 print
22 print
23
koder aka kdanilov4643fd62015-02-10 16:20:13 -080024 for val in eval(block):
25 meta = val['__meta__']
26 meta['sync'] = 's' if meta['sync'] else 'a'
koder aka kdanilov3f356262015-02-13 08:06:14 -080027 key = "{action} {sync} {blocksize}k {concurence}".format(**meta)
koder aka kdanilov4643fd62015-02-10 16:20:13 -080028 results.setdefault(key, []).append(val['bw_mean'])
29
30 processed_res = {}
31
32 for k, v in results.items():
33 v.sort()
34 med = float(sum(v)) / len(v)
35 ran = sum(abs(x - med) for x in v) / len(v)
36 processed_res[k] = (int(med), int(ran))
37
38 return meta, processed_res
39
40
41def ksort(x):
koder aka kdanilov3f356262015-02-13 08:06:14 -080042 op, sync, sz, conc = x.split(" ")
43 return (op, sync, int(sz[:-1]), int(conc))
koder aka kdanilov4643fd62015-02-10 16:20:13 -080044
45
46def create_json_results(meta, file_data):
47 row = {"build_id": "",
48 "type": "",
49 "iso_md5": ""}
50 row.update(file_data)
51 return json.dumps(row)
52
53
54def show_data(*pathes):
koder aka kdanilov3f356262015-02-13 08:06:14 -080055 begin = "| {:>10} {:>5} {:>5} {:>3}"
koder aka kdanilov4643fd62015-02-10 16:20:13 -080056 first_file_templ = " | {:>6} ~ {:>5} {:>2}% {:>5}"
57 other_file_templ = " | {:>6} ~ {:>5} {:>2}% {:>5} ---- {:>6}%"
58
59 line_templ = begin + first_file_templ + \
60 other_file_templ * (len(pathes) - 1) + " |"
61
62 header_ln = line_templ.replace("<", "^").replace(">", "^")
63
koder aka kdanilov3f356262015-02-13 08:06:14 -080064 params = ["Oper", "Sync", "BSZ", "CC", "BW1", "DEV1", "%", "IOPS1"]
koder aka kdanilov4643fd62015-02-10 16:20:13 -080065 for pos in range(1, len(pathes)):
66 params += "BW{0}+DEV{0}+%+IOPS{0}+DIFF %".format(pos).split("+")
67
68 header_ln = header_ln.format(*params)
69
70 sep = '-' * len(header_ln)
71
72 results = [get_data_from_output(path)[1] for path in pathes]
73
74 print sep
75 print header_ln
76 print sep
77
78 prev_tp = None
79
80 common_keys = set(results[0].keys())
81 for result in results[1:]:
82 common_keys &= set(result.keys())
83
84 for k in sorted(common_keys, key=ksort):
85 tp = k.rsplit(" ", 1)[0]
koder aka kdanilov3f356262015-02-13 08:06:14 -080086 op, s, sz, conc = k.split(" ")
koder aka kdanilov4643fd62015-02-10 16:20:13 -080087 s = 'sync' if s == 's' else 'async'
88
89 if tp != prev_tp and prev_tp is not None:
90 print sep
91
92 prev_tp = tp
93
94 results0 = results[0]
95 m0, d0 = results0[k]
96 iops0 = m0 / int(sz[:-1])
97 perc0 = int(d0 * 100.0 / m0 + 0.5)
98
koder aka kdanilov3f356262015-02-13 08:06:14 -080099 data = [op, s, sz, conc, m0, d0, perc0, iops0]
koder aka kdanilov4643fd62015-02-10 16:20:13 -0800100
101 for result in results[1:]:
102 m, d = result[k]
103 iops = m / int(sz[:-1])
104 perc = int(d * 100.0 / m + 0.5)
105 avg_diff = int(((m - m0) * 100.) / m + 0.5)
106 data.extend([m, d, perc, iops, avg_diff])
107
108 print line_templ.format(*data)
109
110 print sep
111
112
113def main(argv):
114 path1 = argv[0]
115 if path1 == '--json':
116 print create_json_results(*get_data_from_output(argv[1]))
117 else:
118 show_data(*argv)
119 return 0
120
121if __name__ == "__main__":
122 exit(main(sys.argv[1:]))
123# print " ", results[k]