Browse Source

added anonymous profiling that doesn't need to be configed on for ~profile

Darren Ranalli 19 years ago
parent
commit
d7b0ba8510
2 changed files with 4 additions and 4 deletions
  1. 3 3
      direct/src/showbase/PythonUtil.py
  2. 1 1
      direct/src/task/Task.py

+ 3 - 3
direct/src/showbase/PythonUtil.py

@@ -761,7 +761,7 @@ def profile(callback, name, terse):
     print '***** END PROFILE: %s *****' % name
     del __builtin__.__dict__['globalProfileFunc']
 
-def profiled(category, terse=False):
+def profiled(category=None, terse=False):
     """ decorator for profiling functions
     turn categories on and off via "want-profile-categoryName 1"
     
@@ -773,7 +773,7 @@ def profiled(category, terse=False):
 
     want-profile-particles 1
     """
-    assert type(category) is types.StringType, "must provide a category name for @profiled"
+    assert type(category) in (types.StringType, types.NoneType), "must provide a category name for @profiled"
 
     try:
         null = not __dev__
@@ -797,7 +797,7 @@ def profiled(category, terse=False):
                 _base = base
             except:
                 _base = simbase
-            if _base.config.GetBool('want-profile-%s' % category, 0):
+            if (category is None) or _base.config.GetBool('want-profile-%s' % category, 0):
                 return profile(Functor(f, *args, **kArgs), name, terse)
             else:
                 return f(*args, **kArgs)

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

@@ -772,7 +772,7 @@ class TaskManager:
     def profileNextFrame(self):
         self._profileNextFrame = True
 
-    @profiled('frame')
+    @profiled()
     def _profiledFrame(self, *args, **kArgs):
         return self.step(*args, **kArgs)