From e48fd3077858171301f5a81b4881f8d6b489c85d Mon Sep 17 00:00:00 2001 From: Théo de la Hogue Date: Tue, 23 Jul 2024 12:35:51 +0200 Subject: Improving execution info calculation. --- src/argaze/DataFeatures.py | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/src/argaze/DataFeatures.py b/src/argaze/DataFeatures.py index 2629e8e..6711905 100644 --- a/src/argaze/DataFeatures.py +++ b/src/argaze/DataFeatures.py @@ -703,21 +703,23 @@ def PipelineStepExecutionTime(method): end = time.perf_counter() - # Check earlier call dates to calculate frequency - try: + # Create list to store method call dates + if method.__name__ not in self._execution_times.keys(): - last_start, last_end = self._execution_times[method.__name__] + self._execution_times[method.__name__] = [] - if start > last_start: + # Store start end end dates + self._execution_times[method.__name__].append((start, end)) - self._execution_frequencies[method.__name__] = 1 / (start - last_start) - - except KeyError: + # Remove call dates older than 1 second and count number of calls to get frequency + if self._execution_times[method.__name__][-1][0] - self._execution_times[method.__name__][0][0] > 1: - self._execution_frequencies[method.__name__] = math.nan + self._execution_times[method.__name__].pop(0) + self._execution_frequencies[method.__name__] = len(self._execution_times[method.__name__]) - # Store start end end dates - self._execution_times[method.__name__] = (start, end) + else: + + self._execution_frequencies[method.__name__] = math.nan return result @@ -1354,8 +1356,7 @@ class PipelineStepObject(): # Check execution time try: - start, end = self._execution_times[method_name] - t = end - start + t = numpy.mean(numpy.diff(self._execution_times[method_name])) except KeyError: -- cgit v1.1