Django Middleware for reporting very simple lightweight timing stats at end of ever page.
Project description
Django Stats Middleware
Django is one of the most popular Python web frameworks today.
When a Django site seems slow, it's nice to put some real number to to that. The Django Debug Toolbar is the go-to middleware solution for diagnosing Django performance among other things, but it is rather large, and slow itself, adding significantly to the load time of your pages. So it's in a bit of catch-22 bind for simple performance overviews.
For that reason I wrote this tiny little lightweight piece of middleware that reports at the bottom of every page a single line reporting some basic timing stats.
- Total Time: The time from the request arriving to the response being delivered.
- Python Time: Time spent running Python code
- DB Time: Time spent waiting on database queries
- Number of Queries: The number of database queries run
Where:
Python Time + DB Time = Total Time
Here's an example:
To use it just put it at the top of your Django Middleware stack:
MIDDLEWARE = (
'django_stats_middleware.StatsMiddleware',
...
That way Total Time will include the time spent in all other middleware as well as your site code.
It includes some minimal CSS and to include that in your site include it as an app (so Django knows to collect static files from it):
INSTALLED_APPS += (
'django_stats_middleware',
)
and in your template load the CSS:
{% load static %}
<link rel="stylesheet" type="text/css" href="{% static 'django-stats-middleware/css/default.css' %}" />
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
Built Distribution
File details
Details for the file django_stats_middleware-0.3.tar.gz
.
File metadata
- Download URL: django_stats_middleware-0.3.tar.gz
- Upload date:
- Size: 9.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.63.0 importlib-metadata/4.11.2 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.8.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6e98b44219e3cf4bf003a7c30d53d6426cc277e89f4226f3801a24c1efe75e69 |
|
MD5 | 475bef958fe3048c673ea4456e75b4b3 |
|
BLAKE2b-256 | 7be8afba9d45829cf7a3acb86d3c4530ebbf3e0b5ca6fcfabeac106eee0ff814 |
File details
Details for the file django_stats_middleware-0.3-py3-none-any.whl
.
File metadata
- Download URL: django_stats_middleware-0.3-py3-none-any.whl
- Upload date:
- Size: 9.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.63.0 importlib-metadata/4.11.2 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.8.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 937f54b617350e444afc95dcc805cb0c79d64fd3c1a004cb9a4e2f62028bdbdb |
|
MD5 | 2c569630aacd141b50349aa8c5bef50f |
|
BLAKE2b-256 | 7ca370f3b4c55fa4f0d1df938dc28340cb7a6d7628b6ad07718c64b423863886 |