yet_another_django_profiler package

Submodules

yet_another_django_profiler.conf module

Custom Django settings for Yet Another Django Profiler middleware

class yet_another_django_profiler.conf.LazySettings[source]

Bases: object

YADP_ENABLED[source]
YADP_FRACTION_PARAMETER[source]
YADP_MAX_CALLS_PARAMETER[source]
YADP_MODULE_PARENT_DIR_PATTERNS[source]
YADP_PATH_TO_MODULE_FUNCTION[source]
YADP_PATTERN_PARAMETER[source]
YADP_PROFILER_BACKEND[source]
YADP_PROFILE_PARAMETER[source]
path_to_module_function[source]

Resolve the function to use for converting paths to module names

yet_another_django_profiler.conf.path_to_module_name(path)[source]

Get the fully qualified module name for the given absolute path by making intelligent guesses about the PYTHONPATH.

yet_another_django_profiler.middleware module

Yet Another Django Profiler middleware implementation

class yet_another_django_profiler.middleware.ProfilerMiddleware[source]

Bases: object

Code profiling middleware which can display either a call graph PDF or a table of called functions ordered by the desired statistic. For the call graph, just append ”?profile” to the URL. For the graph generation to work, install Graphviz from http://www.graphviz.org/Download.php

For a statistics table, use the statistic you want to sort by as the parameter (such as ”?profile=time”). Sorting options include:

  • calls (call count)
  • cumulative (cumulative time)
  • file (file name)
  • module (file name)
  • pcalls (primitive call count)
  • line (line number)
  • name (function name)
  • nfl (name/file/line)
  • stdname (standard name)
  • time (internal time)

Additional parameters can be added when generating a statistics table:

  • fraction - The fraction of total function calls to display (the default of .2 is omitted if max_calls or pattern are specified)
  • max_calls - The maximum number of function calls to display
  • pattern - Regular expression filter for function display names

To get these instructions in the app if you forget the usage options, use ”?profile=help” in the URL.

Inspiration:

process_response(request, response)[source]
process_view(request, callback, callback_args, callback_kwargs)[source]
yet_another_django_profiler.middleware.func_strip_path(func_name)[source]

Replacement for pstats.func_strip_path which yields qualified module names

yet_another_django_profiler.middleware.text_response(response, content)[source]

Return a plain text message as the response content.

yet_another_django_profiler.middleware.which(program)[source]

Return the path of the named program in the PATH, or None if no such executable program can be found Used to make sure that required binaries are in place before attempting to call them.

yet_another_django_profiler.yadp_yappi module

class yet_another_django_profiler.yadp_yappi.YappiProfile[source]

Bases: object

Wrapper class that represents Yappi profiling backend with API matching the cProfile.

create_stats()[source]
disable()[source]
enable()[source]
runcall(func, *args, **kw)[source]

Module contents

Yet Another Django Profiler middleware

A django profiling middeware that tries to consolidate the best features of the ones that came before it. Originally described at http://blog.safariflow.com/2013/11/21/profiling-django-via-middleware/