Browse Source

moved PStat import to top of file for more efficient profiling

Joe Shochet 20 years ago
parent
commit
88d05089fe
1 changed files with 4 additions and 1 deletions
  1. 4 1
      direct/src/task/Task.py

+ 4 - 1
direct/src/task/Task.py

@@ -16,6 +16,10 @@ import string
 import signal
 import signal
 from libheapq import heappush, heappop, heapify
 from libheapq import heappush, heappop, heapify
 
 
+if __debug__:
+    # For pstats
+    from pandac.PandaModules import PStatCollector
+
 # MRM: Need to make internal task variables like time, name, index
 # MRM: Need to make internal task variables like time, name, index
 # more unique (less likely to have name clashes)
 # more unique (less likely to have name clashes)
 
 
@@ -138,7 +142,6 @@ class Task:
 
 
     def setupPStats(self, name):
     def setupPStats(self, name):
         if __debug__ and TaskManager.taskTimerVerbose:
         if __debug__ and TaskManager.taskTimerVerbose:
-            from pandac.PandaModules import PStatCollector
             self.pstats = PStatCollector("App:Show code:" + name)
             self.pstats = PStatCollector("App:Show code:" + name)
 
 
     def finishTask(self, verbose):
     def finishTask(self, verbose):