From f8ff1d82fdf41ba1bce0b3665738abdd64245c40 Mon Sep 17 00:00:00 2001 From: Bas Nijholt <basnijholt@gmail.com> Date: Fri, 2 Nov 2018 11:41:09 +0100 Subject: [PATCH] report 0% overhead when none of the function results have returned Previously it reported 100% which is not a good estimate either. --- adaptive/runner.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/adaptive/runner.py b/adaptive/runner.py index 1f793467..44fba35d 100644 --- a/adaptive/runner.py +++ b/adaptive/runner.py @@ -180,6 +180,10 @@ class BaseRunner(metaclass=abc.ABCMeta): but is a rough rule of thumb. """ t_function = self._elapsed_function_time + if t_function == 0: + # When no function is done executing, the overhead cannot + # reliably be determined, so 0 is the best we can do. + return 0 t_total = self.elapsed_time() return (1 - t_function / t_total) * 100 @@ -426,7 +430,6 @@ class AsyncRunner(BaseRunner): overhead of the executor. Essentially, this is ``100 * (1 - total_elapsed_function_time / self.elapsed_time())``. - Notes ----- This runner can be used when an async function (defined with -- GitLab