Skip to content

Commit fc8e096

Browse files
gudnimghenrikbrixandersen
authored andcommitted
scripts: twister: minor speedup in apply_filters
Move a check to run earlier in a for-loop to minimize doing unnecessary work like creating TestInstance class instances. This is a very minor optimization when the number of testsuites are low. But starts to count when there are a lot of testsuites. Signed-off-by: Guðni Már Gilbert <gudni.m.g@gmail.com>
1 parent a1123c4 commit fc8e096

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

‎scripts/pylib/twister/twisterlib/testplan.py‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -889,6 +889,10 @@ def apply_filters(self, **kwargs):
889889
for itoolchain, plat in itertools.product(
890890
ts.integration_toolchains or [None], platform_scope
891891
):
892+
if (plat.arch == "unit") != (ts.type == "unit"):
893+
# Discard silently
894+
continue
895+
892896
if itoolchain:
893897
toolchain = itoolchain
894898
elif plat.arch in ['posix', 'unit']:
@@ -909,10 +913,6 @@ def apply_filters(self, **kwargs):
909913
if not force_platform and self.check_platform(plat,exclude_platform):
910914
instance.add_filter("Platform is excluded on command line.", Filters.CMD_LINE)
911915

912-
if (plat.arch == "unit") != (ts.type == "unit"):
913-
# Discard silently
914-
continue
915-
916916
if ts.modules and self.modules and not set(ts.modules).issubset(set(self.modules)):
917917
instance.add_filter(
918918
f"one or more required modules not available: {','.join(ts.modules)}",

0 commit comments

Comments
 (0)