Skip to content

Commit 2b8d749

Browse files
committed
fix two bugs related to overhead
We were always dividing the total function execution time by the number of cores, however sometimes the user sets 'ntasks' so instead we should divide by '_get_max_tasks()'. Also the future start_time wasn't measured in the case where one uses a SequentialExecutor because the Future that is returned already contains the result.
1 parent f8ff1d8 commit 2b8d749

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

adaptive/runner.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ def _process_futures(self, done_futs):
201201
if self.raise_if_retries_exceeded:
202202
self._do_raise(e, x)
203203
else:
204-
self._elapsed_function_time += t / _get_ncores(self.executor)
204+
self._elapsed_function_time += t / self._get_max_tasks()
205205
self.to_retry.pop(x, None)
206206
self.tracebacks.pop(x, None)
207207
if self.do_log:
@@ -220,8 +220,9 @@ def _get_futures(self):
220220
points, _ = self._ask(n_new_tasks)
221221

222222
for x in points:
223+
start_time = time.time() # so we can measure execution time
223224
fut = self._submit(x)
224-
fut.start_time = time.time() # so we can measure execution time
225+
fut.start_time = start_time
225226
self.pending_points[fut] = x
226227

227228
# Collect and results and add them to the learner

0 commit comments

Comments
 (0)