I want to profile my code, but exclude startup.
Python docs describe how to run cProfile as a script:
python -m cProfile [-o output_file] [-s sort_order] (-m module | myscript.py)
They also describe how to turn profiling on and off using the python API:
import cProfile
pr = cProfile.Profile()
pr.enable()
# ... do something ...
pr.disable()
Will it be effective to run pr.enable()
and pr.disable()
if I am running cProfile as a module?
Is there an implied "enable" when starting my code that I could disable, or is the cProfile
object used by the script method not accessible to me?