Geprofiler is a Python HTTP Server profiler that makes it easy to find slow code.
Project description
Geprofiler is a Python call stack profiler built on top of Pyinstrument but stripped of the unnecessary and focused on supporting features for HTTP Server.
Installation
$ pip install geprofiler
Geprofiler supports Python 3.7+. In addition, curl is required to be installed if you want to use
geprofiler.yaml
.
Usage
The examples below use Django to create a simple HTTP server that will be profiled by Geprofiler.
⚡ Quick start
To profile Django web requests:
- Add
geprofiler.middleware.ProfilerMiddleware
toMIDDLEWARE
in yoursettings.py
. - Once the server has been started, add
?geprofiler
(as a query param) to the end of a request URL you want to profile (alsogeprofiler
can also be added as a request header). As soon as the request is processed, a new browser tab will be opened to display the profile information. - Add
GEPROFILER_PROFILE_DIR = 'profiles'
to yoursettings.py
if you want the result page to be saved to the folderprofiles
in your working directory.
📋 Use geprofiler.yaml
Sometimes, you need a different solution to solve advanced problems. For example, you might want Geprofiler to automatically profile all the APIs you specified immediately, instead of spending too much time profiling each API manually. In this case, you can define a file geprofiler.yaml
in your working directory with a structure similar to the one below.
request
:
format
: the format of your request list.list
: a list of request statements corresponding to the format declared above.filter
:
min_duration
: the minimum duration that a request has taken in milliseconds.output_dir
: (optional) the folder that you want to save the result page in.
Finally, to start profiling, run:
$ geprofiler
Result:
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.