From 3205960c881a12294176ad1e345d356e85acc317 Mon Sep 17 00:00:00 2001 From: Jordan Yates Date: Sat, 6 Dec 2025 10:22:38 +1000 Subject: [PATCH 1/2] scripts: twisterlib: display testplan build duration Display how long it takes to build the testplan in the logs. This can be useful since the duration to bulid the plan can vary wildly depending on the arguments given. Without this information, it is difficult to tell (from CI logs) whether a long execution time is from actually building and running the tests, or just generating the testplan. For example, in a downstream repo: ``` ./zephyr/scripts/twister --integration -iv -T . --dry-run INFO - Building initial testsuite list... INFO - Built testsuite list in 10.58 seconds ``` vs ``` ./zephyr/scripts/twister --integration -iv -T . --dry-run \ --vendor nordic --vendor zephyr INFO - Building initial testsuite list... INFO - Built testsuite list in 201.01 seconds ``` Signed-off-by: Jordan Yates --- scripts/pylib/twister/twisterlib/testplan.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/scripts/pylib/twister/twisterlib/testplan.py b/scripts/pylib/twister/twisterlib/testplan.py index 699104a20e304..e418ab14ecaad 100755 --- a/scripts/pylib/twister/twisterlib/testplan.py +++ b/scripts/pylib/twister/twisterlib/testplan.py @@ -16,6 +16,7 @@ import re import subprocess import sys +import time from argparse import Namespace from collections import OrderedDict from itertools import islice @@ -830,6 +831,7 @@ def apply_filters(self, **kwargs): integration_mode_list = test_config_options.get('integration_mode', []) logger.info("Building initial testsuite list...") + build_list_start = time.time() keyed_tests = {} for _, ts in self.testsuites.items(): @@ -1220,6 +1222,9 @@ def apply_filters(self, **kwargs): change_skip_to_error_if_integration(self.options, inst) inst.add_missing_case_status(inst.status) + build_list_duration = time.time() - build_list_start + logger.info(f"Built testsuite list in {build_list_duration:.2f} seconds") + def _find_required_instance(self, required_app, instance: TestInstance) -> TestInstance | None: if req_platform := required_app.get("platform", None): platform = self.get_platform(req_platform) From 5e00e43d3e67b19dec74fdc9d543c43925855557 Mon Sep 17 00:00:00 2001 From: Jordan Yates Date: Sat, 6 Dec 2025 10:29:07 +1000 Subject: [PATCH 2/2] scripts: twisterlib: main: trim run duration Display the total run duration to two decimal points instead of ~14, similar to the other displayed timestamps. Signed-off-by: Jordan Yates --- scripts/pylib/twister/twisterlib/twister_main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/pylib/twister/twisterlib/twister_main.py b/scripts/pylib/twister/twisterlib/twister_main.py index ed935f6b92857..e851cda31aadc 100644 --- a/scripts/pylib/twister/twisterlib/twister_main.py +++ b/scripts/pylib/twister/twisterlib/twister_main.py @@ -182,7 +182,7 @@ def twister(options: argparse.Namespace, default_options: argparse.Namespace) -> if options.dry_run: duration = time.time() - start_time - logger.info(f"Completed in {duration} seconds") + logger.info(f"Completed in {duration:.2f} seconds") return 0 if options.short_build_path: