From 556b009a9dbe68ba25960a29e9ff1eb88725e140 Mon Sep 17 00:00:00 2001 From: digitalfrost Date: Wed, 3 Aug 2022 11:26:39 +0200 Subject: [PATCH 1/3] Fix Bug in timing MachineErrorChecker execution We want the Logger in line 215 to give the execution time in seconds so we don't want the start time to be the epoch. Currently the logger will output something like time = 1659518458.5s not like time = 3.0s --- cura/Machines/MachineErrorChecker.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cura/Machines/MachineErrorChecker.py b/cura/Machines/MachineErrorChecker.py index 2cb333d157..d2140cc49b 100644 --- a/cura/Machines/MachineErrorChecker.py +++ b/cura/Machines/MachineErrorChecker.py @@ -43,7 +43,7 @@ class MachineErrorChecker(QObject): self._application = cura.CuraApplication.CuraApplication.getInstance() self._machine_manager = self._application.getMachineManager() - self._start_time = 0. # measure checking time + self._start_time = time.time() # measure checking time # This timer delays the starting of error check so we can react less frequently if the user is frequently # changing settings. From fad47856e49ac4c9e4052e5fb9f9c581335ebc30 Mon Sep 17 00:00:00 2001 From: digitalfrost Date: Wed, 3 Aug 2022 11:40:15 +0200 Subject: [PATCH 2/3] Rename _start_time to _check_start_time This better reflects what _start_time is and makes the code easier to read. _check_start_time is self documenting. The current comment next to _start_time is erroneous since _start_time is not "measuring the checking time" --- cura/Machines/MachineErrorChecker.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cura/Machines/MachineErrorChecker.py b/cura/Machines/MachineErrorChecker.py index d2140cc49b..df335eddb4 100644 --- a/cura/Machines/MachineErrorChecker.py +++ b/cura/Machines/MachineErrorChecker.py @@ -43,7 +43,7 @@ class MachineErrorChecker(QObject): self._application = cura.CuraApplication.CuraApplication.getInstance() self._machine_manager = self._application.getMachineManager() - self._start_time = time.time() # measure checking time + self._check_start_time = time.time() # This timer delays the starting of error check so we can react less frequently if the user is frequently # changing settings. @@ -152,7 +152,7 @@ class MachineErrorChecker(QObject): self._stacks_and_keys_to_check.append((stack, key)) self._application.callLater(self._checkStack) - self._start_time = time.time() + self._check_start_time = time.time() Logger.log("d", "New error check scheduled.") def _checkStack(self) -> None: @@ -212,4 +212,4 @@ class MachineErrorChecker(QObject): self._check_in_progress = False self.needToWaitForResultChanged.emit() self.errorCheckFinished.emit() - Logger.log("i", "Error check finished, result = %s, time = %0.1fs", result, time.time() - self._start_time) + Logger.log("i", "Error check finished, result = %s, time = %0.1fs", result, time.time() - self._check_start_time) From 9f3a1cfe0ae3810e41ddba09f2ec836f12b2f6ec Mon Sep 17 00:00:00 2001 From: digitalfrost Date: Tue, 23 Aug 2022 19:53:50 +0200 Subject: [PATCH 3/3] Use f-string and info method with Logger Use f-string and info method for Logger instead of "Old Style" string formating. --- cura/Machines/MachineErrorChecker.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cura/Machines/MachineErrorChecker.py b/cura/Machines/MachineErrorChecker.py index df335eddb4..a770e63785 100644 --- a/cura/Machines/MachineErrorChecker.py +++ b/cura/Machines/MachineErrorChecker.py @@ -212,4 +212,5 @@ class MachineErrorChecker(QObject): self._check_in_progress = False self.needToWaitForResultChanged.emit() self.errorCheckFinished.emit() - Logger.log("i", "Error check finished, result = %s, time = %0.1fs", result, time.time() - self._check_start_time) + execution_time = time.time() - self._check_start_time + Logger.info(f"Error check finished, result = {result}, time = {execution_time:.2f}s")