django-cprofile-middleware==1.0.5
django-silk==5.1.0
snakeviz==2.2.0
pyprof2calltree==1.4.5
sudo apt install kcachegrind
MIDDLEWARE = [
'django_cprofile_middleware.middleware.ProfilerMiddleware',
...
]
DJANGO_CPROFILE_MIDDLEWARE_REQUIRE_STAFF = False
-
download statistics:
GET {{ _.url }}?prof&count=9999999&sort=cumtime&download
-
analyze the profiling results:
snakeviz /tmp/cprofile.bin
-
download statistics:
GET {{ _.url }}?prof&count=9999999&sort=cumtime&download
-
analyze the profiling results:
pyprof2calltree -i /tmp/cprofile.bin -o /tmp/cprofile.calltree` kcachegrind /tmp/cprofile.calltree
INSTALLED_APPS = [
'silk',
...
]
MIDDLEWARE = [
'silk.middleware.SilkyMiddleware',
...
]
SILKY_PYTHON_PROFILER = True
python manage.py makemigrations
python manage.py migrate
from django.urls import path, include
urlpatterns += [
path("silk/", include("silk.urls", namespace="silk"))
]
from silk.profiling.profiler import silk_profile
with snake_profile('some-descriptive-name'):
my_method()