diff options
author | Richard Purdie <richard.purdie@linuxfoundation.org> | 2024-11-22 16:17:19 +0000 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2024-11-23 14:44:54 +0000 |
commit | 41d39a282690df522162b9af48e3325a3a0b2acc (patch) | |
tree | 7bee58131f9586056c389c6ad683d558b726eb21 /scripts/lib/resulttool/resultutils.py | |
parent | fae3c13eb6ebc1da1e6bc2de3ee024d2bc2e990f (diff) | |
download | poky-41d39a282690df522162b9af48e3325a3a0b2acc.tar.gz |
resulttool: Trim the precision of duration information
The duration values have pointless amounts of precision. Removing some of the
least significant digits reduces result size and makes the results easier to read.
(From OE-Core rev: a789a2e6d97bb8efd663226a17db8d1ca6c1e40f)
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'scripts/lib/resulttool/resultutils.py')
-rw-r--r-- | scripts/lib/resulttool/resultutils.py | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/scripts/lib/resulttool/resultutils.py b/scripts/lib/resulttool/resultutils.py index 9cba8639a3..760e426de0 100644 --- a/scripts/lib/resulttool/resultutils.py +++ b/scripts/lib/resulttool/resultutils.py | |||
@@ -131,6 +131,22 @@ def strip_logs(results): | |||
131 | del newresults[res]['result']['ptestresult.sections'][i]['log'] | 131 | del newresults[res]['result']['ptestresult.sections'][i]['log'] |
132 | return newresults | 132 | return newresults |
133 | 133 | ||
134 | # For timing numbers, crazy amounts of precision don't make sense and just confuse | ||
135 | # the logs. For numbers over 1, trim to 3 decimal places, for numbers less than 1, | ||
136 | # trim to 4 significant digits | ||
137 | def trim_durations(results): | ||
138 | for res in results: | ||
139 | if 'result' not in results[res]: | ||
140 | continue | ||
141 | for entry in results[res]['result']: | ||
142 | if 'duration' in results[res]['result'][entry]: | ||
143 | duration = results[res]['result'][entry]['duration'] | ||
144 | if duration > 1: | ||
145 | results[res]['result'][entry]['duration'] = float("%.3f" % duration) | ||
146 | elif duration < 1: | ||
147 | results[res]['result'][entry]['duration'] = float("%.4g" % duration) | ||
148 | return results | ||
149 | |||
134 | def handle_cleanups(results): | 150 | def handle_cleanups(results): |
135 | # Remove pointless path duplication from old format reproducibility results | 151 | # Remove pointless path duplication from old format reproducibility results |
136 | for res2 in results: | 152 | for res2 in results: |
@@ -194,6 +210,7 @@ def save_resultsdata(results, destdir, fn="testresults.json", ptestjson=False, p | |||
194 | resultsout = results[res] | 210 | resultsout = results[res] |
195 | if not ptestjson: | 211 | if not ptestjson: |
196 | resultsout = strip_logs(results[res]) | 212 | resultsout = strip_logs(results[res]) |
213 | trim_durations(resultsout) | ||
197 | handle_cleanups(resultsout) | 214 | handle_cleanups(resultsout) |
198 | with open(dst, 'w') as f: | 215 | with open(dst, 'w') as f: |
199 | f.write(json.dumps(resultsout, sort_keys=True, indent=1)) | 216 | f.write(json.dumps(resultsout, sort_keys=True, indent=1)) |