cherrypy.lib.profiler模块

Cherrypy的分析器工具。

Cherrypy用户

您可以按如下方式分析任何页面:

from cherrypy.lib import profiler

class Root:
    p = profiler.Profiler("/path/to/profile/dir")

    @cherrypy.expose
    def index(self):
        self.p.run(self._index)

    def _index(self):
        return "Hello, world!"

cherrypy.tree.mount(Root())

您还可以使用 make_app 充当wsgi中间件。

奇瑞派开发者

此模块可以在您对Cherrypy进行更改时使用,以快速检查CP的总体性能。使用 --profile 运行测试套件时标记。然后,使用 serve() 函数在Web浏览器中浏览结果。如果从命令行运行此模块,它将调用 serve() 为你。

class cherrypy.lib.profiler.ProfileAggregator(path=None)[源代码]

基类:cherrypy.lib.profiler.Profiler

run(func, *args, **params)[源代码]

将配置文件数据转储到self.path。

class cherrypy.lib.profiler.Profiler(path=None)[源代码]

基类:object

index()[源代码]
menu()[源代码]
report(filename)[源代码]
run(func, *args, **params)[源代码]

将配置文件数据转储到self.path。

statfiles()[源代码]
返回类型

list of available profiles.

stats(filename, sortby='cumulative')[源代码]
RTYPE状态(索引)

输出给定配置文件的print_stats()。

class cherrypy.lib.profiler.make_app(nextapp, path=None, aggregate=False)[源代码]

基类:object

cherrypy.lib.profiler.new_func_strip_path(func_name)[源代码]

通过添加 __init__ 模块的父级

cherrypy.lib.profiler.serve(path=None, port=8080)[源代码]