blob: 55696167551c1abc77cfc212d7ad0fb1a743e813 [file] [log] [blame]
koder aka kdanilov4a72f122015-02-09 12:25:54 +02001import re
2import sys
3
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()
14 if not block.startswith("[{u'__meta__':"):
15 continue
16 for val in eval(block):
17 meta = val['__meta__']
18 meta['sync'] = 's' if meta['sync'] else 'a'
19 key = "{action} {sync} {blocksize}k".format(**meta)
20 results.setdefault(key, []).append(val['bw_mean'])
21
22 processed_res = {}
23
24 for k, v in results.items():
25 v.sort()
26 med = float(sum(v)) / len(v)
27 ran = sum(abs(x - med) for x in v) / len(v)
28 processed_res[k] = (int(med), int(ran))
29
30 return processed_res
31
32
33def ksort(x):
34 op, sync, sz = x.split(" ")
35 return (op, sync, int(sz[:-1]))
36
37
38def show_data(path1, path2=None):
39 templ_1 = " {:>10} {:>5} {:>5} {:>6} ~ {:>5} {:>2}% {:>5}"
40 templ_2 = templ_1 + " {:>6} ~ {:>5} {:>2}% {:>5} ---- {:>6}% "
41
42 ln_1 = templ_1.replace("<", "^").replace(">", "^")
43 ln_1 = ln_1.format("Oper", "Sync", "BSZ", "BW1", "DEV1", "%", "IOPS1")
44
45 ln_2 = templ_2.replace("<", "^").replace(">", "^")
46 ln_2 = ln_2.format("Oper", "Sync", "BSZ", "BW1", "DEV1", "%",
47 "IOPS1", "BW2", "DEV2", "%", "IOPS2", "DIFF %")
48
49 sep_1 = '-' * len(ln_1)
50 sep_2 = '-' * len(ln_2)
51
52 res_1 = get_data_from_output(path1)
53
54 if path2 is None:
55 res_2 = None
56 sep = sep_1
57 ln = ln_1
58 templ = templ_1
59 else:
60 res_2 = get_data_from_output(path2)
61 sep = sep_2
62 ln = ln_2
63 templ = templ_2
64
65 print sep
66 print ln
67 print sep
68
69 prev_tp = None
70
71 common_keys = set(res_1.keys())
72
73 if res_2 is not None:
74 common_keys &= set(res_2.keys())
75
76 for k in sorted(common_keys, key=ksort):
77 tp = k.rsplit(" ", 1)[0]
78 op, s, sz = k.split(" ")
79 s = 'sync' if s == 's' else 'async'
80
81 if tp != prev_tp and prev_tp is not None:
82 print sep
83
84 prev_tp = tp
85
86 m1, d1 = res_1[k]
87 iops1 = m1 / int(sz[:-1])
88 perc1 = int(d1 * 100.0 / m1 + 0.5)
89
90 if res_2 is not None:
91 m2, d2 = res_2[k]
92 iops2 = m2 / int(sz[:-1])
93 perc2 = int(d2 * 100.0 / m2 + 0.5)
94 avg_diff = int(((m2 - m1) * 100.) / m2 + 0.5)
95
96 if res_2 is not None:
97 print templ.format(op, s, sz, m1, d1, perc1, iops1,
98 m2, d2, perc2, iops2, avg_diff)
99 else:
100 print templ.format(op, s, sz, m1, d1, perc1, iops1)
101
102 print sep
103
104
105def main(argv):
106 path1 = argv[0]
107 path2 = argv[1] if len(argv) > 1 else None
108 show_data(path1, path2)
109 return 0
110
111if __name__ == "__main__":
112 exit(main(sys.argv[1:]))
113# print " ", results[k]