DamienIrving / climate-analysis

Code used for the analysis and visualisation of climate data during my PhD
MIT License
40 stars 19 forks source link

Profiling #32

Open DamienIrving opened 8 years ago

DamienIrving commented 8 years ago

There are a number of different types of profiling:

Step-by-step

If you want to move through your code step-by-step, use the Python debugger:

import pdb
pdb.set_trace()

Summary information

This depends if you're interested in runtime or memory usage...

Runtime

Use cprofile to generate a binary file with the stats,

$ python -m cprofile -o output.o script.py <args>

then you need a tool to visualise that binary file. There are lots out there (e.g. see this thread) - I found cprofilev to be simple and easy to use.

Memory usage

This thread goes through the options. The posts here and here are also good.