kdanylov aka koder | 3a9e5db | 2017-05-09 20:00:44 +0300 | [diff] [blame] | 1 | import logging |
| 2 | |
| 3 | |
kdanylov aka koder | 150b219 | 2017-04-01 16:53:01 +0300 | [diff] [blame] | 4 | import numpy |
| 5 | |
| 6 | from cephlib.common import float2str |
kdanylov aka koder | b083333 | 2017-05-13 20:39:17 +0300 | [diff] [blame] | 7 | from cephlib import texttable |
| 8 | from cephlib.statistic import calc_norm_stat_props, calc_histo_stat_props |
kdanylov aka koder | 150b219 | 2017-04-01 16:53:01 +0300 | [diff] [blame] | 9 | |
kdanylov aka koder | 150b219 | 2017-04-01 16:53:01 +0300 | [diff] [blame] | 10 | from .stage import Stage, StepOrder |
| 11 | from .test_run_class import TestRun |
| 12 | from .suits.io.fio import FioTest |
kdanylov aka koder | 150b219 | 2017-04-01 16:53:01 +0300 | [diff] [blame] | 13 | from .suits.io.fio_hist import get_lat_vals |
kdanylov aka koder | 3a9e5db | 2017-05-09 20:00:44 +0300 | [diff] [blame] | 14 | from .data_selectors import get_aggregated |
| 15 | |
| 16 | |
| 17 | logger = logging.getLogger("wally") |
| 18 | |
kdanylov aka koder | 150b219 | 2017-04-01 16:53:01 +0300 | [diff] [blame] | 19 | |
| 20 | class ConsoleReportStage(Stage): |
| 21 | |
| 22 | priority = StepOrder.REPORT |
| 23 | |
| 24 | def run(self, ctx: TestRun) -> None: |
kdanylov aka koder | b083333 | 2017-05-13 20:39:17 +0300 | [diff] [blame] | 25 | for suite in ctx.rstorage.iter_suite(FioTest.name): |
kdanylov aka koder | 150b219 | 2017-04-01 16:53:01 +0300 | [diff] [blame] | 26 | table = texttable.Texttable(max_width=200) |
| 27 | |
kdanylov aka koder | b083333 | 2017-05-13 20:39:17 +0300 | [diff] [blame] | 28 | tbl = ctx.rstorage.get_txt_report(suite) |
kdanylov aka koder | 3a9e5db | 2017-05-09 20:00:44 +0300 | [diff] [blame] | 29 | 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 koder | 150b219 | 2017-04-01 16:53:01 +0300 | [diff] [blame] | 32 | |
kdanylov aka koder | b083333 | 2017-05-13 20:39:17 +0300 | [diff] [blame] | 33 | 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 koder | 3a9e5db | 2017-05-09 20:00:44 +0300 | [diff] [blame] | 36 | 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 koder | 150b219 | 2017-04-01 16:53:01 +0300 | [diff] [blame] | 39 | |
kdanylov aka koder | b083333 | 2017-05-13 20:39:17 +0300 | [diff] [blame] | 40 | lat_ts = get_aggregated(ctx.rstorage, suite.storage_id, job.storage_id, metric='lat', |
| 41 | trange=job.reliable_info_range_s) |
kdanylov aka koder | 3a9e5db | 2017-05-09 20:00:44 +0300 | [diff] [blame] | 42 | 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 koder | 150b219 | 2017-04-01 16:53:01 +0300 | [diff] [blame] | 49 | |
kdanylov aka koder | 3a9e5db | 2017-05-09 20:00:44 +0300 | [diff] [blame] | 50 | tbl = table.draw() |
kdanylov aka koder | b083333 | 2017-05-13 20:39:17 +0300 | [diff] [blame] | 51 | ctx.rstorage.put_txt_report(suite, tbl) |
kdanylov aka koder | 3a9e5db | 2017-05-09 20:00:44 +0300 | [diff] [blame] | 52 | print(tbl) |