koder aka kdanilov | 66839a9 | 2015-04-11 13:22:31 +0300 | [diff] [blame] | 1 | import texttable |
| 2 | |
koder aka kdanilov | 652cd80 | 2015-04-13 12:21:07 +0300 | [diff] [blame^] | 3 | from utils import ssize_to_b |
koder aka kdanilov | 66839a9 | 2015-04-11 13:22:31 +0300 | [diff] [blame] | 4 | from statistic import med_dev |
| 5 | |
Yulia Portnova | 7ddfa73 | 2015-02-24 17:32:58 +0200 | [diff] [blame] | 6 | |
koder aka kdanilov | 66839a9 | 2015-04-11 13:22:31 +0300 | [diff] [blame] | 7 | def get_test_descr(data): |
| 8 | rw = {"randread": "rr", |
| 9 | "randwrite": "rw", |
| 10 | "read": "sr", |
| 11 | "write": "sw"}[data["action"]] |
| 12 | |
koder aka kdanilov | 652cd80 | 2015-04-13 12:21:07 +0300 | [diff] [blame^] | 13 | return "{0}{1}{2}_th{3}".format(rw, |
| 14 | data['sync_mode'], |
| 15 | data['blocksize'], |
| 16 | data['concurence']) |
koder aka kdanilov | 66839a9 | 2015-04-11 13:22:31 +0300 | [diff] [blame] | 17 | |
koder aka kdanilov | 66839a9 | 2015-04-11 13:22:31 +0300 | [diff] [blame] | 18 | |
koder aka kdanilov | 652cd80 | 2015-04-13 12:21:07 +0300 | [diff] [blame^] | 19 | def 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 Portnova | 7ddfa73 | 2015-02-24 17:32:58 +0200 | [diff] [blame] | 25 | |
| 26 | |
koder aka kdanilov | 66839a9 | 2015-04-11 13:22:31 +0300 | [diff] [blame] | 27 | def format_results_for_console(test_set): |
| 28 | data_for_print = [] |
| 29 | tab = texttable.Texttable() |
koder aka kdanilov | 652cd80 | 2015-04-13 12:21:07 +0300 | [diff] [blame^] | 30 | tab.set_deco(tab.HEADER | tab.VLINES | tab.BORDER) |
koder aka kdanilov | 66839a9 | 2015-04-11 13:22:31 +0300 | [diff] [blame] | 31 | tab.set_cols_align(["l", "r", "r", "r", "r"]) |
Yulia Portnova | 7ddfa73 | 2015-02-24 17:32:58 +0200 | [diff] [blame] | 32 | |
koder aka kdanilov | 652cd80 | 2015-04-13 12:21:07 +0300 | [diff] [blame^] | 33 | 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 kdanilov | 66839a9 | 2015-04-11 13:22:31 +0300 | [diff] [blame] | 45 | descr = get_test_descr(data) |
Yulia Portnova | 7ddfa73 | 2015-02-24 17:32:58 +0200 | [diff] [blame] | 46 | |
koder aka kdanilov | 66839a9 | 2015-04-11 13:22:31 +0300 | [diff] [blame] | 47 | iops, _ = med_dev(data['iops']) |
| 48 | bw, bwdev = med_dev(data['bw_mean']) |
Yulia Portnova | 7ddfa73 | 2015-02-24 17:32:58 +0200 | [diff] [blame] | 49 | |
koder aka kdanilov | 66839a9 | 2015-04-11 13:22:31 +0300 | [diff] [blame] | 50 | # 3 * sigma |
| 51 | dev_perc = int((bwdev * 300) / bw) |
Yulia Portnova | 7ddfa73 | 2015-02-24 17:32:58 +0200 | [diff] [blame] | 52 | |
koder aka kdanilov | 66839a9 | 2015-04-11 13:22:31 +0300 | [diff] [blame] | 53 | params = (descr, int(iops), int(bw), dev_perc, |
| 54 | int(med_dev(data['lat'])[0]) // 1000) |
| 55 | data_for_print.append(params) |
Yulia Portnova | 7ddfa73 | 2015-02-24 17:32:58 +0200 | [diff] [blame] | 56 | |
koder aka kdanilov | 66839a9 | 2015-04-11 13:22:31 +0300 | [diff] [blame] | 57 | header = ["Description", "IOPS", "BW KBps", "Dev * 3 %", "LAT ms"] |
koder aka kdanilov | 652cd80 | 2015-04-13 12:21:07 +0300 | [diff] [blame^] | 58 | tab.header(header) |
Yulia Portnova | 7ddfa73 | 2015-02-24 17:32:58 +0200 | [diff] [blame] | 59 | |
koder aka kdanilov | 66839a9 | 2015-04-11 13:22:31 +0300 | [diff] [blame] | 60 | map(tab.add_row, data_for_print) |
Yulia Portnova | 7ddfa73 | 2015-02-24 17:32:58 +0200 | [diff] [blame] | 61 | |
koder aka kdanilov | 66839a9 | 2015-04-11 13:22:31 +0300 | [diff] [blame] | 62 | return tab.draw() |