official plugins for VizTracer; currently support tracing cpu and memory usage through psutil.
The prefered way to install vizplugins is via pip
pip install vizplugins
The vizplugin should be used with viztracer.
You can use VizTracer and the plugin by
viztracer --plugin vizplugins.cpu_usage -- my_script.py arg1 arg2
which will record the cpu percent of the process and generate a result.html
file in the directory you run this command, which you can open with Chrome.
The plugin samples cpu usage per 0.02s by default, but you can explicitly indicate the desired frequency at which to sample data per second
viztracer --plugin "vizplugins.cpu_usage -f 20" -- my_script.py arg1 arg2
which will sample data approximately 20 times per second, with a sampling interval of 0.05 second.
You can also trace the memory usage and cpu usage by
viztracer --plugin "vizplugins --cpu_usage --memory_usage" -- my_script.py arg1 arg2
which will record both the cpu and memory usage.
The below image is an example of the resulting html, which is called on an recursively defined fibonacci funtion.
The "cpu_usage" on the top indicates the corresponding cpu usage at each time period. The "memory_usage" have two colors, representing rss(Resident Set Size, the non-swapped physical memory) and vms(Virtual Memory Size). You can see the details by clicking on one of the periods.