mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-03 18:31:55 -04:00
added warnings for tasks that run longer than expected, to track down chugs
This commit is contained in:
parent
d55b83f568
commit
98efaf0f62
@ -329,6 +329,8 @@ class TaskManager:
|
||||
|
||||
OsdPrefix = 'task.'
|
||||
|
||||
DefTaskDurationWarningThreshold = 3.
|
||||
|
||||
def __init__(self):
|
||||
self.running = 0
|
||||
self.stepping = 0
|
||||
@ -354,6 +356,16 @@ class TaskManager:
|
||||
# small intervals.
|
||||
self.trueClock = TrueClock.getGlobalPtr()
|
||||
|
||||
"""
|
||||
base = getBase()
|
||||
self.warnTaskDuration = base.config.GetBool('task-duration-warnings', 1)
|
||||
self.taskDurationWarningThreshold = base.config.GetFloat('task-duration-warning-threshold', 2)
|
||||
"""
|
||||
# we don't have a base object at this point, so set some defaults and read the real values
|
||||
# every frame
|
||||
self.warnTaskDuration = 0
|
||||
self.taskDurationWarningThreshold = 2
|
||||
|
||||
self.currentTime, self.currentFrame = self.__getTimeFrame()
|
||||
if (TaskManager.notify == None):
|
||||
TaskManager.notify = directNotify.newCategory("TaskManager")
|
||||
@ -701,6 +713,13 @@ class TaskManager:
|
||||
task.avgDt = (task.runningTotal / task.frame)
|
||||
else:
|
||||
task.avgDt = 0
|
||||
|
||||
# warn if the task took too long
|
||||
if self.warnTaskDuration:
|
||||
if dt >= self.taskDurationWarningThreshold:
|
||||
TaskManager.notify.warning('task %s ran for %s seconds' % (
|
||||
task.name, dt))
|
||||
|
||||
return ret
|
||||
|
||||
def __repeatDoMethod(self, task):
|
||||
@ -881,6 +900,13 @@ class TaskManager:
|
||||
|
||||
|
||||
def run(self):
|
||||
base = getBase()
|
||||
self.warnTaskDuration = base.config.GetBool('task-duration-warnings',
|
||||
1)
|
||||
self.taskDurationWarningThreshold = base.config.GetFloat(
|
||||
'task-duration-warning-threshold',
|
||||
TaskManager.DefTaskDurationWarningThreshold)
|
||||
|
||||
# Set the clock to have last frame's time in case we were
|
||||
# Paused at the prompt for a long time
|
||||
if self.globalClock:
|
||||
|
Loading…
x
Reference in New Issue
Block a user