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