line_profiler icon indicating copy to clipboard operation
line_profiler copied to clipboard

Allow user to add directories to the Python path.

Open dalewis opened this issue 9 years ago • 1 comments

This allows us to profile scripts that are located within a package hierarchy. Multiple directories may be added, via either the short argument -p or long argument --pythonpath.

Usage: kernprof <other options> -p dir1 [-p dir2 -p dir3 ...] script_to_profile.py

Ex: Script foo/bar/script.py, with directory structure:

base/
|---foo/
    |---__init__.py
    |---bar/
        |---__init__.py
        |---script.py

Script can normally be run via python -m foo.bar.script or python foo/bar/script.py.

To run kernprof: From base:

kernprof -l -v -p . foo/bar/script.py

dalewis avatar Aug 04 '16 08:08 dalewis

Hey Rob,

line_profiler/kernprof is great! Just came across it last week. I made a small change to allow profiling scripts located in package hierarchies. Let me know what you think.

-Darren

dalewis avatar Aug 04 '16 08:08 dalewis