Profiling using CProfiler

Sudhakar Reddy
2 min readJun 4, 2020
  1. Login to Floyd hub and check your workspace

2. Launch the Python program for which you want to run the cprofiler.In this case its TestProfile.py which is nothing but Assignment14

3.Run the command below i.e python -m cProfile -o perfstas TestProfile.py.

The cprofile output of running TestProfile.py would be stored in perfstats

4.Download perfstats(binary file) to your PC to analyse the cProfile output of TestProfile python code.

5.To Analyse cProfile ,execute “pip install cprofilev” on your PC to view cProfile output i.e to view the perfstats file(output of the cProfile run done on TestProfile.py python file)

6.Run cprofilev -f C:\Cprofiler\perfstats

7. Check the output of the cprofile hosted on http://127.0.0.1:4000

8.8.In order to find bottleneck in the code execution.We need to sort the above function calls based on the total time.

Run the following to sort the same.

http://127.0.0.1:4000/?sort=tottime

References:

https://ymichael.com/2014/03/08/profiling-python-with-cprofile.html

--

--