Metadata-Version: 2.1
Name: Flask-Perf
Version: 0.1.4
Summary: A simple profiler for flask applications.
Home-page: https://github.com/abetlen/Flask-Perf
Author: Andrei Betlen
Author-email: abetlen@gmail.com
License: MIT
Platform: any
Classifier: Environment :: Web Environment
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: BSD License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python
Classifier: Topic :: Internet :: WWW/HTTP :: Dynamic Content
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Description-Content-Type: text/markdown
Provides-Extra: flask_sqlalchemy
Requires-Dist: Flask
Provides-Extra: flask_sqlalchemy
Requires-Dist: flask-sqlalchemy; extra == 'flask_sqlalchemy'

# Flask-Perf

[![PyPI version](https://badge.fury.io/py/Flask-Perf.svg)](https://badge.fury.io/py/Flask-Perf)
[![Build Status](https://travis-ci.org/abetlen/Flask-Perf.svg?branch=master)](https://travis-ci.org/abetlen/Flask-Perf)

A Flask extension for code and database query profiling.

This profiler is an implementation of the methods described in this post [post](https://blog.miguelgrinberg.com/post/the-flask-mega-tutorial-part-xvi-debugging-testing-and-profiling) however the extension allows you to also control profiling through the application config.

## Installation

```bash
$ pip install flask_perf
```

## Example

```python
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](https://docs.python.org/dev/library/profile.html#pstats.Stats.print_stats) | `[]`   |
| `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"` |


