From 64eb98f7a836957edacbc8346802c7d91dc0b962 Mon Sep 17 00:00:00 2001 From: Simon Cross Date: Tue, 6 Sep 2016 20:49:06 +0200 Subject: [PATCH] Use debug_timer on lights. --- tabakrolletjie/lights.py | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) 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 -- 2.34.1