Profiler tools for CherryPy.

CherryPy users

You can profile any of your pages as follows:

from cherrypy.lib import profiler

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

    def index(self): = True

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


You can also turn on profiling for all requests using the make_app function as WSGI middleware.

CherryPy developers

This module can be used whenever you make changes to CherryPy, to get a quick sanity-check on overall CP performance. Use the --profile flag when running the test suite. Then, use the serve() function to browse the results in a web browser. If you run this module from the command line, it will call serve() for you.


class cherrypy.lib.profiler.Profiler(path=None)
run(func, *args, **params)

Dump profile data into self.path.

Return type:list of available profiles.
stats(filename, sortby='cumulative')
Rtype stats(index):
 output of print_stats() for the given profile.
class cherrypy.lib.profiler.ProfileAggregator(path=None)
class cherrypy.lib.profiler.make_app(nextapp, path=None, aggregate=False)



Make profiler output more readable by adding __init__ modules’ parents

cherrypy.lib.profiler.serve(path=None, port=8080)