Browse Source

Add some profiling decorators to the ContainerTree

Jaime van Kessel 5 years ago
parent
commit
85ed22de4c

+ 3 - 0
cura/Machines/ContainerTree.py

@@ -11,11 +11,13 @@ from cura.Settings.GlobalStack import GlobalStack  # To listen only to global st
 
 from typing import Dict, List, TYPE_CHECKING
 import time
+import UM.FlameProfiler
 
 if TYPE_CHECKING:
     from cura.Machines.QualityGroup import QualityGroup
     from cura.Machines.QualityChangesGroup import QualityChangesGroup
 
+
 ##  This class contains a look-up tree for which containers are available at
 #   which stages of configuration.
 #
@@ -77,6 +79,7 @@ class ContainerTree:
     # Add a machine node by the id of it's definition.
     # This is automatically called by the _machineAdded function, but it's sometimes needed to add a machine node
     # faster than would have been done when waiting on any signals (for instance; when creating an entirely new machine)
+    @UM.FlameProfiler.profile
     def addMachineNodeByDefinitionId(self, definition_id: str) -> None:
         if definition_id in self.machines:
             return  # Already have this definition ID.

+ 1 - 0
cura/Machines/IntentNode.py

@@ -10,6 +10,7 @@ from cura.Machines.ContainerNode import ContainerNode
 if TYPE_CHECKING:
     from cura.Machines.QualityNode import QualityNode
 
+
 ##  This class represents an intent profile in the container tree.
 #
 #   This class has no more subnodes.

+ 2 - 0
cura/Machines/MachineNode.py

@@ -13,6 +13,7 @@ from cura.Machines.QualityChangesGroup import QualityChangesGroup  # To construc
 from cura.Machines.QualityGroup import QualityGroup  # To construct groups of quality profiles that belong together.
 from cura.Machines.QualityNode import QualityNode
 from cura.Machines.VariantNode import VariantNode
+import UM.FlameProfiler
 
 
 ##  This class represents a machine in the container tree.
@@ -168,6 +169,7 @@ class MachineNode(ContainerNode):
         return self.global_qualities.get(self.preferred_quality_type, next(iter(self.global_qualities.values())))
 
     ##  (Re)loads all variants under this printer.
+    @UM.FlameProfiler.profile
     def _loadAll(self):
         container_registry = ContainerRegistry.getInstance()
         if not self.has_variants:

+ 2 - 1
cura/Machines/MaterialNode.py

@@ -9,7 +9,7 @@ from UM.Settings.Interfaces import ContainerInterface
 from UM.Signal import Signal
 from cura.Machines.ContainerNode import ContainerNode
 from cura.Machines.QualityNode import QualityNode
-
+import UM.FlameProfiler
 if TYPE_CHECKING:
     from typing import Dict
     from cura.Machines.VariantNode import VariantNode
@@ -55,6 +55,7 @@ class MaterialNode(ContainerNode):
         ))
         return fallback
 
+    @UM.FlameProfiler.profile
     def _loadAll(self) -> None:
         container_registry = ContainerRegistry.getInstance()
         # Find all quality profiles that fit on this material.

+ 3 - 1
cura/Machines/QualityNode.py

@@ -6,12 +6,13 @@ from typing import Union, TYPE_CHECKING
 from UM.Settings.ContainerRegistry import ContainerRegistry
 from cura.Machines.ContainerNode import ContainerNode
 from cura.Machines.IntentNode import IntentNode
-
+import UM.FlameProfiler
 if TYPE_CHECKING:
     from typing import Dict
     from cura.Machines.MaterialNode import MaterialNode
     from cura.Machines.MachineNode import MachineNode
 
+
 ##  Represents a quality profile in the container tree.
 #
 #   This may either be a normal quality profile or a global quality profile.
@@ -29,6 +30,7 @@ class QualityNode(ContainerNode):
         self._material = my_metadata.get("material")
         self._loadAll()
 
+    @UM.FlameProfiler.profile
     def _loadAll(self) -> None:
         container_registry = ContainerRegistry.getInstance()
 

+ 4 - 1
cura/Machines/VariantNode.py

@@ -9,7 +9,7 @@ from UM.Settings.Interfaces import ContainerInterface
 from UM.Signal import Signal
 from cura.Machines.ContainerNode import ContainerNode
 from cura.Machines.MaterialNode import MaterialNode
-
+import UM.FlameProfiler
 if TYPE_CHECKING:
     from typing import Dict
     from cura.Machines.MachineNode import MachineNode
@@ -38,6 +38,7 @@ class VariantNode(ContainerNode):
         self._loadAll()
 
     ##  (Re)loads all materials under this variant.
+    @UM.FlameProfiler.profile
     def _loadAll(self) -> None:
         container_registry = ContainerRegistry.getInstance()
 
@@ -92,6 +93,7 @@ class VariantNode(ContainerNode):
 
     ##  When a material gets added to the set of profiles, we need to update our
     #   tree here.
+    @UM.FlameProfiler.profile
     def _materialAdded(self, container: ContainerInterface) -> None:
         if container.getMetaDataEntry("type") != "material":
             return  # Not interested.
@@ -125,6 +127,7 @@ class VariantNode(ContainerNode):
         self.materials[base_file].materialChanged.connect(self.materialsChanged)
         self.materialsChanged.emit(self.materials[base_file])
 
+    @UM.FlameProfiler.profile
     def _materialRemoved(self, container: ContainerInterface) -> None:
         if container.getMetaDataEntry("type") != "material":
             return  # Only interested in materials.