Comments (8)
I have a new pull request for support console_scripts. 😸
from scalene.
$ python -m scalene --help
scalene: could not find input file.
First of all, there are no docs. Secondly, what if I want to profile console_scripts
or python modules (not files).
Even cProfile have some abilities for this:
$ python -m cProfile --help
Usage: cProfile.py [-o output_file_path] [-s sort] [-m module | scriptfile] [arg] ...
Options:
-h, --help show this help message and exit
-o OUTFILE, --outfile=OUTFILE
Save stats to <outfile>
-s SORT, --sort=SORT Sort order when printing to stdout, based on
pstats.Stats class
-m Profile a library module
from scalene.
@emeryberger, here's an example repo that reproduces the issues I originally reported:
https://github.com/jessemyers/scalene-repro
from scalene.
Updated to provide conventional command-line help and output redirection.
% python3 -m scalene --help
usage: scalene [-h] [-o OUTFILE] prog
Scalene: a high-precision CPU and memory profiler.
https://github.com/emeryberger/scalene
for CPU profiling only:
% python -m scalene yourprogram.py
for CPU and memory profiling (Mac OS X):
% DYLD_INSERT_LIBRARIES=$PWD/libscalene.dylib PYTHONMALLOC=malloc python -m scalene yourprogram.py
for CPU and memory profiling (Linux):
% LD_PRELOAD=$PWD/libscalene.dylib PYTHONMALLOC=malloc python -m scalene yourprogram.py
positional arguments:
prog program to be profiled
optional arguments:
-h, --help show this help message and exit
-o OUTFILE, --outfile OUTFILE
file to hold profiler output (default: stdout)
Will work on the other issue described here.
from scalene.
I'd love a repro case.
from scalene.
I'd be happy to add more descriptive text via help (I am planning to add an --outfile option, so the time is right).
Usage is currently just python -m scalene your-file-goes-here.py
. It doesn't have explicit support for console_scripts or modules, but that shouldn't be hard to add. If you have some test cases you could share, that would be helpful.
from scalene.
console_scripts
are just plain python files in python bin
directory without extension with shebang string. This one is for alembic
library:
#!/home/poh/.pyenv/versions/3.7.2/bin/python3.7
# -*- coding: utf-8 -*-
import re
import sys
from alembic.config import main
if __name__ == '__main__':
sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0])
sys.exit(main())
They can be actually runned with scalene
(did not test output though):
$ python -m scalene $(which alembic)
or in case of pyenv
:
$ python -m scalene $(pyenv which alembic)
But, this is not very elegant.
For modules runpy
should be used.
from scalene.
Merged, thanks!
from scalene.
Related Issues (20)
- Scalene can't open browser on MacOS HOT 4
- Is there a way to measure time spent in GC? HOT 3
- GPU and memory columns not present HOT 7
- Python 3.11 support HOT 1
- defaults to cli HOT 2
- Segmentation fault profiling project
- Getting SIGSEGV with empty program HOT 5
- Probable bug with scalene when profiling async code HOT 1
- Wheel missing for Python 3.12 HOT 3
- Scalene does not seem to work with multiprocessing
- Unicode decode error after executing cupy code in ipython
- Scalene crashes on sklearn / statsmodel etc. imports HOT 10
- Include flags from environment variables set externally HOT 1
- GUI Filter: Display only functions / methods with profiled lines
- Discrepency between online GUI and the generated HTML HOT 1
- Ollama server is not detected HOT 3
- Environment variables from .env file are not loaded HOT 1
- Add ability to control whether `profile.html` is generated
- ImportError: dlopen with crdp.abi3.so, 0x0002: bad bind opcode 0x00 HOT 6
- Scalene doesnt work properly with torchrun / torch.distributed.run HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from scalene.