evanhempel / python-flamegraph Goto Github PK
View Code? Open in Web Editor NEWStatistical profiler which outputs in format suitable for FlameGraph (http://www.brendangregg.com/flamegraphs.html)
License: The Unlicense
Statistical profiler which outputs in format suitable for FlameGraph (http://www.brendangregg.com/flamegraphs.html)
License: The Unlicense
=_=
I'm getting an error running this. Seems to work fine on Python 3.7, but on 3.8, I get the following.
Traceback (most recent call last):
File "/Users/user/.pyenv/versions/3.8.2/lib/python3.8/runpy.py", line 193, in _run_module_as_main
return _run_code(code, main_globals, None,
File "/Users/user/.pyenv/versions/3.8.2/lib/python3.8/runpy.py", line 86, in _run_code
exec(code, run_globals)
File "/Users/user/.pyenv/versions/my-venv-3.8.2/lib/python3.8/site-packages/flamegraph/__main__.py", line 4, in <module>
flamegraph.main()
File "/Users/user/.pyenv/versions/my-venv-3.8.2/lib/python3.8/site-packages/flamegraph/flamegraph.py", line 146, in main
start_time = time.clock()
AttributeError: module 'time' has no attribute 'clock'
Error in atexit._run_exitfuncs:
Traceback (most recent call last):
File "/Users/user/.pyenv/versions/my-venv-3.8.2/lib/python3.8/site-packages/flamegraph/flamegraph.py", line 99, in stop
self.join()
File "/Users/user/.pyenv/versions/3.8.2/lib/python3.8/threading.py", line 1006, in join
raise RuntimeError("cannot join thread before it is started")
RuntimeError: cannot join thread before it is started
At least for time.clock()
, it seems like there are alternatives in 3.8.
https://github.com/evanhempel/python-flamegraph/blob/master/flamegraph/flamegraph.py#L90 has a string that's split over multiple lines, but this is a syntax error for me. Easy fix is probably to just add some singlequotes to use the python parser's implicit string concatenation.
Hi there!
Thanks for sharing this, I'm really looking forward to putting your tool to good work :-)
I got here looking for a way to profile pip install
because it's much slower on some machines than others. I was hoping to profile it using flamegraph pip install ...
, but I take it that flamegraph
expects its first argument to be a file.
The coverage
tool supports this (ref for inspiration). Would you be willing to accept a contribution that adds something similar?
i cannot start it because No module named flamegraph.
but i have installed: pip install git+https://github.com/evanhempel/python-flamegraph.git
'''pip install git+https://github.com/evanhempel/python-flamegraph.git
Collecting git+https://github.com/evanhempel/python-flamegraph.git
Cloning https://github.com/evanhempel/python-flamegraph.git to /tmp/pip-req-build-0o57y8hm
Running command git clone -q https://github.com/evanhempel/python-flamegraph.git /tmp/pip-req-build-0o57y8hm
/home/yiwei/.local/lib/python3.8/site-packages/pkg_resources/init.py:123: PkgResourcesDeprecationWarning: 0.23ubuntu1 is an invalid version and will not be supported in a future release
warnings.warn(
/home/yiwei/.local/lib/python3.8/site-packages/pkg_resources/init.py:123: PkgResourcesDeprecationWarning: 1.13.1-unknown is an invalid version and will not be supported in a future release
warnings.warn(
/home/yiwei/.local/lib/python3.8/site-packages/pkg_resources/init.py:123: PkgResourcesDeprecationWarning: 0.1.36ubuntu1 is an invalid version and will not be supported in a future release
warnings.warn(
Building wheels for collected packages: flamegraph
Building wheel for flamegraph (setup.py) ... done
Created wheel for flamegraph: filename=flamegraph-0.1-py3-none-any.whl size=5793 sha256=29005f3f6de44d87677934b3929f9ff5f527d75c4e229a204d17d24b7bde124e
Stored in directory: /tmp/pip-ephem-wheel-cache-x0ptsvmg/wheels/ef/34/64/fb50a5c67924972e8361d0641f1f1b56fa9f1ff8daad2550bb
Successfully built flamegraph
Installing collected packages: flamegraph
Successfully installed flamegraph-0.1
'''
what can i do here?
The sdist package at PyPI is missing LICENSE file.
I have a simple python web program which uses jinja2 and Quart, when I run python server_async.py, everything is fine. But when I run python -m flamegraph -o perf.log server_async.py, it reports errors:
...
File "server_async.py", line 254, in index
template = await render_template('index.html')
...
jinja2.exceptions.TemplateNotFound: index.html
I guess this is because flamegraph does not work with Quart and jinja2, right?
python-flamegraph should be available on PyPi, pip install python-flamegraph works.
I have a simple python web program which uses jinja2 and Quart, when I run python server_async.py, everything is fine. But when I run python -m flamegraph -o perf.log server_async.py, it reports errors:
...
File "server_async.py", line 254, in index
template = await render_template('index.html')
...
jinja2.exceptions.TemplateNotFound: index.html
I guess this is because flamegraph does not work with Quart and jinja2, right?
I would like to be able to pip install the latest version from PyPI with your awesome changes. :)
i.e. how to get a log for an individual request?
Now only the functions in the script that is profiled are added to the log. It would be really great to also know what takes time in functions from other modules imported by the profiled script.
Would you mind terribly uploading python-flamegraph to PyPI? It's a simple process:
python setup.py sdist register upload
(People will tell you to run twine upload
instead, because distutils do not verify SSL certificates, but I think that means you need to register the project manually via some web form, instead of having setup.py register
take care of everything.)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.