flask-flamegraph helps you quickly understand:
- Where all the time is being spent in your endpoints
- How deep your callstacks are
- Where the lowest hanging fruit is for optimization
import flask
import flask_flamegraph
flask_flamegraph = flask_flamegraph.FlaskFlamegraph()
def create_app():
app = flas.Flask(__name__)
flask_flamegraph.init_app(app)
return app
if __name__ == '__main__':
app = create_app()
app.run()
After this, hit any of your routes, and navigate to http://localhost:5000/__flame__
Run the tests:
pytest
This plugin is largely based upon flask-debugtoolbar-flamegraph,
but with inspiration from sqltap for adding a separate __flame__
endpoint
to more naturally support json-only apis instead of template rendered pages.
Also, impossible to do without the flamegraph project iteself.