I guess this could be a bug in the profiler and it's not counting all the functions called by my function in its total time, considering this is Python calling some C code calling a Python function calling more Chipmunk stuff (or whatever Pymunk does). It would be nice to know for sure, though.
Here are the profiling results for major (running time) Pymunk internal functions and my pre_collision function, before and after:
Code: Select all
ncalls tottime percall cumtime percall filename:lineno(function)
11067 0.639 0.000 1.795 0.000 pymunk/__init__.py:419(cf)
44028 0.260 0.000 0.260 0.000 pymunk/__init__.py:1170(_get_shape)
22014 0.251 0.000 0.511 0.000 pymunk/__init__.py:1167(_get_shapes)
600 0.225 0.000 2.021 0.003 pymunk/__init__.py:274(step)
23726/16872 0.141 0.000 0.185 0.000 pymunk/__init__.py:1158(_get_contacts)
10410 0.106 0.000 0.169 0.000 pymunk/vec2d.py:149(__sub__)
11007 0.080 0.000 0.221 0.000 game.py:22(pre_collision)
30270 0.067 0.000 0.067 0.000 pymunk/__init__.py:616(_get_velocity)
16710 0.062 0.000 0.062 0.000 pymunk/vec2d.py:46(__init__)
23876 0.049 0.000 0.049 0.000 pymunk/vec2d.py:58(__getitem__)
11067 0.048 0.000 0.048 0.000 pymunk/__init__.py:1146(__init__)
6854 0.031 0.000 0.031 0.000 pymunk/__init__.py:1108(__init__)
6300 0.025 0.000 0.043 0.000 pymunk/vec2d.py:41(from_param)
13466 0.023 0.000 0.023 0.000 pymunk/__init__.py:1127(_get_normal)
12600 0.022 0.000 0.022 0.000 pymunk/__init__.py:610(_get_position)
10410 0.019 0.000 0.019 0.000 pymunk/__init__.py:863(<lambda>)
Code: Select all
ncalls tottime percall cumtime percall filename:lineno(function)
600 0.273 0.000 0.483 0.001 pymunk/__init__.py:274(step)
11167 0.143 0.000 0.209 0.000 pymunk/__init__.py:419(cf)
6300 0.041 0.000 0.074 0.000 pymunk/vec2d.py:41(from_param)
11167 0.040 0.000 0.040 0.000 pymunk/__init__.py:1146(__init__)
12600 0.035 0.000 0.035 0.000 pymunk/__init__.py:610(_get_position)
6300 0.033 0.000 0.033 0.000 pymunk/vec2d.py:46(__init__)
9450 0.030 0.000 0.030 0.000 pymunk/__init__.py:616(_get_velocity)
11104 0.025 0.000 0.025 0.000 game.py:22(pre_collision)
7574 0.020 0.000 0.020 0.000 pymunk/__init__.py:588(_get_angle)