Skip to content

Commit f8ff1d8

Browse files
committed
report 0% overhead when none of the function results have returned
Previously it reported 100% which is not a good estimate either.
1 parent 008d47e commit f8ff1d8

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

adaptive/runner.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,10 @@ def overhead(self):
180180
but is a rough rule of thumb.
181181
"""
182182
t_function = self._elapsed_function_time
183+
if t_function == 0:
184+
# When no function is done executing, the overhead cannot
185+
# reliably be determined, so 0 is the best we can do.
186+
return 0
183187
t_total = self.elapsed_time()
184188
return (1 - t_function / t_total) * 100
185189

@@ -426,7 +430,6 @@ class AsyncRunner(BaseRunner):
426430
overhead of the executor. Essentially, this is
427431
``100 * (1 - total_elapsed_function_time / self.elapsed_time())``.
428432
429-
430433
Notes
431434
-----
432435
This runner can be used when an async function (defined with

0 commit comments

Comments
 (0)