From: Simon Cross Date: Tue, 6 Sep 2016 18:49:06 +0000 (+0200) Subject: Use debug_timer on lights. X-Git-Tag: tabakrolletjie-v1.0.0~230 X-Git-Url: https://git.ctpug.org.za/?a=commitdiff_plain;h=64eb98f7a836957edacbc8346802c7d91dc0b962;p=tabakrolletjie.git Use debug_timer on lights. --- diff --git a/tabakrolletjie/lights.py b/tabakrolletjie/lights.py index 6f2c6e7..7620c48 100644 --- a/tabakrolletjie/lights.py +++ b/tabakrolletjie/lights.py @@ -1,13 +1,12 @@ """ May it be a light for you in dark places, when all other lights go out. """ -import time - import pymunk import pymunk.pygame_util import pygame.draw -from .constants import SCREEN_SIZE, LIGHT_CATEGORY, DEBUG +from .constants import SCREEN_SIZE, LIGHT_CATEGORY +from .utils import debug_timer LIGHT_FILTER = pymunk.ShapeFilter( mask=pymunk.ShapeFilter.ALL_MASKS ^ LIGHT_CATEGORY, @@ -32,8 +31,8 @@ def screen_rays(pos): yield pymunk.Vec2d(x, bottom) +@debug_timer("lights.calculate_ray_polys") def calculate_ray_polys(space, body, position): - start_time = time.time() position = pymunk.Vec2d(position) vertices = [position] ray_polys = [] @@ -54,11 +53,6 @@ def calculate_ray_polys(space, body, position): vertices = trial_poly.get_vertices() + [point] if len(vertices) > 2: ray_polys.append(pymunk.Poly(body, vertices)) - end_time = time.time() - if DEBUG: - print( - "calculate_ray_polys: %d polys, %g seconds" % - (len(ray_polys), end_time - start_time)) return ray_polys