Adrian Tam shows how you can test the performance of calls in Python:
Profiling is a technique to figure out how time is spent in a program. With this statistics, we can find the “hot spot” of a program and think about ways of improvement. Sometimes, hot spot in unexpected location may hint a bug in the program as well.
In this tutorial, we will see how we can use the profiling facility in Python. Specifically, you will see
– How we can compare small code fragments using
timeit
module– How we can profile the entire program using
cProfile
module– How we can invoke a profiler inside an existing program
– What the profiler cannot do
Read on for those techniques.