vmprof / vmprof-python

vmprof - a statistical program profiler
http://vmprof.com
Other
433 stars 54 forks source link

Add `-m` switch to vmprof cli #259

Open BarrensZeppelin opened 6 months ago

BarrensZeppelin commented 6 months ago

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

mattip commented 6 months ago

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

BarrensZeppelin commented 6 months ago

Like this? :slightly_smiling_face:

mattip commented 6 months ago

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

BarrensZeppelin commented 6 months ago

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