I am trying to profile a reasonably sized python project using cprofile.
I am usually invoking my python app as a module something like:
python -m cabon.apps.detector -i input_image.png
Now howo can I use cprofile from the command line. I see that the cProfile itself is invoked as a module with -m
and how can this be combined with my python app which is also invoked as a module?
The files
cProfile
andprofile
can also be invoked as a script to profile another script. For example:
python -m cProfile [-o output_file] [-s sort_order] (-m module | myscript.py)
As mentioned in the documentation, we can specify that a module is being profiled by using additional -m
. First for the cProfile
and then the actual module:
python -m cProfile -m cabon.apps.detector -i input_image.png