blob: bbbf8d246a10cbfb842ac494b471e4afe6e47ea9 [file] [log] [blame]
Yulia Portnova7ddfa732015-02-24 17:32:58 +02001import itertools
koder aka kdanilov66839a92015-04-11 13:22:31 +03002from collections import defaultdict
3
4import texttable
5
6from 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 Portnova7ddfa732015-02-24 17:32:58 +020058
59
koder aka kdanilov66839a92015-04-11 13:22:31 +030060def 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 Portnova7ddfa732015-02-24 17:32:58 +020070 else:
koder aka kdanilov66839a92015-04-11 13:22:31 +030071 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 Portnova7ddfa732015-02-24 17:32:58 +020077
78
koder aka kdanilov66839a92015-04-11 13:22:31 +030079def 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 Portnova7ddfa732015-02-24 17:32:58 +020084
koder aka kdanilov66839a92015-04-11 13:22:31 +030085 for test_name, data in test_set['res'].items():
86 descr = get_test_descr(data)
Yulia Portnova7ddfa732015-02-24 17:32:58 +020087
koder aka kdanilov66839a92015-04-11 13:22:31 +030088 iops, _ = med_dev(data['iops'])
89 bw, bwdev = med_dev(data['bw_mean'])
Yulia Portnova7ddfa732015-02-24 17:32:58 +020090
koder aka kdanilov66839a92015-04-11 13:22:31 +030091 # 3 * sigma
92 dev_perc = int((bwdev * 300) / bw)
Yulia Portnova7ddfa732015-02-24 17:32:58 +020093
koder aka kdanilov66839a92015-04-11 13:22:31 +030094 params = (descr, int(iops), int(bw), dev_perc,
95 int(med_dev(data['lat'])[0]) // 1000)
96 data_for_print.append(params)
Yulia Portnova7ddfa732015-02-24 17:32:58 +020097
koder aka kdanilov66839a92015-04-11 13:22:31 +030098 header = ["Description", "IOPS", "BW KBps", "Dev * 3 %", "LAT ms"]
99 tab.add_row(header)
100 tab.header = header
Yulia Portnova7ddfa732015-02-24 17:32:58 +0200101
koder aka kdanilov66839a92015-04-11 13:22:31 +0300102 map(tab.add_row, data_for_print)
Yulia Portnova7ddfa732015-02-24 17:32:58 +0200103
koder aka kdanilov66839a92015-04-11 13:22:31 +0300104 return tab.draw()
Yulia Portnova7ddfa732015-02-24 17:32:58 +0200105
106
koder aka kdanilov66839a92015-04-11 13:22:31 +0300107# 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