[Bf-extensions-cvs] [ed86d37] master: Removed home-grown Profiling class, cProfile does a much better job.

Lukas Tönne noreply at git.blender.org
Mon Dec 15 14:31:35 CET 2014


Commit: ed86d3710db8ec73905c2885128b07abb2a2daa5
Author: Lukas Tönne
Date:   Mon Dec 15 10:15:01 2014 +0100
Branches: master
https://developer.blender.org/rBACed86d3710db8ec73905c2885128b07abb2a2daa5

Removed home-grown Profiling class, cProfile does a much better job.

===================================================================

M	object_physics_meadow/util.py

===================================================================

diff --git a/object_physics_meadow/util.py b/object_physics_meadow/util.py
index 5b4af67..1832394 100644
--- a/object_physics_meadow/util.py
+++ b/object_physics_meadow/util.py
@@ -93,44 +93,3 @@ def set_object_parent(ob, parent):
     mat = ob.matrix_world
     ob.parent = parent
     ob.matrix_world = mat
-
-#-----------------------------------------------------------------------
-
-class Profiling():
-    def __init__(self, name):
-        self.name = name
-        self.total = 0.0
-        self.count = 0
-        self.last = 0.0
-    
-    def reset(self):
-        self.total = 0.0
-        self.count = 0
-        self.last = 0.0
-    
-    @property
-    def average(self):
-        return self.total / float(self.count) if self.count > 0 else 0.0
-    
-    def __enter__(self):
-        self.start_time = time.time()
-    
-    def __exit__(self, exc_type, exc_value, traceback):
-        self.last = time.time() - self.start_time
-        self.total += self.last
-        self.count += 1
-        
-    def as_string(self, show_total=True, show_count=True, show_average=True, show_last=False):
-        precision = 6
-        factor = 10 ** precision
-        time_str = lambda t: "{}:{}".format(time.strftime("%M:%S", time.gmtime(t)), str(int(t * float(factor)) % factor).rjust(precision, '0'))
-        result = "{}:\n".format(self.name)
-        if show_total:
-            result += "\ttotal = {}\n".format(time_str(self.total))
-        if show_count:
-            result += "\tcount = {}\n".format(self.count)
-        if show_average:
-            result += "\taverage = {}\n".format(time_str(self.average))
-        if show_last:
-            result += "\tlast = {}\n".format(time_str(self.last))
-        return result



More information about the Bf-extensions-cvs mailing list