koder aka kdanilov | 7f59d56 | 2016-12-26 01:34:23 +0200 | [diff] [blame] | 1 | # put all result preprocessing here |
| 2 | # selection, aggregation |
koder aka kdanilov | ffaf48d | 2016-12-27 02:25:29 +0200 | [diff] [blame] | 3 | |
koder aka kdanilov | 108ac36 | 2017-01-19 20:17:16 +0200 | [diff] [blame] | 4 | from io import BytesIO |
koder aka kdanilov | f286517 | 2016-12-30 03:35:11 +0200 | [diff] [blame] | 5 | import logging |
koder aka kdanilov | 108ac36 | 2017-01-19 20:17:16 +0200 | [diff] [blame] | 6 | from typing import Any |
koder aka kdanilov | f286517 | 2016-12-30 03:35:11 +0200 | [diff] [blame] | 7 | |
koder aka kdanilov | ffaf48d | 2016-12-27 02:25:29 +0200 | [diff] [blame] | 8 | from .stage import Stage, StepOrder |
| 9 | from .test_run_class import TestRun |
koder aka kdanilov | f286517 | 2016-12-30 03:35:11 +0200 | [diff] [blame] | 10 | from .statistic import calc_norm_stat_props, calc_histo_stat_props |
koder aka kdanilov | 108ac36 | 2017-01-19 20:17:16 +0200 | [diff] [blame] | 11 | from .result_classes import StatProps, DataSource, TimeSeries |
| 12 | from .hlstorage import ResultStorage |
koder aka kdanilov | f286517 | 2016-12-30 03:35:11 +0200 | [diff] [blame] | 13 | from .suits.io.fio_hist import get_lat_vals, expected_lat_bins |
koder aka kdanilov | 108ac36 | 2017-01-19 20:17:16 +0200 | [diff] [blame] | 14 | from .suits.io.fio import FioTest |
koder aka kdanilov | f286517 | 2016-12-30 03:35:11 +0200 | [diff] [blame] | 15 | from .utils import StopTestError |
| 16 | |
koder aka kdanilov | f286517 | 2016-12-30 03:35:11 +0200 | [diff] [blame] | 17 | import matplotlib |
koder aka kdanilov | f286517 | 2016-12-30 03:35:11 +0200 | [diff] [blame] | 18 | matplotlib.use('svg') |
koder aka kdanilov | f286517 | 2016-12-30 03:35:11 +0200 | [diff] [blame] | 19 | import matplotlib.pyplot as plt |
| 20 | |
koder aka kdanilov | ffaf48d | 2016-12-27 02:25:29 +0200 | [diff] [blame] | 21 | |
koder aka kdanilov | 108ac36 | 2017-01-19 20:17:16 +0200 | [diff] [blame] | 22 | logger = logging.getLogger("wally") |
| 23 | |
| 24 | |
koder aka kdanilov | ffaf48d | 2016-12-27 02:25:29 +0200 | [diff] [blame] | 25 | class CalcStatisticStage(Stage): |
| 26 | priority = StepOrder.TEST + 1 |
| 27 | |
| 28 | def run(self, ctx: TestRun) -> None: |
koder aka kdanilov | 108ac36 | 2017-01-19 20:17:16 +0200 | [diff] [blame] | 29 | rstorage = ResultStorage(ctx.storage) |
koder aka kdanilov | ffaf48d | 2016-12-27 02:25:29 +0200 | [diff] [blame] | 30 | |
koder aka kdanilov | 108ac36 | 2017-01-19 20:17:16 +0200 | [diff] [blame] | 31 | for suite in rstorage.iter_suite(FioTest.name): |
| 32 | for job in rstorage.iter_job(suite): |
koder aka kdanilov | f286517 | 2016-12-30 03:35:11 +0200 | [diff] [blame] | 33 | results = {} |
koder aka kdanilov | 108ac36 | 2017-01-19 20:17:16 +0200 | [diff] [blame] | 34 | for ts in rstorage.iter_ts(suite, job): |
| 35 | if ts.source.sensor == 'lat': |
koder aka kdanilov | f286517 | 2016-12-30 03:35:11 +0200 | [diff] [blame] | 36 | if ts.second_axis_size != expected_lat_bins: |
| 37 | logger.error("Sensor %s.%s on node %s has" + |
| 38 | "second_axis_size=%s. Can only process sensors with second_axis_size=%s.", |
koder aka kdanilov | 108ac36 | 2017-01-19 20:17:16 +0200 | [diff] [blame] | 39 | ts.source.dev, ts.source.sensor, ts.source.node_id, |
| 40 | ts.second_axis_size, expected_lat_bins) |
koder aka kdanilov | f286517 | 2016-12-30 03:35:11 +0200 | [diff] [blame] | 41 | continue |
| 42 | ts.bins_edges = get_lat_vals(ts.second_axis_size) |
koder aka kdanilov | 108ac36 | 2017-01-19 20:17:16 +0200 | [diff] [blame] | 43 | stat_prop = calc_histo_stat_props(ts) # type: StatProps |
koder aka kdanilov | ffaf48d | 2016-12-27 02:25:29 +0200 | [diff] [blame] | 44 | |
koder aka kdanilov | f286517 | 2016-12-30 03:35:11 +0200 | [diff] [blame] | 45 | elif ts.second_axis_size != 1: |
| 46 | logger.warning("Sensor %s.%s on node %s provide 2D data with " + |
| 47 | "ts.second_axis_size=%s. Can't process it.", |
koder aka kdanilov | 108ac36 | 2017-01-19 20:17:16 +0200 | [diff] [blame] | 48 | ts.source.dev, ts.source.sensor, ts.source.node_id, ts.second_axis_size) |
koder aka kdanilov | f286517 | 2016-12-30 03:35:11 +0200 | [diff] [blame] | 49 | continue |
koder aka kdanilov | ffaf48d | 2016-12-27 02:25:29 +0200 | [diff] [blame] | 50 | else: |
koder aka kdanilov | f286517 | 2016-12-30 03:35:11 +0200 | [diff] [blame] | 51 | stat_prop = calc_norm_stat_props(ts) |
koder aka kdanilov | ffaf48d | 2016-12-27 02:25:29 +0200 | [diff] [blame] | 52 | |
koder aka kdanilov | f286517 | 2016-12-30 03:35:11 +0200 | [diff] [blame] | 53 | raise StopTestError() |