You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 64a58d6
Browse filesBrowse the repository at this point in the historyBrowse files
authored
perf(tests): cut the unit test suite from 123s to 78s (#4966)
Profiling `--quick` by wrapping time.sleep/asyncio.sleep showed 38s of its
123s was spent literally asleep, and most of the rest of the hot spots were
one avoidable cost: parsing multi-megabyte debug dumps with PyYAML's
pure-Python parser.
Production changes:
- read_debug_yaml() now loads through libyaml's CLoader. It pairs the C
parser with the very same (unsafe) Constructor yaml.unsafe_load uses, so
the Python-object tags these dumps carry still load and the result is
identical - verified equal on the committed cases - about 6x faster on a
5MB dump. Falls back to the pure-Python loader when PyYAML was not built
with libyaml. This speeds up real --debug_file replays too, not just tests.
- ComponentBase.wait_api_started() polls every 0.1s instead of every 1s.
Components come up in milliseconds, so the old cadence spent nearly the
whole wait asleep after the component was already live. The loop is now
bounded by a monotonic deadline rather than by counting ticks, so `timeout`
stays honest in seconds however often the flag is checked.
Test changes - each of these waited on a real delay that no assertion
depended on:
- test_givtcp_component: _make_component() records the REST retry waits
instead of taking them, mirroring test_givtcp_rest.py's _client. One test
asserting a write never verifies was walking the whole 5 x 2s ladder.
- test_alphaess_api: MockAlphaESS was inheriting initialize()'s real 2s
api_delay, and the transport-failure test served the full retry backoff.
- test_ohme / test_ge_cloud: skip the retry wait and the rate-limit pacing,
as the neighbouring tests in those files already do.
- test_chat: _fast_confirm_poll() shortens (not removes) await_confirmation's
0.2s poll for tests whose background thread answers immediately.
Tooling:
- --quick's help named three tests that are not marked slow while the four
that are went unmentioned; it is now derived from TEST_REGISTRY so it
cannot drift again.
- Each test logs a wall-clock start/end stamp, so a run that stalls can be
read straight from the log by its unmatched start stamp.
debug_cases 22.56s -> 12.01s random 27.94s -> 22.44s
givtcp_component 10.04s -> 0.03s web_if 3.37s -> 1.57s
alphaess_api 7.05s -> 0.04s chat 3.50s -> 2.52s
window_cache 7.47s -> 2.09s debug_yaml_scope 2.04s -> 0.19s
ge_cloud 1.67s -> 1.04s ohme 1.01s -> 0.01s
Sleeps left in place are the ones that are themselves the assertion - the
tests proving the event loop is not blocked, and annual_job's real
subprocesses.
Co-authored-by: CI <ci@example.com>
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
Copy file name to clipboardExpand all lines: apps/predbat/unit_test.py
+14-7Lines changed: 14 additions & 7 deletions
Original file line number
Diff line number
Diff line change
@@ -749,7 +749,10 @@ def main():
749
749
parser.add_argument("--test", "-t", action="append", help="Run specific test(s) by name (can be used multiple times, use --list to see available tests)")
0 commit comments