Skip to main content

A panel for django-debug-toolbar that integrates information from line_profiler

Project description

Codacy Badge Requirements Status

The Django Debug Toolbar is a configurable set of panels that display various debug information about the current request/response and when clicked, display more details about the panel’s content.

This package provides a panel that incorporates output from line_profiler

This panel will only function with django_debug_toolbar>=1.0, before that it’s functionality was contained in the debug_toolbar.panels.profiling.ProfilingPanel.

This Django Debug Toolbar panel is released under the BSD license, like Django and the Django Debug Toolbar. If you like it, please consider contributing!

The Django Debug Toolbar was originally created by Rob Hudson in August 2008 and was further developed by many contributors.

Installation

To install the line_profiler panel, first install this package with pip install django-debug-toolbar-line-profiling, then add debug_toolbar_line_profiler to the INSTALLED_APPS:

INSTALLED_APPS = (
    ...
    'debug_toolbar_line_profiler',
)

and add the panel to DEBUG_TOOLBAR_PANELS:

DEBUG_TOOLBAR_PANELS = (
    ...
    'debug_toolbar_line_profiler.panel.ProfilingPanel',
)

Configuration

By default, the panel will profile your view function. If you use class based views the panel will profile all functions on the class that don’t start with _. If you want additional code to be profiled, add the @profile_additional decorator like so:

from debug_toolbar_line_profiler import profile_additional
from boto.s3.connection import S3Connection

...

@profile_additional(S3Connection.make_request)
def your_view_code(*args, **kwargs):
    ...

Signals

There is also a signal (debug_toolbar_line_profiler.signals.profiler_setup) that you can attach to for integrating class based views like django rest framework.

Here is an example:

from rest_framework.viewsets import ViewSet
from rest_framework.response import Response
from debug_toolbar_line_profiler import signals


class AViewSet(ViewSet):
    def list(self, request):
        return Response([])

    def retrieve(self, request, pk=None):
        return Response({})


def register_profile_views(sender, profiler, **kwargs):
    profiler.add_function(AViewSet.list)
    profiler.add_function(AViewSet.retrieve)


signals.profiler_setup.connect(register_profile_views,
                               dispatch_uid='register_profile_views')

Project details


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-debug-toolbar-line-profiling-0.8.0.tar.gz.

File metadata

File hashes

Hashes for django-debug-toolbar-line-profiling-0.8.0.tar.gz
Algorithm Hash digest
SHA256 0f15020fa3447d7a984b807c05d930cb93484f4b0325f7d54feff8dafc6b85bc
MD5 07103540ca6a8982b41dad3de7d05aaf
BLAKE2b-256 44b8c1a8c96cbc1e0cff33f9530849360f111255b280b310f5600684fb3aa392

See more details on using hashes here.

File details

Details for the file django_debug_toolbar_line_profiling-0.8.0-py3-none-any.whl.

File metadata

File hashes

Hashes for django_debug_toolbar_line_profiling-0.8.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1f46a043cf6c3906c075cdb20e687001e486d0077bc0d92a4a912f8a365852a7
MD5 b2282f095ea48a55348301ac8568ddb4
BLAKE2b-256 50d4aacc7e9ba2cd105474820289549240707ef97460e4efabddc3d5bdb92b52

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page