Yulia Portnova | 7ddfa73 | 2015-02-24 17:32:58 +0200 | [diff] [blame] | 1 | import itertools |
koder aka kdanilov | 66839a9 | 2015-04-11 13:22:31 +0300 | [diff] [blame^] | 2 | from collections import defaultdict |
| 3 | |
| 4 | import texttable |
| 5 | |
| 6 | from statistic import med_dev |
| 7 | |
| 8 | # [{u'__meta__': {u'raw_cfg': u'[writetest * 2]\ngroup_reporting\nnumjobs=4\nwait_for_previous\nramp_time=5\nblocksize=4k\nfilename={FILENAME}\nrw=randwrite\ndirect=1\nbuffered=0\niodepth=1\nsize=100Mb\nruntime=10\ntime_based\n\n[readtest * 2]\ngroup_reporting\nnumjobs=4\nwait_for_previous\nramp_time=5\nblocksize=4k\nfilename={FILENAME}\nrw=randread\ndirect=1\nbuffered=0\niodepth=1\nsize=100Mb\nruntime=10\ntime_based\n'}, |
| 9 | # u'res': {u'readtest': {u'action': u'randread', |
| 10 | # u'blocksize': u'4k', |
| 11 | # u'bw_mean': [349.61, 276.54], |
| 12 | # u'clat': [11987.16, 15235.08], |
| 13 | # u'concurence': 4, |
| 14 | # u'direct_io': True, |
| 15 | # u'iops': [316, 251], |
| 16 | # u'jobname': u'readtest', |
| 17 | # u'lat': [11987.52, 15235.46], |
| 18 | # u'slat': [0.0, 0.0], |
| 19 | # u'sync': False, |
| 20 | # u'timings': [u'10', u'5']}, |
| 21 | # u'writetest': {u'action': u'randwrite', |
| 22 | # u'blocksize': u'4k', |
| 23 | # u'bw_mean': [72.03, 61.84], |
| 24 | # u'clat': [113525.86, 152836.42], |
| 25 | # u'concurence': 4, |
| 26 | # u'direct_io': True, |
| 27 | # u'iops': [35, 23], |
| 28 | # u'jobname': u'writetest', |
| 29 | # u'lat': [113526.31, 152836.89], |
| 30 | # u'slat': [0.0, 0.0], |
| 31 | # u'sync': False, |
| 32 | # u'timings': [u'10', u'5']}}}, |
| 33 | # {u'__meta__': {u'raw_cfg': u'[writetest * 2]\ngroup_reporting\nnumjobs=4\nwait_for_previous\nramp_time=5\nblocksize=4k\nfilename={FILENAME}\nrw=randwrite\ndirect=1\nbuffered=0\niodepth=1\nsize=100Mb\nruntime=10\ntime_based\n\n[readtest * 2]\ngroup_reporting\nnumjobs=4\nwait_for_previous\nramp_time=5\nblocksize=4k\nfilename={FILENAME}\nrw=randread\ndirect=1\nbuffered=0\niodepth=1\nsize=100Mb\nruntime=10\ntime_based\n'}, |
| 34 | # u'res': {u'readtest': {u'action': u'randread', |
| 35 | # u'blocksize': u'4k', |
| 36 | # u'bw_mean': [287.62, 280.76], |
| 37 | # u'clat': [15437.57, 14741.65], |
| 38 | # u'concurence': 4, |
| 39 | # u'direct_io': True, |
| 40 | # u'iops': [258, 271], |
| 41 | # u'jobname': u'readtest', |
| 42 | # u'lat': [15437.94, 14742.04], |
| 43 | # u'slat': [0.0, 0.0], |
| 44 | # u'sync': False, |
| 45 | # u'timings': [u'10', u'5']}, |
| 46 | # u'writetest': {u'action': u'randwrite', |
| 47 | # u'blocksize': u'4k', |
| 48 | # u'bw_mean': [71.18, 61.62], |
| 49 | # u'clat': [116382.95, 153486.81], |
| 50 | # u'concurence': 4, |
| 51 | # u'direct_io': True, |
| 52 | # u'iops': [32, 22], |
| 53 | # u'jobname': u'writetest', |
| 54 | # u'lat': [116383.44, 153487.27], |
| 55 | # u'slat': [0.0, 0.0], |
| 56 | # u'sync': False, |
| 57 | # u'timings': [u'10', u'5']}}}] |
Yulia Portnova | 7ddfa73 | 2015-02-24 17:32:58 +0200 | [diff] [blame] | 58 | |
| 59 | |
koder aka kdanilov | 66839a9 | 2015-04-11 13:22:31 +0300 | [diff] [blame^] | 60 | def get_test_descr(data): |
| 61 | rw = {"randread": "rr", |
| 62 | "randwrite": "rw", |
| 63 | "read": "sr", |
| 64 | "write": "sw"}[data["action"]] |
| 65 | |
| 66 | if data["direct_io"]: |
| 67 | sync_mode = 'd' |
| 68 | elif data["sync"]: |
| 69 | sync_mode = 's' |
Yulia Portnova | 7ddfa73 | 2015-02-24 17:32:58 +0200 | [diff] [blame] | 70 | else: |
koder aka kdanilov | 66839a9 | 2015-04-11 13:22:31 +0300 | [diff] [blame^] | 71 | sync_mode = 'a' |
| 72 | |
| 73 | th_count = int(data['concurence']) |
| 74 | |
| 75 | return "{0}{1}{2}_th{3}".format(rw, sync_mode, |
| 76 | data['blocksize'], th_count) |
Yulia Portnova | 7ddfa73 | 2015-02-24 17:32:58 +0200 | [diff] [blame] | 77 | |
| 78 | |
koder aka kdanilov | 66839a9 | 2015-04-11 13:22:31 +0300 | [diff] [blame^] | 79 | def format_results_for_console(test_set): |
| 80 | data_for_print = [] |
| 81 | tab = texttable.Texttable() |
| 82 | tab.set_deco(tab.HEADER | tab.VLINES | tab.BORDER | tab.HLINES) |
| 83 | tab.set_cols_align(["l", "r", "r", "r", "r"]) |
Yulia Portnova | 7ddfa73 | 2015-02-24 17:32:58 +0200 | [diff] [blame] | 84 | |
koder aka kdanilov | 66839a9 | 2015-04-11 13:22:31 +0300 | [diff] [blame^] | 85 | for test_name, data in test_set['res'].items(): |
| 86 | descr = get_test_descr(data) |
Yulia Portnova | 7ddfa73 | 2015-02-24 17:32:58 +0200 | [diff] [blame] | 87 | |
koder aka kdanilov | 66839a9 | 2015-04-11 13:22:31 +0300 | [diff] [blame^] | 88 | iops, _ = med_dev(data['iops']) |
| 89 | bw, bwdev = med_dev(data['bw_mean']) |
Yulia Portnova | 7ddfa73 | 2015-02-24 17:32:58 +0200 | [diff] [blame] | 90 | |
koder aka kdanilov | 66839a9 | 2015-04-11 13:22:31 +0300 | [diff] [blame^] | 91 | # 3 * sigma |
| 92 | dev_perc = int((bwdev * 300) / bw) |
Yulia Portnova | 7ddfa73 | 2015-02-24 17:32:58 +0200 | [diff] [blame] | 93 | |
koder aka kdanilov | 66839a9 | 2015-04-11 13:22:31 +0300 | [diff] [blame^] | 94 | params = (descr, int(iops), int(bw), dev_perc, |
| 95 | int(med_dev(data['lat'])[0]) // 1000) |
| 96 | data_for_print.append(params) |
Yulia Portnova | 7ddfa73 | 2015-02-24 17:32:58 +0200 | [diff] [blame] | 97 | |
koder aka kdanilov | 66839a9 | 2015-04-11 13:22:31 +0300 | [diff] [blame^] | 98 | header = ["Description", "IOPS", "BW KBps", "Dev * 3 %", "LAT ms"] |
| 99 | tab.add_row(header) |
| 100 | tab.header = header |
Yulia Portnova | 7ddfa73 | 2015-02-24 17:32:58 +0200 | [diff] [blame] | 101 | |
koder aka kdanilov | 66839a9 | 2015-04-11 13:22:31 +0300 | [diff] [blame^] | 102 | map(tab.add_row, data_for_print) |
Yulia Portnova | 7ddfa73 | 2015-02-24 17:32:58 +0200 | [diff] [blame] | 103 | |
koder aka kdanilov | 66839a9 | 2015-04-11 13:22:31 +0300 | [diff] [blame^] | 104 | return tab.draw() |
Yulia Portnova | 7ddfa73 | 2015-02-24 17:32:58 +0200 | [diff] [blame] | 105 | |
| 106 | |
koder aka kdanilov | 66839a9 | 2015-04-11 13:22:31 +0300 | [diff] [blame^] | 107 | # def format_pgbench_stat(res): |
| 108 | # """ |
| 109 | # Receives results in format: |
| 110 | # "<num_clients> <num_transactions>: <tps> |
| 111 | # <num_clients> <num_transactions>: <tps> |
| 112 | # .... |
| 113 | # " |
| 114 | # """ |
| 115 | # if res: |
| 116 | # data = {} |
| 117 | # grouped_res = itertools.groupby(res, lambda x: x[0]) |
| 118 | # for key, group in grouped_res: |
| 119 | # results = list(group) |
| 120 | # sum_res = sum([r[1] for r in results]) |
| 121 | # mean = sum_res/len(results) |
| 122 | # sum_sq = sum([(r[1] - mean) ** 2 for r in results]) |
| 123 | # if len(results) > 1: |
| 124 | # dev = (sum_sq / (len(results) - 1)) |
| 125 | # else: |
| 126 | # dev = 0 |
| 127 | # data[key] = (mean, dev) |
| 128 | # return data |