Removed home-grown Profiling class, cProfile does a much better job.
authorLukas Tönne <lukas.toenne@gmail.com>
Mon, 15 Dec 2014 09:15:01 +0000 (10:15 +0100)
committerLukas Tönne <lukas.toenne@gmail.com>
Mon, 15 Dec 2014 09:15:01 +0000 (10:15 +0100)
object_physics_meadow/util.py

index 5b4af67..1832394 100644 (file)
@@ -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