提交 2a072daf 编写于 作者: C Cleber Rosa

avocado/core/loader.py: make sure loaders are only registered once

Long story short, after taking a look at:

https://github.com/avocado-framework/avocado-vt/issues/322

I noticed that, on purpose, the VirtTestLoader class would be registered
both by `avocado_vt/plugins/vt.py` and avocado_vt/plugins/vt_list.py`.
The reasoning is simply to keep plugins independent, without depending
on each other.

But, it turns out the registering the loader on both places doubles the
time it takes to find VT tests. Without this patch:

$ /usr/bin/time ./scripts/avocado list > /dev/null
9.52user 0.17system 0:09.68elapsed 100%CPU (0avgtext+0avgdata 189528maxresident)k
0inputs+3744outputs (0major+63564minor)pagefaults 0swaps

With this patch:

$ /usr/bin/time ./scripts/avocado list > /dev/null
5.47user 0.13system 0:05.60elapsed 100%CPU (0avgtext+0avgdata 145716maxresident)k
0inputs+1920outputs (0major+51958minor)pagefaults 0swaps
Signed-off-by: NCleber Rosa <crosa@redhat.com>
上级 d11d1a9a
......@@ -102,7 +102,8 @@ class TestLoaderProxy(object):
def register_plugin(self, plugin):
try:
if issubclass(plugin, TestLoader):
self.registered_plugins.append(plugin)
if plugin not in self.registered_plugins:
self.registered_plugins.append(plugin)
else:
raise ValueError
except ValueError:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册