提供页面加载时间的细分
django-speedbar的Python项目详细描述
Django SpeedBar检测页面加载过程中的关键事件(数据库 查询、模板呈现、url解析等)并提供摘要 每个页面加载的信息,以及与google chrome的集成 SpeedTracer显示页面加载中发生的事件树。
它被设计为在实时站点上运行,对性能的影响最小。 虽然所有请求都被监视,但结果只对用户可见 带着国旗。
安装
若要安装Django SpeedBar,请将其添加到已安装的应用程序、URL中,并添加 SpeedBar中间件。
# settings.pyINSTALLED_APPS=[# ...'speedbar',# ...]# For best results put speedbar as near to the top of your middleware# list as possible. django-speedbar listens to the django request_finished# signal so actions performed by middleware higher up the stack will still# be recorded, but will not be included in summary data.MIDDLEWARE_CLASSES=['speedbar.middleware.SpeedbarMiddleware',# ...]
# urls.pyurlpatterns=patterns('',# ...(r'^speedbar/',include('speedbar.urls')),# ...)
要在SpeedTracer中查看结果,还需要安装 SpeedTracer plugin。
要在页面中包含摘要信息,可以使用metric模板 标签
{% load speedbar %} <divclass="speedbar"><span>Overall: {% metric "overall" "time" %} ms</span><span>SQL: {% metric "sql" "count" %} ({% metric "sql" "time" %} ms)</span><!-- ... --></div>
配置
Django SpeedBar有许多配置设置。
# Enable instrumentation of page load processSPEEDBAR_ENABLE=True# Enable the summary data template tagsSPEEDBAR_PANEL=True# Include headers needed to show page generation profile tree in the# Google Chrome SpeedTracer plugin.SPEEDBAR_TRACE=True# Include response headers with summary data for each request. These are# intended for logging and are included in all requests, not just staff# requests. If you turn this on we recommend configuring your load# balancer to strip them before sending the response to the client.SPEEDBAR_RESPONSE_HEADERS=False# Configure which instrumentation modules to load. This should not# normally be necessary for built in modules as they will only load# if the relevant clients are installed, but is useful for adding# additional custom modules.SPEEDBAR_MODULES=['speedbar.modules.stacktracer',# Most other modules depend on this one'speedbar.modules.pagetimer','speedbar.modules.sql','myproject.modules.sprockets',# ...]
状态
我们的生产系统安装了Django Speedbar。但是,api 不稳定,可能会改变。它还没有任何违约 模板,以便更容易地使用页面上的功能。
类似项目
有许多类似的项目你可能也要考虑 或者代替Django Speedbar。
django调试工具栏
网址:https://github.com/django-debug-toolbar/django-debug-toolbar
德詹戈佩奇的瑞士军刀检查。成熟,广泛使用,和 有很多可用的插件。它更注重调试和 信息,较少关注绩效衡量。我们也找到了 在我们的生产现场运行缓慢。
django live profiler
网址:http://invitebox.github.io/django-live-profiler/
用于django应用程序的站点范围探查器。我没用过这个,所以 无法对此发表评论。
学分
Django Speedbar主要是由西奥·斯皮尔斯在Mixcloud工作时写的。