4

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?

1 Answer 1

5

The files cProfile and profile 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
Sign up to request clarification or add additional context in comments.

1 Comment

Ahhhh damn. I had tried this but mistakenly put the -m immediately after the -s instead of after the parameter. Thanks!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.