blob: 381d9ff8c639a68a2be30b7d8162cb7056cdbc4f [file] [log] [blame]
kdanylov aka koder3a9e5db2017-05-09 20:00:44 +03001import logging
kdanylov aka koder84de1e42017-05-22 14:00:07 +03002from typing import cast, Iterator, List, Union
kdanylov aka koder3a9e5db2017-05-09 20:00:44 +03003
kdanylov aka koder150b2192017-04-01 16:53:01 +03004import numpy
5
6from cephlib.common import float2str
kdanylov aka koder84de1e42017-05-22 14:00:07 +03007from cephlib.texttable import Texttable
kdanylov aka koderb0833332017-05-13 20:39:17 +03008from cephlib.statistic import calc_norm_stat_props, calc_histo_stat_props
kdanylov aka koder150b2192017-04-01 16:53:01 +03009
kdanylov aka koder150b2192017-04-01 16:53:01 +030010from .stage import Stage, StepOrder
11from .test_run_class import TestRun
kdanylov aka koder84de1e42017-05-22 14:00:07 +030012from .result_classes import SuiteConfig
kdanylov aka koder150b2192017-04-01 16:53:01 +030013from .suits.io.fio import FioTest
kdanylov aka koder84de1e42017-05-22 14:00:07 +030014from .suits.io.fio_job import FioJobParams
kdanylov aka koder150b2192017-04-01 16:53:01 +030015from .suits.io.fio_hist import get_lat_vals
kdanylov aka koder3a9e5db2017-05-09 20:00:44 +030016from .data_selectors import get_aggregated
kdanylov aka koder84de1e42017-05-22 14:00:07 +030017from .result_storage import IWallyStorage
kdanylov aka koder3a9e5db2017-05-09 20:00:44 +030018
19
20logger = logging.getLogger("wally")
21
kdanylov aka koder150b2192017-04-01 16:53:01 +030022
kdanylov aka koder84de1e42017-05-22 14:00:07 +030023
24console_report_headers = ["Description", "IOPS ~ Dev", "BW, MiBps", 'Skew/Kurt', 'lat med, ms', 'lat 95, ms']
25console_report_align = ['l', 'r', 'r', 'r', 'r', 'r']
26
27def get_console_report_table(suite: SuiteConfig, rstorage: IWallyStorage) -> List[Union[List[str], Texttable.HLINE]]:
28 table = [] # type: List[Union[List[str], Texttable.HLINE]]
29 prev_params = None
30 for job in sorted(rstorage.iter_job(suite), key=lambda job: job.params):
31 fparams = cast(FioJobParams, job.params)
32 fparams['qd'] = None
33
34 if prev_params is not None and fparams.char_tpl != prev_params:
35 table.append(Texttable.HLINE)
36
37 prev_params = fparams.char_tpl
38
39 bw_ts = get_aggregated(rstorage, suite.storage_id, job.storage_id, metric='bw',
40 trange=job.reliable_info_range_s)
41 props = calc_norm_stat_props(bw_ts)
42 avg_iops = props.average // job.params.params['bsize']
43 iops_dev = props.deviation // job.params.params['bsize']
44
45 lat_ts = get_aggregated(rstorage, suite.storage_id, job.storage_id, metric='lat',
46 trange=job.reliable_info_range_s)
47 bins_edges = numpy.array(get_lat_vals(lat_ts.data.shape[1]), dtype='float32') / 1000 # convert us to ms
48 lat_props = calc_histo_stat_props(lat_ts, bins_edges)
49 table.append([job.params.summary,
50 "{:>6s} ~ {:>6s}".format(float2str(avg_iops), float2str(iops_dev)),
51 float2str(props.average / 1024), # Ki -> Mi
52 "{:>5.1f}/{:>5.1f}".format(props.skew, props.kurt),
53 float2str(lat_props.perc_50), float2str(lat_props.perc_95)])
54 return table
55
56
kdanylov aka koder150b2192017-04-01 16:53:01 +030057class ConsoleReportStage(Stage):
58
59 priority = StepOrder.REPORT
60
61 def run(self, ctx: TestRun) -> None:
kdanylov aka koderb0833332017-05-13 20:39:17 +030062 for suite in ctx.rstorage.iter_suite(FioTest.name):
kdanylov aka koder84de1e42017-05-22 14:00:07 +030063 table = Texttable(max_width=200)
64 table.set_deco(Texttable.VLINES | Texttable.BORDER | Texttable.HEADER)
kdanylov aka koderb0833332017-05-13 20:39:17 +030065 tbl = ctx.rstorage.get_txt_report(suite)
kdanylov aka koder3a9e5db2017-05-09 20:00:44 +030066 if tbl is None:
kdanylov aka koder84de1e42017-05-22 14:00:07 +030067 table.header(console_report_headers)
68 table.set_cols_align(console_report_align)
69 for line in get_console_report_table(suite, ctx.rstorage):
70 table.add_row(line)
kdanylov aka koder3a9e5db2017-05-09 20:00:44 +030071 tbl = table.draw()
kdanylov aka koderb0833332017-05-13 20:39:17 +030072 ctx.rstorage.put_txt_report(suite, tbl)
kdanylov aka koder3a9e5db2017-05-09 20:00:44 +030073 print(tbl)