libb.ProfileMiddleware

class ProfileMiddleware(func, log=None, sort='time', count=20)[source]

Bases: object

WSGI middleware for profiling requests.

Parameters:
  • func – WSGI application callable.

  • log – Logger instance for output.

  • sort (str) – Profile sort key (default ‘time’).

  • count (int) – Number of top functions to show (default 20).

Warning

Should always be last middleware loaded: 1. You want to profile everything else 2. For speed, we return the result NOT the wrapped func