2
0
Эх сурвалжийг харах

moved profiling code into showbase for a more reasonable access

Zachary Pavlov 18 жил өмнө
parent
commit
f2f61a626c

+ 1 - 15
direct/src/showbase/PythonUtil.py

@@ -2970,23 +2970,9 @@ if __debug__:
     assert obj2count[1] == 1 * 3
     assert obj2count[2] == 2 * 3
     assert obj2count[3] == 3 * 3
-    assert obj2count[4] == 4 * 3
+    assert obj2count[4] == 4 * 3                  
 
-
-
-bias=-1
 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):
         if(not base.config.GetBool("use-profiler",0)):
             return f

+ 9 - 0
direct/src/showbase/ShowBase.py

@@ -32,6 +32,7 @@ import EventManager
 import math,sys,os
 import Loader
 import time
+import profile, pstats
 from direct.fsm import ClassicFSM
 from direct.fsm import State
 import DirectObject
@@ -115,6 +116,14 @@ class ShowBase(DirectObject.DirectObject):
         # has to run before libpanda is even loaded).
         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
         # aspect ratio from the window size.
         # If you need to know the actual aspect ratio call base.getAspectRatio()