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

This commit is contained in:
Darren Ranalli 2006-12-27 19:56:52 +00:00
parent 60719cbf5c
commit d7b0ba8510
2 changed files with 4 additions and 4 deletions

View File

@ -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)

View File

@ -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)