提交 7bece680 编写于 作者: L Lukáš Doktor

avocado.core.multiplexer: Optimization

Let's use comprehensions for generating pools and itertools to flatten
the list of variants. This improves the performance ~10%.
Signed-off-by: NLukáš Doktor <ldoktor@redhat.com>
上级 334e1215
......@@ -47,10 +47,7 @@ class MuxTree(object):
if node.is_leaf:
self.pools.append(node)
else:
pools = []
for mux_child in node.children:
pools.append(MuxTree(mux_child))
self.pools.append(pools)
self.pools.append([MuxTree(child) for child in node.children])
@staticmethod
def _iter_mux_leaves(node):
......@@ -75,19 +72,12 @@ class MuxTree(object):
if isinstance(pool, list):
pools.append(itertools.chain(*pool))
else:
pools.append([pool])
pools.append(pool)
pools = itertools.product(*pools)
while True:
# TODO: Implement 2nd level filteres here
# TODO: This part takes most of the time, optimize it
dirty = pools.next()
ret = []
for pool in dirty:
if isinstance(pool, list):
ret.extend(pool)
else:
ret.append(pool)
yield ret
yield list(itertools.chain(*pools.next()))
def yaml2tree(input_yamls, filter_only=None, filter_out=None,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册