分析

当特定的URL需要包括整个金字塔调度的精简分析时,金字塔调试工具栏对请求的分析可能有点限制。

金字塔CubicWeb提供了将请求作为 wsgi middleware 以及一些有助于分析基本功能的视图。

当给定“profile”选项时,视图和wsgi中间件将被激活。这可以在命令行上完成 (cubicweb-ctl pyramid --profile )或者在 金字塔设置文件 .

意见

启用分析时,将提供以下路由和相应的视图:

  • /_profile/ping :回答“ping”,不做任何其他操作。另请参见 cubicweb.pyramid.profile.ping() .

  • /_profile/cnx :收到CNX后回复“ping”。另请参见 cubicweb.pyramid.profile.cnx() .

典型用法

假设我们想衡量 cnx .

  • 在启用配置文件的情况下启动应用程序:

    $ cubicweb-ctl pyramid --no-daemon --profile --profile-dump-every 100
    
  • 使用“ab”或任何其他HTTP基准测试工具抛出大量请求:

    $ ab -c 1 -n 100 http://localhost:8080/_profile/cnx
    
  • 分析结果。我个人幻想 SnakeViz:

    $ snakeviz program.prof