blob: 967d8f3471cebb195b24138ff9665207cd9e0062 [file] [log] [blame]
koder aka kdanilov66839a92015-04-11 13:22:31 +03001import texttable
2
koder aka kdanilov652cd802015-04-13 12:21:07 +03003from utils import ssize_to_b
koder aka kdanilov66839a92015-04-11 13:22:31 +03004from statistic import med_dev
5
Yulia Portnova7ddfa732015-02-24 17:32:58 +02006
koder aka kdanilov66839a92015-04-11 13:22:31 +03007def get_test_descr(data):
8 rw = {"randread": "rr",
9 "randwrite": "rw",
10 "read": "sr",
11 "write": "sw"}[data["action"]]
12
koder aka kdanilov652cd802015-04-13 12:21:07 +030013 return "{0}{1}{2}_th{3}".format(rw,
14 data['sync_mode'],
15 data['blocksize'],
16 data['concurence'])
koder aka kdanilov66839a92015-04-11 13:22:31 +030017
koder aka kdanilov66839a92015-04-11 13:22:31 +030018
koder aka kdanilov652cd802015-04-13 12:21:07 +030019def key_func(k_data):
20 _, data = k_data
21
22 bsz = ssize_to_b(data['blocksize'])
23 tp = data['action']
24 return tp, data['sync_mode'], bsz, data['concurence']
Yulia Portnova7ddfa732015-02-24 17:32:58 +020025
26
koder aka kdanilov66839a92015-04-11 13:22:31 +030027def format_results_for_console(test_set):
28 data_for_print = []
29 tab = texttable.Texttable()
koder aka kdanilov652cd802015-04-13 12:21:07 +030030 tab.set_deco(tab.HEADER | tab.VLINES | tab.BORDER)
koder aka kdanilov66839a92015-04-11 13:22:31 +030031 tab.set_cols_align(["l", "r", "r", "r", "r"])
Yulia Portnova7ddfa732015-02-24 17:32:58 +020032
koder aka kdanilov652cd802015-04-13 12:21:07 +030033 items = sorted(test_set['res'].items(), key=key_func)
34 prev_k = None
35
36 for test_name, data in items:
37 curr_k = key_func((test_name, data))[:3]
38
39 if prev_k is not None:
40 if prev_k != curr_k:
41 data_for_print.append(["---"] * 5)
42
43 prev_k = curr_k
44
koder aka kdanilov66839a92015-04-11 13:22:31 +030045 descr = get_test_descr(data)
Yulia Portnova7ddfa732015-02-24 17:32:58 +020046
koder aka kdanilov66839a92015-04-11 13:22:31 +030047 iops, _ = med_dev(data['iops'])
48 bw, bwdev = med_dev(data['bw_mean'])
Yulia Portnova7ddfa732015-02-24 17:32:58 +020049
koder aka kdanilov66839a92015-04-11 13:22:31 +030050 # 3 * sigma
51 dev_perc = int((bwdev * 300) / bw)
Yulia Portnova7ddfa732015-02-24 17:32:58 +020052
koder aka kdanilov66839a92015-04-11 13:22:31 +030053 params = (descr, int(iops), int(bw), dev_perc,
54 int(med_dev(data['lat'])[0]) // 1000)
55 data_for_print.append(params)
Yulia Portnova7ddfa732015-02-24 17:32:58 +020056
koder aka kdanilov66839a92015-04-11 13:22:31 +030057 header = ["Description", "IOPS", "BW KBps", "Dev * 3 %", "LAT ms"]
koder aka kdanilov652cd802015-04-13 12:21:07 +030058 tab.header(header)
Yulia Portnova7ddfa732015-02-24 17:32:58 +020059
koder aka kdanilov66839a92015-04-11 13:22:31 +030060 map(tab.add_row, data_for_print)
Yulia Portnova7ddfa732015-02-24 17:32:58 +020061
koder aka kdanilov66839a92015-04-11 13:22:31 +030062 return tab.draw()