This module provides a web-based memory profiling interface. The Pympler web frontend exposes process information, tracker statistics, and garbage graphs. The web frontend uses Bottle, a lightweight Python web framework. Bottle is packaged with Pympler.
The web server can be invoked almost as easily as setting a breakpoint using pdb:
from pympler.web import start_profiler start_profiler()
start_profiler suspends the current thread and executes the Pympler
web server, exposing profiling data and various facilities of the Pympler
library via a graphic interface.
- pympler.web.start_profiler(host='localhost', port=8090, tracker=None, stats=None, debug=False, **kwargs)¶
Start the web server to show profiling data. The function suspends the Python application (the current thread) until the web server is stopped.
The only way to stop the server is to signal the running thread, e.g. press Ctrl+C in the console. If this isn’t feasible for your application use start_in_background instead.
During the execution of the web server, profiling data is (lazily) cached to improve performance. For example, garbage graphs are rendered when the garbage profiling data is requested and are simply retransmitted upon later requests.
The web server can display profiling data from previously taken snapshots when tracker or stats is specified. The former is useful for profiling a running application, the latter for off-line analysis. Requires existing snapshots taken with
host – the host where the server shall run, default is localhost
port – server listens on the specified port, default is 8090 to allow coexistance with common web applications
tracker – ClassTracker instance, browse profiling data (on-line analysis)
stats – Stats instance, analyze ClassTracker profiling dumps (useful for off-line analysis)
Start the web server in the background. A new thread is created which serves the profiling interface without suspending the current application.
For the documentation of the parameters see start_profiler.
Returns the created thread object.