I have a python project where I execute the app as a module using the -m flag. So something like:
python -m apps.validate -i input.mp4
Now, I want to profile it using the command line. So the inline examples suggest invoking cProfile itself a module. However, I cannot do something like:
python -m cProfile apps.validate -i input.mp4
However, this results in the error "No such file or directory". I cannot just go to the apps directory and launch validate.py due to relative imports.
Is there a way to profile a module on the command line?
cProfileonline documentation that says a-moption was added tocProfilein that version. This is in addition to the Python interpreter's own-moption, This means that something likepython -m cProfile -m apps.validate -i input.mp4ought to work (if you're using Python 3.7+).profile(andcProfile) and see how support for the new-moption was added. It might even be possible to use that version of it with an earlier version of the Python interpreter (depending on what other changes were made).