- CPU Time: Time spent running on the CPU
- Wall-time: Elapsed time per function call
- Heap Live Size: Number of bytes allocated that are not yet garbage collected
- Allocated Memory: Number of bytes allocated in memory
- Allocations: Time spent running on the CPU
Prerequisites
Upsun Continuous Profiler requiresPython >=3.7.0.
Installation
The Blackfire Continuous Profiler Python library is included by default in all Python images matching its requirements. There is no installation required.Python continuous profiler API
The Python profiler API (profiler) can be initiated with the following options:
application_name: the application name.period: specifies the length at which to collect CPU profiles. The default is 45 seconds.upload_timeout: observability data upload timeout. The default is 10 seconds.labels: a dict containing the custom labels specific to the profile payload that is sent.
| Function | Description |
|---|---|
def start(): | The start function starts the continuous profiler probe. It collects profiling information in the background and periodically uploads it to the Blackfire Agent until the stop function is called. |
def stop(): | Stops the continuous profiling probe. |
Example
Here is an example of how you can initiate the Pythonprofiler on a basic app:
-
Create
example.pywith the following code: -
Run the app: