Profyle, a development tool for analysing and managing python traces
Project description
Development tool for analysing and managing python traces
Why do you need Profyle?
Bottlenecks
With Profyle you can easily detect where in your code you have a bottleneck, simply analyze the trace and see what function or operation is taking most of the execution time of the request
Enhance performace
Analyze the traces and decide which parts of your code should be improved
Installation
$ pip install profyle
---> 100%
Example
1. Implement
In order to track all your API requests you must implement the ProfyleMiddleware
ProfyleMiddleware
- enabled : Default true. You can use an env variable to decide if profyle is enabled.
- pattern: Profyle only will trace those paths that match with pattern (glob pattern)
FastAPI
from fastapi import FastAPI
from profyle.fastapi import ProfyleMiddleware
app = FastAPI()
app.add_middleware(ProfyleMiddleware, pattern='*/api/v2/*')
@app.get("/items/{item_id}")
async def read_item(item_id: int):
return {"item_id": item_id}
Flask
from flask import Flask
from profyle.flask import ProfyleMiddleware
app = Flask(__name__)
app.wsgi_app = ProfyleMiddleware(app.wsgi_app, pattern='*/api/products*')
@app.route("/")
def hello_world():
return "<p>Hello, World!</p>"
Django
Soon..2. Run
- Run the web server:
$ profyle start
INFO: Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit)
INFO: Started reloader process [28720]
INFO: Started server process [28722]
INFO: Waiting for application startup.
INFO: Application startup complete.
3. List
- List all requests tracing:
4. Analyze
- Profyle stands on the shoulder of giants: Viztracer and Perfetto
- Detailed function entry/exit information on timeline with source code
- Super easy to use, no source code change for most features, no package dependency
- Supports threading, multiprocessing, subprocess and async
- Powerful front-end, able to render GB-level trace smoothly
- Works on Linux/MacOS/Window
CLI Commands
start
- Start the web server and view profile traces
$ profyle start
INFO: Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit)
INFO: Started reloader process [28720]
INFO: Started server process [28722]
INFO: Waiting for application startup.
INFO: Application startup complete.
clean
- Delete all profile traces
$ profyle clean
10 traces removed
check
- Check traces DB size
$ profyle check
DB size: 30MB
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
profyle-0.1.0.tar.gz
(120.6 kB
view hashes)
Built Distribution
profyle-0.1.0-py3-none-any.whl
(124.4 kB
view hashes)