A simple profiler for flask applications.
Project description
Flask-Perf
A Flask extension for code and database query profiling.
This profiler is an implementation of the methods described in this post post however the extension allows you to also control profiling through the application config.
Installation
$ pip install flask_perf
Example
from flask import Flask, jsonify
from flask_perf import Profiler
app = Flask(__name__)
app.config["PROFILER_ENABLED"] = True
profiler = Profiler(app) # or profiler.init_app(app)
@app.route("/")
def index():
return jsonfiy({
"message": "Hello World!"
})
Configuration
Config Name | Description | default |
---|---|---|
PROFILER_ENABLED |
Enable the profiler. | False |
PROFILER_RESTRICTIONS |
List of profiler restrictions, described in depth in the Official Python Docs | [] |
PROFILER_SQLALCHEMY_ENABLED |
Enable SQLAlchemy query logging. Note: This option requires that the flask_sqlalchemy package is installed and the SQLALCHEMY_RECORD_QUERIES config option is set to True . |
False |
PROFILER_SQLALCHEMY_THRESHOLD |
Minimum query duration in seconds to log. | 0 |
PROFILER_SQLALCHEMY_FORMAT |
Logged SQLAlchemy query format. | "statement: {query}\nparameters: {parameters}\nduration: {duration}s\ncontext: {context}\n" |
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Flask-Perf-0.1.4.tar.gz
(2.9 kB
view hashes)
Built Distribution
Close
Hashes for Flask_Perf-0.1.4-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1998994fdfd5de8831ead8ba466b5acf62fd62829c8e52a2133ee8a8add446bf |
|
MD5 | e073c7c1363097cbe4c6f2ba54909c72 |
|
BLAKE2b-256 | e639ac2cf20494ca05e3fd5b8bf7c32809f474f7446a31a55680470a8a1ae511 |