cProfile measure module with -- arguments

77 views Asked by At

I want to profile a module that takes arguments with -- . cProfile then thinks that these are arguments for themselves. How can I work around this?

py -3.9 -m cProfile -m my_module -o statistics --my-argument
Usage: cProfile.py [-o output_file_path] [-s sort] [-m module | scriptfile] [arg] ...

cProfile.py: error: no such option: --my-argument
1

There are 1 answers

1
William On

Just change the order. It should work.

py -3.9 -m cProfile -o statistics.prof -m my_module <args>

If it is not a module then:

py -3.9 -m cProfile -o statistics.prof your_code.py <args>