mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-03 10:22:45 -04:00
support for profiling multiple frames
This commit is contained in:
parent
cf20bf4630
commit
a88183a033
@ -2062,8 +2062,9 @@ class ShowBase(DirectObject.DirectObject):
|
||||
# Set fWantTk to 0 to avoid starting Tk with this call
|
||||
self.startDirect(fWantDirect = fDirect, fWantTk = fTk)
|
||||
|
||||
def profileNextFrame(self):
|
||||
self.taskMgr.profileNextFrame()
|
||||
def profileFrames(self, num=1):
|
||||
# profile the next 'num' frames and log the results
|
||||
self.taskMgr.profileFrames(num)
|
||||
|
||||
def run(self):
|
||||
self.taskMgr.run()
|
||||
|
@ -336,7 +336,7 @@ class TaskManager:
|
||||
# List of tasks scheduled to execute in the future
|
||||
self.__doLaterList = []
|
||||
|
||||
self._profileNextFrame = False
|
||||
self._profileFrames = False
|
||||
|
||||
# We copy this value in from __builtins__ when it gets set.
|
||||
# But since the TaskManager might have to run before it gets
|
||||
@ -772,12 +772,18 @@ class TaskManager:
|
||||
self.__addNewTask(task)
|
||||
self.pendingTaskDict.clear()
|
||||
|
||||
def profileNextFrame(self):
|
||||
self._profileNextFrame = True
|
||||
def profileFrames(self, num=None):
|
||||
self._profileFrames = True
|
||||
if num is None:
|
||||
num = 1
|
||||
self._profileFrameCount = num
|
||||
|
||||
@profiled()
|
||||
def _profiledFrame(self, *args, **kArgs):
|
||||
return self.step(*args, **kArgs)
|
||||
def _doProfiledFrames(self, *args, **kArgs):
|
||||
print '** profiling %s frames' % self._profileFrameCount
|
||||
for i in xrange(self._profileFrameCount):
|
||||
result = self.step(*args, **kArgs)
|
||||
return result
|
||||
|
||||
def step(self):
|
||||
# assert TaskManager.notify.debug('step: begin')
|
||||
@ -849,9 +855,9 @@ class TaskManager:
|
||||
self.running = 1
|
||||
while self.running:
|
||||
try:
|
||||
if self._profileNextFrame:
|
||||
self._profiledFrame()
|
||||
self._profileNextFrame = False
|
||||
if self._profileFrames:
|
||||
self._profileFrames = False
|
||||
self._doProfiledFrames()
|
||||
else:
|
||||
self.step()
|
||||
except KeyboardInterrupt:
|
||||
|
Loading…
x
Reference in New Issue
Block a user