使用 Scalene 对 Python 代理工作负载进行分析
Use Scalene when a Python agent, tool server, or retrieval pipeline needs line-level CPU, GPU, and memory profiling before targeted optimization.
Prerequisites
Python project or script that reproduces the workload; Scalene CLI; local or staging permission to run profiling
Installation
Use the upstream install or setup path that matches your environment:
- conda install -c conda-forge scalene
Requirements and caveats from upstream:
- (tweet from Ian Ozsvald, author of High Performance Python)
- Python Profiler Links to AI to Improve Code Scalene identifies inefficiencies and asks GPT-4 for suggestions, IEEE Spectrum
- Episode 172: Measuring Multiple Facets of Python Performance With Scalene, The Real Python podcast
Basic usage or getting-started notes:
- [](https://anaconda.org/conda-forge/sca...
- <img width="571" alt="example proposed optimization" src="https://user-images.githubusercontent.com/1612723/211639968-37cf793f-3290-43d1-9282-79e579558388.png">
- python3 -m pip install -U scalene
- Source: https://github.com/1991513ccie-png/skills
- Extracted from upstream docs: https://raw.githubusercontent.com/plasma-umass/scalene/HEAD/README.md
Documentation
- https://github.com/1991513ccie-png/skills