vmprof-python icon indicating copy to clipboard operation
vmprof-python copied to clipboard

Add `-m` switch to vmprof cli

Open BarrensZeppelin opened this issue 1 year ago • 4 comments

It makes vmprof run the specified program with runpy.run_module instead of runpy.run_path.

BarrensZeppelin avatar Mar 05 '24 13:03 BarrensZeppelin

Could you add a test for this, and add it to the documentation?

mattip avatar Mar 06 '24 08:03 mattip

Like this? :slightly_smiling_face:

BarrensZeppelin avatar Mar 07 '24 16:03 BarrensZeppelin

Yes, thanks. I assume you have run this and it successfully calls the module as expected?

mattip avatar Mar 07 '24 16:03 mattip

Yeah. http.server is a bad example for performance profiling, but it seems to work:

$ python3 -m vmprof --output file.prof -m http.server
Serving HTTP on 0.0.0.0 port 8000 (http://0.0.0.0:8000/) ...
127.0.0.1 - - [07/Mar/2024 17:56:57] "GET / HTTP/1.1" 200 -
^C
Keyboard interrupt received, exiting.
$ vmprofshow file.prof flat
   100.000% - <unknown code>:None:None
     0.000% - <module>:/opt/pypy3/lib/pypy3.10/http/server.py:1
     0.000% - __import__:<frozen importlib._bootstrap>:1117
     0.000% - _gcd_import:<frozen importlib._bootstrap>:1038
     0.000% - _find_and_load:<frozen importlib._bootstrap>:1022
     0.000% - _find_and_load_unlocked:<frozen importlib._bootstrap>:987
     0.000% - _load_unlocked:<frozen importlib._bootstrap>:664
     0.000% - exec_module:<builtin>/frozen importlib._bootstrap_external:891
     0.000% - _call_with_frames_removed:<frozen importlib._bootstrap>:233
     0.000% - <module>:/opt/pypy3/lib/pypy3.10/html/__init__.py:1
     0.000% - get_code:<builtin>/frozen importlib._bootstrap_external:964
     0.000% - source_to_code:<builtin>/frozen importlib._bootstrap_external:956
     0.000% - _code_to_timestamp_pyc:<builtin>/frozen importlib._bootstrap_external:697

BarrensZeppelin avatar Mar 07 '24 16:03 BarrensZeppelin