# Path: speedinfo/profiler.py
# class Profiler(object):
#     PROFILER_STATE_CACHE_KEY = "speedinfo.profiler.is_on"
#     def __init__(self):
#     def is_on(self):
#     def is_on(self, value):
#     def storage(self):
# 
# Path: speedinfo/conditions/dispatcher.py
# class ConditionsDispatcher:
#     def __init__(self):
#     def import_conditions(self):
#     def get_conditions(self):
# 
# Path: speedinfo/conf.py
# DEFAULTS = {
#     "SPEEDINFO_TESTS": False,
#     "SPEEDINFO_CACHED_RESPONSE_ATTR_NAME": "_is_cached",
#     "SPEEDINFO_STORAGE": None,
#     "SPEEDINFO_CACHE_STORAGE_CACHE_ALIAS": "default",
#     "SPEEDINFO_PROFILING_CONDITIONS": [],
#     "SPEEDINFO_EXCLUDE_URLS": [],
#     "SPEEDINFO_ADMIN_COLUMNS": (
#         ("View name", "{}", "view_name"),
#         ("HTTP method", "{}", "method"),
#         ("Anonymous calls", "{:.1f}%", "anon_calls_ratio"),
#         ("Cache hits", "{:.1f}%", "cache_hits_ratio"),
#         ("SQL queries per call", "{}", "sql_count_per_call"),
#         ("SQL time", "{:.1f}%", "sql_time_ratio"),
#         ("Total calls", "{}", "total_calls"),
#         ("Time per call", "{:.8f}", "time_per_call"),
#         ("Total time", "{:.4f}", "total_time"),
#     ),
# }
# class SpeedinfoSettings:
#     def __init__(self, defaults=None):
#     def __getattr__(self, name):


from timeit import default_timer
from django.conf import settings
from django.db import connections
from speedinfo import profiler
from speedinfo.conditions.dispatcher import conditions_dispatcher
from speedinfo.conf import speedinfo_settings
    from django.urls import resolve, Resolver404  # Django >= 1.10
    from django.core.urlresolvers import resolve, Resolver404
            return resolve(request.path)._func_path
        except Resolver404:
            return None

    def can_process_request(self, request):
        """Checks conditions to start profiling the request

        :type request: :class:`django.http.HttpRequest`
        :return: True if request can be processed
        :rtype: bool
        """
        ok = profiler.is_on and self.get_view_name(request)

        for condition in conditions_dispatcher.get_conditions():
            ok = ok and condition.process_request(request)

            if not ok:
                break

        return ok

    def can_process_response(self, response):
        """Checks conditions to finish profiling the request

        :type response: :class:`django.http.HttpResponse`
        :return: True if request can be processed
        :rtype: bool
        """
        ok = True


# Path: speedinfo/profiler.py
# class Profiler(object):
#     PROFILER_STATE_CACHE_KEY = "speedinfo.profiler.is_on"
#     def __init__(self):
#     def is_on(self):
#     def is_on(self, value):
#     def storage(self):
# 
# Path: speedinfo/conditions/dispatcher.py
# class ConditionsDispatcher:
#     def __init__(self):
#     def import_conditions(self):
#     def get_conditions(self):
# 
# Path: speedinfo/conf.py
# DEFAULTS = {
#     "SPEEDINFO_TESTS": False,
#     "SPEEDINFO_CACHED_RESPONSE_ATTR_NAME": "_is_cached",
#     "SPEEDINFO_STORAGE": None,
#     "SPEEDINFO_CACHE_STORAGE_CACHE_ALIAS": "default",
#     "SPEEDINFO_PROFILING_CONDITIONS": [],
#     "SPEEDINFO_EXCLUDE_URLS": [],
#     "SPEEDINFO_ADMIN_COLUMNS": (
#         ("View name", "{}", "view_name"),
#         ("HTTP method", "{}", "method"),
#         ("Anonymous calls", "{:.1f}%", "anon_calls_ratio"),
#         ("Cache hits", "{:.1f}%", "cache_hits_ratio"),
#         ("SQL queries per call", "{}", "sql_count_per_call"),
#         ("SQL time", "{:.1f}%", "sql_time_ratio"),
#         ("Total calls", "{}", "total_calls"),
#         ("Time per call", "{:.8f}", "time_per_call"),
#         ("Total time", "{:.4f}", "total_time"),
#     ),
# }
# class SpeedinfoSettings:
#     def __init__(self, defaults=None):
#     def __getattr__(self, name):


# Path: speedinfo/middleware.py
from timeit import default_timer
from django.conf import settings
from django.db import connections
from speedinfo import profiler
from speedinfo.conditions.dispatcher import conditions_dispatcher
from speedinfo.conf import speedinfo_settings
    from django.urls import resolve, Resolver404  # Django >= 1.10
    from django.core.urlresolvers import resolve, Resolver404

            return resolve(request.path)._func_path
        except Resolver404:
            return None

    def can_process_request(self, request):
        """Checks conditions to start profiling the request

        :type request: :class:`django.http.HttpRequest`
        :return: True if request can be processed
        :rtype: bool
        """
        ok = profiler.is_on and self.get_view_name(request)

        for condition in conditions_dispatcher.get_conditions():
            ok = ok and condition.process_request(request)

            if not ok:
                break

        return ok

    def can_process_response(self, response):
        """Checks conditions to finish profiling the request

        :type response: :class:`django.http.HttpResponse`
        :return: True if request can be processed
        :rtype: bool
        """
        ok = True


        for condition in conditions_dispatcher.get_conditions():