call the python profiler for python benchmarking and optimization
April 30th, 2007 by Lawrence David
as long as you’re running a version of python newer than 2.3, you can easily call the python profiler to find bottlenecks in your code:
$ python -m cProfile mycode.py
[...] profiling running time in python is straightforward. what’s tricky is measuring how much memory your program is consuming. i’ve modified some code i found online to do the trick nicely; just import this PyVM module and insert the following into your program: import PyVM [...]