├── .gitignore ├── CHANGES ├── LICENSE ├── MANIFEST.in ├── Makefile ├── README.rst ├── examples ├── hello.py └── templates │ └── hello.html ├── flask_profile ├── __init__.py ├── static │ ├── css │ │ └── profiler.css │ ├── img │ │ ├── asc.gif │ │ ├── bg.gif │ │ ├── desc.gif │ │ └── profile.png │ └── js │ │ ├── jquery.js │ │ ├── jquery.tablesorter.js │ │ └── profiler.js └── templates │ └── _profile │ └── profiler.html └── setup.py /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | *.pyc 3 | *.pyo 4 | dist 5 | build 6 | *.egg 7 | *.egg-info 8 | -------------------------------------------------------------------------------- /CHANGES: -------------------------------------------------------------------------------- 1 | Changelog 2 | --------- 3 | 4 | Version 0.1 5 | ``````````` 6 | 7 | First public preview release. 8 | 9 | 10 | Version 0.2 11 | ``````````` 12 | 13 | Released on May 17th 2016 14 | 15 | - Fixed css/js url in profiler.html 16 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2014 by Shipeng Feng. 2 | 3 | Some rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are 7 | met: 8 | 9 | * Redistributions of source code must retain the above copyright 10 | notice, this list of conditions and the following disclaimer. 11 | 12 | * Redistributions in binary form must reproduce the above 13 | copyright notice, this list of conditions and the following 14 | disclaimer in the documentation and/or other materials provided 15 | with the distribution. 16 | 17 | * The names of the contributors may not be used to endorse or 18 | promote products derived from this software without specific 19 | prior written permission. 20 | 21 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 22 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 23 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 24 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 25 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 26 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 27 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 28 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 29 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 30 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | -------------------------------------------------------------------------------- /MANIFEST.in: -------------------------------------------------------------------------------- 1 | include LICENSE CHANGES *.py 2 | recursive-include flask_profile/static * 3 | recursive-include flask_profile/templates * 4 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | clean-pyc: 2 | find . -name '*.pyc' -exec rm -f {} + 3 | find . -name '*.pyo' -exec rm -f {} + 4 | find . -name '*~' -exec rm -f {} + 5 | 6 | lines: 7 | find . -name "*.py"|xargs cat|wc -l 8 | 9 | release: 10 | python setup.py register 11 | python setup.py sdist upload 12 | python setup.py bdist_wheel upload 13 | -------------------------------------------------------------------------------- /README.rst: -------------------------------------------------------------------------------- 1 | Flask-Profile 2 | ============= 3 | 4 | A profiler extension for finding bottlenecks in Flask application. 5 | 6 | Installation 7 | ------------ 8 | 9 | :: 10 | 11 | $ pip install Flask-Profile 12 | 13 | Usage 14 | ----- 15 | 16 | .. code:: python 17 | 18 | from flask import Flask, render_template_string 19 | from flask.ext.profile import Profiler 20 | 21 | app = Flask(__name__) 22 | # Flask-Profile is only actived under debug mode 23 | app.debug = True 24 | Profiler(app) 25 | 26 | @app.route('/') 27 | def index(): 28 | return render_template_string('
hello') 29 | 30 | app.run() 31 | 32 | You can also create the object once and configure the application later: 33 | 34 | .. code:: python 35 | 36 | profiler = Profiler() 37 | 38 | def create_app(): 39 | app = Flask(__name__) 40 | profiler.init_app(app) 41 | return app 42 | 43 | 44 | If you want the profiler collects data including Extensions, please make sure 45 | that the Extension is used after Flask-Profile: 46 | 47 | .. code:: python 48 | 49 | from flask.ext.session import Session 50 | from flask.ext.profile import Profiler 51 | 52 | Profiler(app) 53 | Session(app) 54 | 55 | .. note:: 56 | 57 | This only works if your response is one html page because the 58 | profiling result is showed in html. 59 | You can click the column name to sort in the page. 60 | 61 | Better 62 | ------ 63 | 64 | If you feel anything wrong, feedbacks or pull requests are welcome. 65 | -------------------------------------------------------------------------------- /examples/hello.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | Simple Hello 4 | ~~~~~~~~~~~~ 5 | 6 | Simple app to demo Flask-Profile. 7 | 8 | :copyright: (c) 2014 by Shipeng Feng. 9 | :license: BSD, see LICENSE for more details. 10 | """ 11 | import urllib 12 | 13 | from flask import Flask, render_template 14 | from flask.ext.profile import Profiler 15 | 16 | 17 | app = Flask(__name__) 18 | app.debug = True 19 | Profiler(app) 20 | 21 | 22 | @app.route('/') 23 | def index(): 24 | # urllib.urlopen('http://www.apple.com') 25 | return render_template('hello.html') 26 | 27 | 28 | if __name__ == "__main__": 29 | app.run() 30 | -------------------------------------------------------------------------------- /examples/templates/hello.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 |