| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
Documentation build overview105 files changed · + 1 added · ± 104 modified + Added ± Modified |
Sorry, something went wrong.
There was a problem hiding this comment.
I've just verified locally that it works in a virtual environment now, so approving.
Thanks for your contribution @edvilme!
I'd even backport to 3.15 (rather a bug fix than a feature IMO), but leave the final decision to @pablogsal.
Sorry, something went wrong.
|
Hi @chris-eibl thank you!! |
Sorry, something went wrong.
|
No, thanks. Let's wait for Pablo's decision first, and then most probably bedevere-bot can take care of it, anyway. |
Sorry, something went wrong.
|
Please address that nit and ping me again so I or @chris-eibl can land |
Sorry, something went wrong.
|
Renamed method to _resolve_python_pid |
Sorry, something went wrong.
|
Thanks @edvilme for the PR, and @chris-eibl for merging it 🌮🎉.. I'm working now to backport this PR to: 3.15. |
Sorry, something went wrong.
|
GH-151097 is a backport of this pull request to the 3.15 branch. |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
Currently, it is not possible to run profiling.sampling from a Windows venv because virtual environments use shims to launch the original interpreter, but the shim itself isn't a real Python process.
Fix
Added _resolve_venv_child function to detect when the profiler is started from a virtual environment process on Windows, and automatically redirect it to the real child Python process. This prevents profiling against the shim instead of the actual Python process.
The SampleProfiler class uses the resolved child PID when initializing.
Before
After
(venv) PS C:\Users\user\Documents\project> python -m profiling.sampling run .\test.py Profile Stats: nsamples sample% tottime (ms) cumul% cumtime (ms) filename:lineno(function) 465/465 24.6 465.000 24.6 465.000 test.py:59(bubble_sort) 452/589 24.0 452.000 31.2 589.000 test.py:27(fibonacci_recursive) 400/400 21.2 400.000 21.2 400.000 test.py:60(bubble_sort) 227/227 12.0 227.000 12.0 227.000 test.py:72(matrix_multiply) 130/130 6.9 130.000 6.9 130.000 test.py:58(bubble_sort) 95/123 5.0 95.000 6.5 123.000 test.py:25(fibonacci_recursive) 27/27 1.4 27.000 1.4 27.000 test.py:71(matrix_multiply) 23/23 1.2 23.000 1.2 23.000 test.py:26(fibonacci_recursive) 19/31 1.0 19.000 1.6 31.000 test.py:23(fibonacci_recursive) 9/9 0.5 9.000 0.5 9.000 test.py:34(is_prime) 7/7 0.4 7.000 0.4 7.000 test.py:35(is_prime) 6/6 0.3 6.000 0.3 6.000 test.py:84(compute_collatz) 4/8 0.2 4.000 0.4 8.000 random.py:342(Random.randint) 3/3 0.2 3.000 0.2 3.000 random.py:339(Random.randint) 3/3 0.2 3.000 0.2 3.000 test.py:80(compute_collatz) Legend: nsamples: Direct/Cumulative samples (direct executing / on call stack) sample%: Percentage of total samples this function was directly executing tottime: Estimated total time spent directly in this function cumul%: Percentage of total samples when this function was on the call stack cumtime: Estimated cumulative time (including time in called functions) filename:lineno(function): Function location and nameCC @pablogsal