On this page you find all important commands for the CLI tool py-spy. If the
command you are looking for is missing please ask our AI.
py-spy
Py-spy is a powerful command line tool used for profiling Python applications. It allows developers to analyze the performance of their programs by sampling the execution stack to identify bottlenecks and areas of improvement.
- It is written in Rust and can be easily installed using package managers like Homebrew or by directly downloading pre-built binaries.
- Py-spy supports profiling both CPU-bound and memory-bound applications, providing insights into how much time is spent on different functions.
- It uses the Linux perf_events subsystem for CPU profiling, making it highly efficient and accurate.
- Being a sampling profiler, it avoids the need for instrumentation or modifying the code, making it convenient for profiling third-party libraries or closed-source applications.
- Py-spy supports navigating the profile data using the Flamegraph format, which represents the call stack as a flame-like visualization.
- It can be integrated with other tools like web browsers or Jupyter notebooks to provide a more detailed analysis of the profiled data.
- Py-spy offers different sampling modes, allowing users to choose the sampling frequency according to their specific requirements.
- It can generate detailed reports with information on the number of samples, CPU time, memory usage, and more for each function.
- Py-spy has minimal overhead, ensuring that the profiling process does not significantly impact the performance of the profiled application.
- It is compatible with both Python 2.x and Python 3.x, making it suitable for a wide range of Python projects.
List of commands for py-spy:
-
py-spy:tldr:01d9d py-spy: Show a live view of the functions that take the most execution time of a running process.$ py-spy top --pid ${pid}try on your machineexplain this command
-
py-spy:tldr:4af81 py-spy: Dump the call stack of a running process.$ py-spy dump --pid ${pid}try on your machineexplain this command
-
py-spy:tldr:83d59 py-spy: Produce an SVG flame graph of the function call execution time.$ py-spy record -o ${path-to-profile-svg} --pid ${pid}try on your machineexplain this command