mirror of
https://github.com/esphome/esphome.git
synced 2026-09-02 02:56:01 +00:00
[ci] Always print top import-time offenders, not just on regression
Seeing the top contributors every run — regression or not — gives reviewers and future-PR authors a running reference for which imports are currently most expensive. That's the data we need to prioritize lazy-import refactors, so there's no reason to hide it on pass.
This commit is contained in:
+23
-18
@@ -146,27 +146,32 @@ def cmd_check(args: argparse.Namespace) -> int:
|
||||
f"measured {TARGET_MODULE}: {_format_us(measured)} "
|
||||
f"(budget {_format_us(baseline)} + {margin_pct}% = {_format_us(ceiling)})"
|
||||
)
|
||||
passed = measured <= ceiling
|
||||
stream = sys.stdout if passed else sys.stderr
|
||||
|
||||
if measured <= ceiling:
|
||||
if passed:
|
||||
print(summary)
|
||||
return 0
|
||||
else:
|
||||
print(
|
||||
f"REGRESSION: `import {TARGET_MODULE}` took {_format_us(measured)}, "
|
||||
f"exceeding the budget of {_format_us(baseline)} + {margin_pct}% "
|
||||
f"({_format_us(ceiling)}).",
|
||||
file=stream,
|
||||
)
|
||||
|
||||
print(
|
||||
f"REGRESSION: `import {TARGET_MODULE}` took {_format_us(measured)}, "
|
||||
f"exceeding the budget of {_format_us(baseline)} + {margin_pct}% "
|
||||
f"({_format_us(ceiling)}).\n"
|
||||
f"Top import-time offenders (by self time):",
|
||||
file=sys.stderr,
|
||||
)
|
||||
_print_offenders_table(top_offenders(har, OFFENDERS_TOP_N), sys.stderr)
|
||||
print(
|
||||
"\nIf this regression is intentional, regenerate the budget with:\n"
|
||||
" script/check_import_time.py --update\n"
|
||||
"Otherwise, consider making the new import lazy "
|
||||
"(import inside the function that uses it).",
|
||||
file=sys.stderr,
|
||||
)
|
||||
return 1
|
||||
print("\nTop import-time offenders (by self time):", file=stream)
|
||||
_print_offenders_table(top_offenders(har, OFFENDERS_TOP_N), stream)
|
||||
|
||||
if not passed:
|
||||
print(
|
||||
"\nIf this regression is intentional, regenerate the budget with:\n"
|
||||
" script/check_import_time.py --update\n"
|
||||
"Otherwise, consider making the new import lazy "
|
||||
"(import inside the function that uses it).",
|
||||
file=stream,
|
||||
)
|
||||
return 1
|
||||
return 0
|
||||
|
||||
|
||||
def cmd_update(args: argparse.Namespace) -> int:
|
||||
|
||||
Reference in New Issue
Block a user