summaryrefslogtreecommitdiff
path: root/extra/usb_power/stats_manager.py
Commit message (Collapse)AuthorAgeFilesLines
* pylintrc: Copy Chromium OS platform2's configCraig Hesling2021-08-021-0/+4
| | | | | | | | | | | | | | | | | | | | This requests that cros lint (and repo upload hook) use the new Chromium OS 4 space indent policy. Since legacy python scripts still use 2 space, I added pylint ignore statements to the individual files to disable indentation checking. Note: There are still valid pylint errors in some of these legacy scripts. BRANCH=none BUG=none TEST=cros lint util/*.py Signed-off-by: Craig Hesling <hesling@chromium.org> Change-Id: I439f5a87bc50f1f43a4996e574bbc0626922a88e Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3064761 Reviewed-by: Mike Frysinger <vapier@chromium.org> Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
* stats_manager: formatting fix for md file outputRuben Rodriguez Buchillon2021-01-211-2/+3
| | | | | | | | | | | | | | | | | Minor formatting fix to make sure that .md files are \n terminated. Also a small change in the way we name the logger so that it derives the name directly from the class. BUG=b:174800621 BRANCH=None TEST=sudo servod -c kohaku_rev2_loc0.xml dut-power -t 3 // normal output Change-Id: I3e49068a7b0f3e8908fbcce6a13e083ce8e9216a Signed-off-by: Ruben Rodriguez Buchillon <coconutruben@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2594689 Reviewed-by: Mengqi Guo <mqg@chromium.org>
* stats_manager: add export to b/ friendly .mdRuben Rodriguez Buchillon2020-12-071-18/+88
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This change in addition to our copy/paste friendly textfile also outputs a buganizer markdown friendly .md summary of the results, to paste into bugs. BUG=b:174800621 BRANCH=None TEST=dut-power -t 3 Storing .md summaries at: [...]/S?_20201204-104756/onboard_summary.md cat [...]/S?_20201204-104756/onboard_summary.md **Onboard INA** |NAME|COUNT|MEAN|STDDEV|MAX|MIN| |-|-:|-:|-:|-:|-:| |LCD_BL_VOUT_mw|3|0.00|0.00|0.00|0.00| |PP1200_BRIJ_mw|3|0.00|0.00|0.00|0.00| |PP1200_TCPC_C0_mw|3|0.00|0.00|0.00|0.00| |PP1800_EC_mw|3|0.00|0.00|0.00|0.00| |PP1800_SENSORS_mw|3|0.00|0.00|0.00|0.00| |PP1800_VR_mw|3|0.00|0.00|0.00|0.00| |PP3300_A_R_mw|3|0.00|0.00|0.00|0.00| |PP3300_EC_STBY_mw|3|0.00|0.00|0.00|0.00| |PP3300_EC_mw|3|0.00|0.00|0.00|0.00| |PP3300_H1_mw|3|0.00|0.00|0.00|0.00| |PP3300_HUB_mw|3|0.00|0.00|0.00|0.00| |PP3300_PD_A_mw|3|0.00|0.00|0.00|0.00| |PP3300_PD_EC_mw|3|0.00|0.00|0.00|0.00| |PP3300_TCPC_C0_mw|3|0.00|0.00|0.00|0.00| |PP5000_A_mw|3|0.00|0.00|0.00|0.00| |PPVAR_BAT_R_mw|3|0.00|0.00|0.00|0.00| |PPVAR_BAT_mw|3|0.00|0.00|0.00|0.00| TEST=pytest stats_manager_unittest.py 21 passed TEST=python2 -m py.test stats_manager_unittest.py 21 passed Change-Id: I94e2d00721e744614838992604cd7a3124c0e39f Signed-off-by: Ruben Rodriguez Buchillon <coconutruben@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2573736 Reviewed-by: Puthikorn Voravootivat <puthik@chromium.org>
* usb_power: Migrate stats_manager.py to python2/3 compatibleYilin Yang2020-09-241-7/+9
| | | | | | | | | | | | BUG=chromium:1031705 BRANCH=master TEST=`python3 stats_manager_unittest.py` pass TEST=`python2 stats_manager_unittest.py` pass Signed-off-by: kerker <kerker@chromium.org> Change-Id: I4414eb99519ae43b1d94cebaea849a9b98beeb5d Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2422062 Reviewed-by: Hung-Te Lin <hungte@chromium.org>
* stats_manager: more informative nan summary outputRuben Rodriguez Buchillon2018-08-011-1/+14
| | | | | | | | | | | | | | | | | Now for the formatted output string, if any value a domain is NaN, the domains gets tagged with a * and a help text gets added at the end of the summary to highlight this issue. CQ-DEPEND=CL:1140025 BRANCH=None BUG=chromium:806146, chromium:760267 TEST=unit tests added & pass Change-Id: I30791053bb1645065fa2bfd8305cc840a4a88031 Signed-off-by: Ruben Rodriguez Buchillon <coconutruben@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1140032 Reviewed-by: Mengqi Guo <mqg@chromium.org>
* stats_manager: accept_nan supportRuben Rodriguez Buchillon2018-08-011-11/+20
| | | | | | | | | | | | | | | | | | This CL introduces a flag to StatsManager that allows for 'NaN' values to be recorded inside StatsManager. The motivation here is that if a sample fails to record it might be more desirable to record a 'NaN' than to just skip the sample, to keep timelines correct, and to not hide errors in the test-run. Also adds necessary tests for that behavior. BRANCH=None BUG=chromium:806146, chromium:760267 TEST=unit tests still pass Change-Id: If17b7f52ba4a05e9e007c73bfa5d667fe36b74b3 Signed-off-by: Ruben Rodriguez Buchillon <coconutruben@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1140031 Reviewed-by: Mengqi Guo <mqg@chromium.org>
* stats_manager: add title banner pretty-printingRuben Rodriguez Buchillon2018-08-011-6/+24
| | | | | | | | | | | | | | If a title is supplied it now gets printed centralized on top of the summary when calling SummaryToString. BRANCH=None BUG=chromium:760267 TEST=unit tests are passing Change-Id: I7c59896ebac82d2ee7b632fd18350b9b4fff2c24 Signed-off-by: Ruben Rodriguez Buchillon <coconutruben@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1140030 Reviewed-by: Mengqi Guo <mqg@chromium.org>
* stats_manager: Avoid losing dataRuben Rodriguez Buchillon2018-08-011-5/+49
| | | | | | | | | | | | | | | | | | | | | | | | | | | In the case of multiple StatsManager, we might get data clobbered. That's particularly bad on long-running tests. This CL introduces two methods to make sure output files are unique in a directory. (1) on init, the user can supply a StatsManagerID (smid) that will be prepended to all output files. E.g. if the smid is 'ec' the summary will be stored at ec_summary.txt (2) should that fail because multiple StatsManagers are using the same smid supplied (or none were supplied) a simple file rotation is done where an integer suffix keeps getting incremented until the filename is unique. E.g. if summary.txt already exists, then summary1.txt will be created. This is not threadsafe at all so the user still have to use some caution to avoid clobbering their own data. BRANCH=None BUG=chromium:760267 TEST=unit tests still all pass Change-Id: I6cc083259362ee20e0242b94ac7cbb1228a06a7a Signed-off-by: Ruben Rodriguez Buchillon <coconutruben@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1140029 Reviewed-by: Mengqi Guo <mqg@chromium.org>
* stats_manager: StatsManager returns file save locationsRuben Rodriguez Buchillon2018-08-011-0/+14
| | | | | | | | | | | | | | | | | Some test code currently duplicates knowledge by telling StatsManager where to save a file and then having to figure out where it stored the files again. This CL has StatsManager return the save locations to simplfy code. This potentially allows for informative logging on where information was stored. BRANCH=None BUG=chromium:760267 TEST=unit tests still pass Change-Id: I54b5873a4a3ddade9a73da0792c1947445759ad4 Signed-off-by: Ruben Rodriguez Buchillon <coconutruben@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1140028 Reviewed-by: Mengqi Guo <mqg@chromium.org>
* stats_manager: replace prefixes with flags in StatsManagerRuben Rodriguez Buchillon2018-07-311-32/+34
| | | | | | | | | | | | | | | | | | | | | | | | | StatsManager right now uses a '__' prefix to indicate that sample_msecs should be the first key in the summary. Additionally, there is a NOSHOW_PREFIX to potentially hide rails in the summary. This CL replaces that approach with constructor arguments to feed into the StatsManager what rails to hide, and the order to print a summary. This results in cleaner code, and less information leakage across classes as hiding & sorting becomes an implementation detail. It also adds two new unit tests to StatsManagerTest to verify this behavior works as intended. As a nit this CL also replaces AddValue with AddSample as Sample is more descriptive for the use-cases. BRANCH=None BUG=chromium:760267 TEST=manual testing, same output as before, and unittests still pass Change-Id: I52ca0d85c4600691fce8d4c74fd2a81fc4aa440f Signed-off-by: Ruben Rodriguez Buchillon <coconutruben@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1140027 Reviewed-by: Mengqi Guo <mqg@chromium.org>
* stats_manager: remove expliting printing from stats_managerRuben Rodriguez Buchillon2018-07-311-16/+10
| | | | | | | | | | | | | | | | | | StatsManager is a library shared across some modules. It shouldn't print anything itself, but rather use logging & return a formatted summary that can be printed. Also take this opportunity to replace majority of explicit print calls in powerlog with logger module. BRANCH=None BUG=chromium:760267 TEST=manual testing, output as expected still for powerlog Change-Id: I0ed2ccaa45bbd1261119a1446110beadb075c1a2 Signed-off-by: Ruben Rodriguez Buchillon <coconutruben@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1140026 Reviewed-by: Mengqi Guo <mqg@chromium.org>
* stats_manager: prepare StatsManager to be a utility used in hdctoolsRuben Rodriguez Buchillon2018-07-271-7/+52
| | | | | | | | | | | | | | | | | | This is the first CL in a series of CLs to start using StatsManager in servo/hdctools (package depends on ec-devutils, as in this package). This CL: - beefs up StatsManager to handle unavailable units more gracefully - adds a few more tests to stats_manager_unittest.py - adds some minor unit testing for powerlog's file retrieval logic BRANCH=None BUG=chromium:760267 TEST=manual testing, unit tests still pass, powerlog still works Change-Id: Ifcdfcc482008484fbc21326c6f087ebf466c3e74 Signed-off-by: Ruben Rodriguez Buchillon <coconutruben@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1140025 Reviewed-by: Mengqi Guo <mqg@chromium.org>
* sweetberry: fix stats_manager and refactorMengqi Guo2018-04-271-12/+41
| | | | | | | | | | | | | | | | | | | | | | This CL updates stats_manager to match the new functionalities in powerlog.py and refactors powerlog.py to more easily find config files and print timestamps in seconds since epoch. The unit test for stats_manager is also updated accordingly. BUG=b:72973433 BRANCH=None TEST=powerlog -b nami_rev0_loc.board -c nami_rev0_loc.scenario \ --print_stats --save_stats /tmp --save_stats_json /tmp \ --save_raw_data /tmp --mW and looking at the printed data python -m unittest stats_manager_unittest CQ-DEPEND=CL:1003522 Change-Id: Ic6e4aadfcd3ad245572788094ee3d3a30106044c Signed-off-by: Mengqi Guo <mqg@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1002546 Reviewed-by: Todd Broch <tbroch@chromium.org>
* sweetberry: print MEAN in json formatMengqi Guo2017-12-051-0/+19
| | | | | | | | | | | | | | | | | | | | | | | | This CL adds the flag --save_stats_json which prints the MEAN of sweetberry readings into json format. Corresponding unit test has been added too. Printing just the MEAN in json format makes it easier to read it back in power_telemetry_logger, which uploads the stats to the dashboard. This CL is part of the effort to start sweetberry measurements while running power autotests. BRANCH=None BUG=b:68956240 TEST=./powerlog.py -b xxx.board -c xxx.scenario \ --save_stats_json [directory to store it] python -m unittest -v stats_manager_unittest Change-Id: I8274bcac21175f6c53184ced79b6ffe5e7d7a72a Signed-off-by: Mengqi Guo <mqg@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/807636 Reviewed-by: Nick Sanders <nsanders@chromium.org> Reviewed-by: Puthikorn Voravootivat <puthik@chromium.org> Reviewed-by: Todd Broch <tbroch@chromium.org>
* sweetberry: calculate statistics for sweetberry readingsMengqi Guo2017-09-291-0/+137
This CL provides the tool to calculate statistics for sweetberry readings and present them in a clear & easy to read format. It also provides the flag to store raw data and statistics summary, should the need arise. There are also some code cleanup for powerlog.py. BRANCH=None BUG=b:35578707 TEST=./powerlog.py -b xxx.board -c xxx.scenario --print_stats \ --save_stats --save_raw_data python -m unittest -v stats_manager_unittest Change-Id: I4aa732756fe6512f37acfcb59b11d950101887d7 Signed-off-by: Mengqi Guo <mqg@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/667241 Reviewed-by: Nick Sanders <nsanders@chromium.org>