blob: 08dbc772e05aa835a01f87be1f408b809e59f6a1 [file] [log] [blame]
koder aka kdanilov8ad6e812015-03-22 14:42:18 +02001import sys
2import math
3import itertools
4
5
6def key(x):
7 return (x['__meta__']['blocksize'],
8 'd' if x['__meta__']['direct_io'] else 's',
9 x['__meta__']['action'],
10 x['__meta__']['concurence'])
11
12
13def med_dev(vals):
14 med = sum(vals) / len(vals)
15 dev = ((sum(abs(med - i) ** 2 for i in vals) / len(vals)) ** 0.5)
16 return int(med), int(dev)
17
18
19def round_deviation(med_dev):
20 med, dev = med_dev
21
22 if dev < 1E-7:
23 return med_dev
24
25 dev_div = 10.0 ** (math.floor(math.log10(dev)) - 1)
26 dev = int(dev / dev_div) * dev_div
27 med = int(med / dev_div) * dev_div
28 return (type(med_dev[0])(med),
29 type(med_dev[1])(dev))
30
31
32def groupby_globally(data, key_func):
33 grouped = {}
34 grouped_iter = itertools.groupby(data, key_func)
35
36 for (bs, cache_tp, act, conc), curr_data_it in grouped_iter:
37 key = (bs, cache_tp, act, conc)
38 grouped.setdefault(key, []).extend(curr_data_it)
39
40 return grouped
41
42
43template = "{bs:>4} {action:>12} {cache_tp:>3} {conc:>4}"
44template += " | {iops[0]:>6} ~ {iops[1]:>5} | {bw[0]:>7} ~ {bw[1]:>6}"
45template += " | {lat[0]:>6} ~ {lat[1]:>5} |"
46
47headers = dict(bs="BS",
48 action="operation",
49 cache_tp="S/D",
50 conc="CONC",
51 iops=("IOPS", "dev"),
52 bw=("BW kBps", "dev"),
53 lat=("LAT ms", "dev"))
54
55
56def main(argv):
57 data = []
58
59 with open(argv[1]) as fc:
60 block = None
61 for line in fc:
62 if line.startswith("{'__meta__':"):
63 block = line
64 elif block is not None:
65 block += line
66
67 if block is not None:
68 if block.count('}') == block.count('{'):
69 data.append(eval(block))
70 block = None
71
72 grouped = groupby_globally(data, key)
73
74 print template.format(**headers)
75
76 for (bs, cache_tp, act, conc), curr_data in sorted(grouped.items()):
77 iops = med_dev([i['iops'] * int(conc) for i in curr_data])
78 bw_mean = med_dev([i['bw_mean'] * int(conc) for i in curr_data])
79 lat = med_dev([i['lat'] / 1000 for i in curr_data])
80
81 iops = round_deviation(iops)
82 bw_mean = round_deviation(bw_mean)
83 lat = round_deviation(lat)
84
85 params = dict(
86 bs=bs,
87 action=act,
88 cache_tp=cache_tp,
89 iops=iops,
90 bw=bw_mean,
91 lat=lat,
92 conc=conc
93 )
94
95 print template.format(**params)
96
97
98if __name__ == "__main__":
99 exit(main(sys.argv))
100
101 # vals = [(123, 23), (125678, 5678), (123.546756, 23.77),
102 # (123.546756, 102.77), (0.1234, 0.0224),
103 # (0.001234, 0.000224), (0.001234, 0.0000224)]
104 # for val in :
105 # print val, "=>", round_deviation(val)