koder aka kdanilov | 652cd80 | 2015-04-13 12:21:07 +0300 | [diff] [blame] | 1 | import sys |
Yulia Portnova | 6d72d7f | 2015-02-04 16:48:50 +0200 | [diff] [blame] | 2 | from collections import OrderedDict |
Yulia Portnova | 6d72d7f | 2015-02-04 16:48:50 +0200 | [diff] [blame] | 3 | |
koder aka kdanilov | 652cd80 | 2015-04-13 12:21:07 +0300 | [diff] [blame] | 4 | import matplotlib.pyplot as plt |
koder aka kdanilov | 66839a9 | 2015-04-11 13:22:31 +0300 | [diff] [blame] | 5 | |
Yulia Portnova | 407ca95 | 2015-04-10 10:38:15 +0300 | [diff] [blame] | 6 | import formatters |
koder aka kdanilov | 66839a9 | 2015-04-11 13:22:31 +0300 | [diff] [blame] | 7 | from chart import charts |
koder aka kdanilov | 2c47309 | 2015-03-29 17:12:13 +0300 | [diff] [blame] | 8 | from utils import ssize_to_b |
koder aka kdanilov | 652cd80 | 2015-04-13 12:21:07 +0300 | [diff] [blame] | 9 | from statistic import med_dev, approximate_curve |
| 10 | |
| 11 | from disk_perf_test_tool.tests.io_results_loader import (load_files, |
| 12 | filter_data) |
Yulia Portnova | 6d72d7f | 2015-02-04 16:48:50 +0200 | [diff] [blame] | 13 | |
| 14 | |
Yulia Portnova | 7b3b1d4 | 2015-02-13 14:08:35 +0200 | [diff] [blame] | 15 | OPERATIONS = (('async', ('randwrite asynchronous', 'randread asynchronous', |
| 16 | 'write asynchronous', 'read asynchronous')), |
| 17 | ('sync', ('randwrite synchronous', 'randread synchronous', |
koder aka kdanilov | 652cd80 | 2015-04-13 12:21:07 +0300 | [diff] [blame] | 18 | 'write synchronous', 'read synchronous')), |
| 19 | ('direct', ('randwrite direct', 'randread direct', |
| 20 | 'write direct', 'read direct'))) |
Yulia Portnova | 7b3b1d4 | 2015-02-13 14:08:35 +0200 | [diff] [blame] | 21 | |
| 22 | sync_async_view = {'s': 'synchronous', |
koder aka kdanilov | 652cd80 | 2015-04-13 12:21:07 +0300 | [diff] [blame] | 23 | 'a': 'asynchronous', |
| 24 | 'd': 'direct'} |
Yulia Portnova | 042344d | 2015-02-10 17:38:33 +0200 | [diff] [blame] | 25 | |
| 26 | |
koder aka kdanilov | 652cd80 | 2015-04-13 12:21:07 +0300 | [diff] [blame] | 27 | # def pgbench_chart_data(results): |
| 28 | # """ |
| 29 | # Format pgbench results for chart |
| 30 | # """ |
| 31 | # data = {} |
| 32 | # charts_url = [] |
Yulia Portnova | 6d72d7f | 2015-02-04 16:48:50 +0200 | [diff] [blame] | 33 | |
koder aka kdanilov | 652cd80 | 2015-04-13 12:21:07 +0300 | [diff] [blame] | 34 | # formatted_res = formatters.format_pgbench_stat(results) |
| 35 | # for key, value in formatted_res.items(): |
| 36 | # num_cl, num_tr = key.split(' ') |
| 37 | # data.setdefault(num_cl, {}).setdefault(build, {}) |
| 38 | # data[keys[z]][build][ |
| 39 | # ' '.join(keys)] = value |
Yulia Portnova | 6d72d7f | 2015-02-04 16:48:50 +0200 | [diff] [blame] | 40 | |
koder aka kdanilov | 652cd80 | 2015-04-13 12:21:07 +0300 | [diff] [blame] | 41 | # for name, value in data.items(): |
| 42 | # title = name |
| 43 | # legend = [] |
| 44 | # dataset = [] |
Yulia Portnova | 6d72d7f | 2015-02-04 16:48:50 +0200 | [diff] [blame] | 45 | |
koder aka kdanilov | 652cd80 | 2015-04-13 12:21:07 +0300 | [diff] [blame] | 46 | # scale_x = [] |
Yulia Portnova | 6d72d7f | 2015-02-04 16:48:50 +0200 | [diff] [blame] | 47 | |
koder aka kdanilov | 652cd80 | 2015-04-13 12:21:07 +0300 | [diff] [blame] | 48 | # for build_id, build_results in value.items(): |
| 49 | # vals = [] |
| 50 | # OD = OrderedDict |
| 51 | # ordered_build_results = OD(sorted(build_results.items(), |
| 52 | # key=lambda t: t[0])) |
| 53 | # scale_x = ordered_build_results.keys() |
| 54 | # for key in scale_x: |
| 55 | # res = build_results.get(key) |
| 56 | # if res: |
| 57 | # vals.append(res) |
| 58 | # if vals: |
| 59 | # dataset.append(vals) |
| 60 | # legend.append(build_id) |
Yulia Portnova | e440802 | 2015-02-10 15:39:25 +0200 | [diff] [blame] | 61 | |
koder aka kdanilov | 652cd80 | 2015-04-13 12:21:07 +0300 | [diff] [blame] | 62 | # if dataset: |
| 63 | # charts_url.append(str(charts.render_vertical_bar |
| 64 | # (title, legend, dataset, scale_x=scale_x))) |
| 65 | # return charts_url |
Yulia Portnova | 919f3be | 2015-02-06 12:49:22 +0200 | [diff] [blame] | 66 | |
| 67 | |
Yulia Portnova | 407ca95 | 2015-04-10 10:38:15 +0300 | [diff] [blame] | 68 | def build_vertical_bar(results, z=0): |
| 69 | data = {} |
| 70 | charts_url = [] |
| 71 | for build, res in results: |
| 72 | formatted_res = formatters.get_formatter(build)(res) |
| 73 | for key, value in formatted_res.items(): |
| 74 | keys = key.split(' ') |
| 75 | data.setdefault(keys[z], {}).setdefault(build, {}) |
| 76 | data[keys[z]][build][ |
| 77 | ' '.join(keys)] = value |
| 78 | |
| 79 | for name, value in data.items(): |
| 80 | title = name |
| 81 | legend = [] |
| 82 | dataset = [] |
| 83 | |
| 84 | scale_x = [] |
| 85 | |
| 86 | for build_id, build_results in value.items(): |
| 87 | vals = [] |
| 88 | OD = OrderedDict |
| 89 | ordered_build_results = OD(sorted(build_results.items(), |
| 90 | key=lambda t: t[0])) |
| 91 | scale_x = ordered_build_results.keys() |
| 92 | for key in scale_x: |
| 93 | res = build_results.get(key) |
| 94 | if res: |
| 95 | vals.append(res) |
| 96 | if vals: |
| 97 | dataset.append(vals) |
| 98 | legend.append(build_id) |
| 99 | |
| 100 | if dataset: |
| 101 | charts_url.append(str(charts.render_vertical_bar |
| 102 | (title, legend, dataset, scale_x=scale_x))) |
| 103 | return charts_url |
| 104 | |
| 105 | |
| 106 | def build_lines_chart(results, z=0): |
Yulia Portnova | 919f3be | 2015-02-06 12:49:22 +0200 | [diff] [blame] | 107 | data = {} |
| 108 | charts_url = [] |
| 109 | |
Yulia Portnova | 407ca95 | 2015-04-10 10:38:15 +0300 | [diff] [blame] | 110 | for build, res in results: |
| 111 | formatted_res = formatters.get_formatter(build)(res) |
| 112 | for key, value in formatted_res.items(): |
Yulia Portnova | 919f3be | 2015-02-06 12:49:22 +0200 | [diff] [blame] | 113 | keys = key.split(' ') |
Yulia Portnova | 407ca95 | 2015-04-10 10:38:15 +0300 | [diff] [blame] | 114 | data.setdefault(key[z], {}) |
| 115 | data[key[z]].setdefault(build, {})[keys[1]] = value |
Yulia Portnova | 919f3be | 2015-02-06 12:49:22 +0200 | [diff] [blame] | 116 | |
| 117 | for name, value in data.items(): |
| 118 | title = name |
| 119 | legend = [] |
| 120 | dataset = [] |
| 121 | scale_x = [] |
| 122 | for build_id, build_results in value.items(): |
| 123 | legend.append(build_id) |
koder aka kdanilov | e21d747 | 2015-02-14 19:02:04 -0800 | [diff] [blame] | 124 | |
| 125 | OD = OrderedDict |
| 126 | ordered_build_results = OD(sorted(build_results.items(), |
koder aka kdanilov | 2c47309 | 2015-03-29 17:12:13 +0300 | [diff] [blame] | 127 | key=lambda t: ssize_to_b(t[0]))) |
koder aka kdanilov | e21d747 | 2015-02-14 19:02:04 -0800 | [diff] [blame] | 128 | |
Yulia Portnova | 919f3be | 2015-02-06 12:49:22 +0200 | [diff] [blame] | 129 | if not scale_x: |
| 130 | scale_x = ordered_build_results.keys() |
| 131 | dataset.append(zip(*ordered_build_results.values())[0]) |
| 132 | |
| 133 | chart = charts.render_lines(title, legend, dataset, scale_x) |
| 134 | charts_url.append(str(chart)) |
| 135 | |
| 136 | return charts_url |
| 137 | |
| 138 | |
Yulia Portnova | 407ca95 | 2015-04-10 10:38:15 +0300 | [diff] [blame] | 139 | def render_html(charts_urls, dest): |
Yulia Portnova | 919f3be | 2015-02-06 12:49:22 +0200 | [diff] [blame] | 140 | templ = open("report.html", 'r').read() |
| 141 | body = "<div><ol>%s</ol></div>" |
| 142 | li = "<li><img src='%s'></li>" |
| 143 | ol = [] |
| 144 | for chart in charts_urls: |
| 145 | ol.append(li % chart) |
| 146 | html = templ % {'body': body % '\n'.join(ol)} |
Yulia Portnova | 407ca95 | 2015-04-10 10:38:15 +0300 | [diff] [blame] | 147 | open(dest, 'w').write(html) |
Yulia Portnova | 919f3be | 2015-02-06 12:49:22 +0200 | [diff] [blame] | 148 | |
| 149 | |
Yulia Portnova | 407ca95 | 2015-04-10 10:38:15 +0300 | [diff] [blame] | 150 | def build_io_chart(res): |
| 151 | pass |
| 152 | |
| 153 | |
koder aka kdanilov | 652cd80 | 2015-04-13 12:21:07 +0300 | [diff] [blame] | 154 | # def render_html_results(ctx): |
| 155 | # charts = [] |
| 156 | # for res in ctx.results: |
| 157 | # if res[0] == "io": |
| 158 | # charts.append(build_io_chart(res)) |
Yulia Portnova | 407ca95 | 2015-04-10 10:38:15 +0300 | [diff] [blame] | 159 | |
koder aka kdanilov | 652cd80 | 2015-04-13 12:21:07 +0300 | [diff] [blame] | 160 | # bars = build_vertical_bar(ctx.results) |
| 161 | # lines = build_lines_chart(ctx.results) |
Yulia Portnova | 407ca95 | 2015-04-10 10:38:15 +0300 | [diff] [blame] | 162 | |
koder aka kdanilov | 652cd80 | 2015-04-13 12:21:07 +0300 | [diff] [blame] | 163 | # render_html(bars + lines, dest) |
Yulia Portnova | 407ca95 | 2015-04-10 10:38:15 +0300 | [diff] [blame] | 164 | |
Yulia Portnova | 407ca95 | 2015-04-10 10:38:15 +0300 | [diff] [blame] | 165 | |
koder aka kdanilov | 652cd80 | 2015-04-13 12:21:07 +0300 | [diff] [blame] | 166 | def make_io_report(results): |
| 167 | for suite_type, test_suite_data in results: |
| 168 | if suite_type != 'io': |
| 169 | continue |
Yulia Portnova | 407ca95 | 2015-04-10 10:38:15 +0300 | [diff] [blame] | 170 | |
koder aka kdanilov | 652cd80 | 2015-04-13 12:21:07 +0300 | [diff] [blame] | 171 | io_test_suite_res = test_suite_data['res'] |
koder aka kdanilov | 66839a9 | 2015-04-11 13:22:31 +0300 | [diff] [blame] | 172 | |
koder aka kdanilov | 652cd80 | 2015-04-13 12:21:07 +0300 | [diff] [blame] | 173 | charts_url = [] |
koder aka kdanilov | 66839a9 | 2015-04-11 13:22:31 +0300 | [diff] [blame] | 174 | |
koder aka kdanilov | 652cd80 | 2015-04-13 12:21:07 +0300 | [diff] [blame] | 175 | name_filters = [ |
| 176 | #('hdd_test_rws4k', ('concurence', 'lat', 'iops')), |
| 177 | #('hdd_test_rrs4k', ('concurence', 'lat', 'iops')), |
| 178 | ('hdd_test_rrd4k', ('concurence', 'lat', 'iops')), |
koder aka kdanilov | 4e9f3ed | 2015-04-14 11:26:12 +0300 | [diff] [blame] | 179 | ('hdd_test_swd1m', ('concurence', 'lat', 'bw')), |
koder aka kdanilov | 652cd80 | 2015-04-13 12:21:07 +0300 | [diff] [blame] | 180 | ] |
koder aka kdanilov | 66839a9 | 2015-04-11 13:22:31 +0300 | [diff] [blame] | 181 | |
koder aka kdanilov | 652cd80 | 2015-04-13 12:21:07 +0300 | [diff] [blame] | 182 | for name_filter, fields in name_filters: |
| 183 | th_filter = filter_data(name_filter, fields) |
koder aka kdanilov | 66839a9 | 2015-04-11 13:22:31 +0300 | [diff] [blame] | 184 | |
koder aka kdanilov | 652cd80 | 2015-04-13 12:21:07 +0300 | [diff] [blame] | 185 | data_iter = sorted(th_filter(io_test_suite_res.values())) |
Yulia Portnova | 407ca95 | 2015-04-10 10:38:15 +0300 | [diff] [blame] | 186 | |
koder aka kdanilov | 652cd80 | 2015-04-13 12:21:07 +0300 | [diff] [blame] | 187 | concurence, latv, iops_or_bw_v = zip(*data_iter) |
| 188 | iops_or_bw_v, iops_or_bw_dev_v = zip(*map(med_dev, iops_or_bw_v)) |
Yulia Portnova | 407ca95 | 2015-04-10 10:38:15 +0300 | [diff] [blame] | 189 | |
koder aka kdanilov | 652cd80 | 2015-04-13 12:21:07 +0300 | [diff] [blame] | 190 | _, ax1 = plt.subplots() |
Yulia Portnova | 407ca95 | 2015-04-10 10:38:15 +0300 | [diff] [blame] | 191 | |
koder aka kdanilov | 652cd80 | 2015-04-13 12:21:07 +0300 | [diff] [blame] | 192 | ax1.plot(concurence, iops_or_bw_v) |
| 193 | ax1.errorbar(concurence, iops_or_bw_v, iops_or_bw_dev_v, |
| 194 | linestyle='None', |
| 195 | label="iops_or_bw_v", |
| 196 | marker="*") |
| 197 | |
| 198 | # ynew = approximate_line(ax, ay, ax, True) |
| 199 | |
| 200 | ax2 = ax1.twinx() |
| 201 | |
| 202 | ax2.errorbar(concurence, |
| 203 | [med_dev(lat)[0] / 1000 for lat in latv], |
| 204 | [med_dev(lat)[1] / 1000 for lat in latv], |
| 205 | linestyle='None', |
| 206 | label="iops_or_bw_v", |
| 207 | marker="*") |
| 208 | ax2.plot(concurence, [med_dev(lat)[0] / 1000 for lat in latv]) |
| 209 | plt.show() |
| 210 | exit(0) |
| 211 | |
| 212 | # bw_only = [] |
| 213 | |
| 214 | # for conc, _, _, (bw, _) in data: |
| 215 | # bw_only.append(bw) |
| 216 | # bw_d_per_th.append((bw / conc, 0)) |
| 217 | |
| 218 | # lines = [(zip(*lat_d)[0], 'msec', 'rr', 'lat'), (bw_sum, None, None, 'bw_sum')] |
| 219 | |
| 220 | # chart_url = charts.render_vertical_bar( |
| 221 | # chart_name, ["bw"], [bw_d_per_th], label_x="KBps", |
| 222 | # scale_x=ordered_data.keys(), |
| 223 | # lines=lines) |
| 224 | |
| 225 | # charts_url.append(str(chart_url)) |
| 226 | |
Yulia Portnova | 407ca95 | 2015-04-10 10:38:15 +0300 | [diff] [blame] | 227 | render_html(charts_url, "results.html") |
koder aka kdanilov | 652cd80 | 2015-04-13 12:21:07 +0300 | [diff] [blame] | 228 | |
| 229 | |
| 230 | def main(args): |
| 231 | make_io_report('/tmp/report', load_files(args[1:])) |
Yulia Portnova | 407ca95 | 2015-04-10 10:38:15 +0300 | [diff] [blame] | 232 | return 0 |
| 233 | |
| 234 | |
| 235 | if __name__ == '__main__': |
koder aka kdanilov | 652cd80 | 2015-04-13 12:21:07 +0300 | [diff] [blame] | 236 | exit(main(sys.argv)) |