check this out: http://docs.cython.org/src/tutorial/profiling_tutorial.html