Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/Util/Profiler.py
diff options
context:
space:
mode:
authoramartin <olpc@localhost.localdomain>2007-01-16 08:32:18 (GMT)
committer amartin <olpc@localhost.localdomain>2007-01-16 08:32:18 (GMT)
commit1c5de0188ba5bf675d872ea6e73f29ef38b63bf5 (patch)
tree5c80c7666daa367f85db9b44ce0e01e68b608ddc /Util/Profiler.py
parent20c60d6a435599dad56e97b0ce9d7efc6f02c4d4 (diff)
TrackInterface screen buffers
Diffstat (limited to 'Util/Profiler.py')
-rw-r--r--Util/Profiler.py23
1 files changed, 20 insertions, 3 deletions
diff --git a/Util/Profiler.py b/Util/Profiler.py
index 338589e..0019a6c 100644
--- a/Util/Profiler.py
+++ b/Util/Profiler.py
@@ -8,6 +8,10 @@ class TaskProfiler( object ):
def ProfileBegin( self, profile ):
if self.profiles.has_key(profile) == False: self.profiles[profile] = TaskProfile(profile)
self.profiles[profile].begin()
+
+ def ProfilePause( self, profile ):
+ if self.profiles.has_key(profile) == False: return False
+ self.profiles[profile].pause()
def ProfileEnd( self, profile ):
if self.profiles.has_key(profile) == False: return False
@@ -51,20 +55,33 @@ class TaskProfile( object ):
self.max = -1.0 # pretty low
self.avg = 0.0
self.dt = 0
- self.inProgress = False;
+ self.inProgress = False
+ self.paused = False
def begin( self ):
if self.inProgress: return False # you fucked up your ProfileBegin and ProfileEnd pairs
self.inProgress = True
- self.startTime = time.time()
-
+ if self.paused:
+ self.paused = False
+ self.startTime += time.time() - self.pauseTime
+ else:
+ self.startTime = time.time()
+
+ def pause( self ):
+ self.pauseTime = time.time()
+ self.inProgress = False
+ self.paused = True
+
def end( self ):
self.dt = time.time() - self.startTime
+ if self.paused:
+ self.dt = self.pauseTime - self.startTime
if self.dt > self.max: self.max = self.dt
if self.dt < self.min: self.min = self.dt
self.avg = (self.dt + self.avg*self.count)/(self.count+1)
self.count += 1
self.inProgress = False
+ self.paused = False
def printlast( self ):
return "Profile: " + self.name + " last dt: %f" % (self.dt)