提交 2d041bcf 编写于 作者: A Ademar de Souza Reis Jr

core.runner: optimize the waiting for early test status

The loop that waits for the early test status has a call to sleep(0), which
turns it into an almost busy-loop. Changing it to sleep(0.01) consumes less CPU
without performance degradation (might actually make things run faster according
to my tests).

This change also makes it more consistent with the similar loop
for the actual test status.

On my machine, before this change running "passtest.py" 100 times would result
in almost 250000 calls to time.sleep(). After the change, the number gets down
to 600 (tracked via python cProfile module).
Signed-off-by: NAdemar de Souza Reis Jr <areis@redhat.com>
上级 2d08dda2
......@@ -142,6 +142,7 @@ class TestStatus(object):
:param timeout: timeout for early_state
:raise exceptions.TestError: On timeout/error
"""
step = 0.01
end = time.time() + timeout
while not self.early_status:
if not proc.is_alive():
......@@ -154,7 +155,7 @@ class TestStatus(object):
"avocado framework." % timeout)
os.kill(proc.pid, signal.SIGKILL)
raise exceptions.TestError(msg)
time.sleep(0)
time.sleep(step)
def _tick(self):
"""
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册