Python comes with two profiling options, profile
and cProfile
, which share the same interface but differ in their impact on the profiled program's performance. The profile
module is pure Python but adds significant overhead to the software being profiled and, therefore, isn't well suited for long running programs. The cProfile
profiling option is a C extension and has much lower overhead, thus impacting program execution times to a lesser degree. As a result, we will use cProfile
.
Part of the beauty of Python is its batteries included nature. The cProfile
and profile
profiling options both come built in to the Python distribution that you are using.