SmartOne Logo
Nadeau Innovations has been acquired by SmartOne.ai.
Click here to learn more.

Profiling Python Code

Figure out the bottlenecks in your Python scripts.

Run Your Code with cProfile

python -m cProfile -o my_output.cprof my_script.py

Visualize Your Code’s Execution

# visualize with pyprof2calltree
pip install pyprof2calltree
pyprof2calltree -k -i my_output.cprof

# visualize with pyprof2calltree
pip install snakeviz
snakeviz my_output.cprof
  • ncalls: number of calls,
  • tottime: total time spent in the given function (excluding time made in calls to sub-functions)
  • percall: quotient of tottime divided by ncalls
  • cumtime: total time spent in this and all subfunctions
  • percall: quotient of cumtime divided by primitive calls
Nicholas Nadeau, Ph.D., P.Eng.
Nicholas Nadeau, Ph.D., P.Eng.
Founder / Fractional CTO

Nicholas Nadeau is a fractional CTO empowering startups with next-gen technology expertise, and a passion for driving corporate innovation. Stay informed on cutting-edge hard tech trends - subscribe to my newsletter. Ready to innovate? Discover my services and accelerate your growth.

Related