blob: 649032942b5d0e9b2c0da0137bcd2c9590bbd86d [file] [log] [blame]
kdanylov aka koder3a9e5db2017-05-09 20:00:44 +03001import logging
2
3
kdanylov aka koder150b2192017-04-01 16:53:01 +03004import numpy
5
6from cephlib.common import float2str
kdanylov aka koderb0833332017-05-13 20:39:17 +03007from cephlib import texttable
8from 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
12from .suits.io.fio import FioTest
kdanylov aka koder150b2192017-04-01 16:53:01 +030013from .suits.io.fio_hist import get_lat_vals
kdanylov aka koder3a9e5db2017-05-09 20:00:44 +030014from .data_selectors import get_aggregated
15
16
17logger = logging.getLogger("wally")
18
kdanylov aka koder150b2192017-04-01 16:53:01 +030019
20class ConsoleReportStage(Stage):
21
22 priority = StepOrder.REPORT
23
24 def run(self, ctx: TestRun) -> None:
kdanylov aka koderb0833332017-05-13 20:39:17 +030025 for suite in ctx.rstorage.iter_suite(FioTest.name):
kdanylov aka koder150b2192017-04-01 16:53:01 +030026 table = texttable.Texttable(max_width=200)
27
kdanylov aka koderb0833332017-05-13 20:39:17 +030028 tbl = ctx.rstorage.get_txt_report(suite)
kdanylov aka koder3a9e5db2017-05-09 20:00:44 +030029 if tbl is None:
30 table.header(["Description", "IOPS ~ Dev", "BW, MiBps", 'Skew/Kurt', 'lat med, ms', 'lat 95, ms'])
31 table.set_cols_align(('l', 'r', 'r', 'r', 'r', 'r'))
kdanylov aka koder150b2192017-04-01 16:53:01 +030032
kdanylov aka koderb0833332017-05-13 20:39:17 +030033 for job in sorted(ctx.rstorage.iter_job(suite), key=lambda job: job.params):
34 bw_ts = get_aggregated(ctx.rstorage, suite.storage_id, job.storage_id, metric='bw',
35 trange=job.reliable_info_range_s)
kdanylov aka koder3a9e5db2017-05-09 20:00:44 +030036 props = calc_norm_stat_props(bw_ts)
37 avg_iops = props.average // job.params.params['bsize']
38 iops_dev = props.deviation // job.params.params['bsize']
kdanylov aka koder150b2192017-04-01 16:53:01 +030039
kdanylov aka koderb0833332017-05-13 20:39:17 +030040 lat_ts = get_aggregated(ctx.rstorage, suite.storage_id, job.storage_id, metric='lat',
41 trange=job.reliable_info_range_s)
kdanylov aka koder3a9e5db2017-05-09 20:00:44 +030042 bins_edges = numpy.array(get_lat_vals(lat_ts.data.shape[1]), dtype='float32') / 1000 # convert us to ms
43 lat_props = calc_histo_stat_props(lat_ts, bins_edges)
44 table.add_row([job.params.summary,
45 "{} ~ {}".format(float2str(avg_iops), float2str(iops_dev)),
46 float2str(props.average / 1024), # Ki -> Mi
47 "{}/{}".format(float2str(props.skew), float2str(props.kurt)),
48 float2str(lat_props.perc_50), float2str(lat_props.perc_95)])
kdanylov aka koder150b2192017-04-01 16:53:01 +030049
kdanylov aka koder3a9e5db2017-05-09 20:00:44 +030050 tbl = table.draw()
kdanylov aka koderb0833332017-05-13 20:39:17 +030051 ctx.rstorage.put_txt_report(suite, tbl)
kdanylov aka koder3a9e5db2017-05-09 20:00:44 +030052 print(tbl)