moved profiling code into showbase for a more reasonable access

This commit is contained in:
Zachary Pavlov 2007-06-25 21:23:19 +00:00
parent cab1ce3e0b
commit f2f61a626c
2 changed files with 10 additions and 15 deletions

View File

@ -2972,21 +2972,7 @@ if __debug__:
assert obj2count[3] == 3 * 3 assert obj2count[3] == 3 * 3
assert obj2count[4] == 4 * 3 assert obj2count[4] == 4 * 3
bias=-1
def quickProfile(name="unnamed"): def quickProfile(name="unnamed"):
global bias
if(base.config.GetBool("use-profiler",0)):
if bias == -1:
print "Calibrating profiler"
bias = prof.Profile().calibrate(100000)
print "Bias is: ",bias
prof.Profile.bias =bias
def f8(x):
return ("%"+"8.%df"%base.config.GetInt("profile-decimals",3)) % x
pstats.f8=f8
def profileDecorator(f): def profileDecorator(f):
if(not base.config.GetBool("use-profiler",0)): if(not base.config.GetBool("use-profiler",0)):
return f return f

View File

@ -32,6 +32,7 @@ import EventManager
import math,sys,os import math,sys,os
import Loader import Loader
import time import time
import profile, pstats
from direct.fsm import ClassicFSM from direct.fsm import ClassicFSM
from direct.fsm import State from direct.fsm import State
import DirectObject import DirectObject
@ -115,6 +116,14 @@ class ShowBase(DirectObject.DirectObject):
# has to run before libpanda is even loaded). # has to run before libpanda is even loaded).
taskMgr.resumeFunc = PStatClient.resumeAfterPause taskMgr.resumeFunc = PStatClient.resumeAfterPause
profile.Profile.bias = float(self.config.GetString("profile-bias"))
def f8(x):
return ("%"+"8.%df"%base.config.GetInt("profile-decimals",3)) % x
pstats.f8=f8
# If the aspect ratio is 0 or None, it means to infer the # If the aspect ratio is 0 or None, it means to infer the
# aspect ratio from the window size. # aspect ratio from the window size.
# If you need to know the actual aspect ratio call base.getAspectRatio() # If you need to know the actual aspect ratio call base.getAspectRatio()