perf_agent is a Python 3.11+ performance analysis prototype. It accepts an executable, command, or PID, profiles it with available system tools, converts raw profiler output into structured evidence, and writes Markdown/HTML reports under runs/<run_id>/.
python -m venv .venv
. .venv/bin/activate
pip install -e ".[dev]"
cp .env.example .envThe LLM client reads OpenAI-compatible settings from .env in this order:
- API key:
OPENAI_API_KEY,LLM_API_KEY,DEEPSEEK_API_KEY - model:
PERF_AGENT_MODEL,LLM_MODEL_ID,DEEPSEEK_MODEL - base URL:
OPENAI_BASE_URL,LLM_BASE_URL,DEEPSEEK_BASE_URL
Set PERF_AGENT_DISABLE_LLM=1 to force deterministic fallbacks.
Set PERF_AGENT_DISABLE_ADB=1 for host-only runs that should not probe ADB devices.
./examples/build_examples.sh
perf-agent analyze --task examples/tasks/cpu_bound.json
perf-agent analyze --task-note examples/tasks/cpu_bound.task.md
perf-agent analyze -- examples/bin/cpu_bound_demo
perf-agent interactiveanalyze accepts three interface styles:
--task path.jsonfor structured, repeatable runs.--task-note path.mdfor human-editable task notes with fields such asgoal:,command:,source_dir:, andmax_rounds:.- Direct CLI flags (
--cmd,--exe,--pid, or command tokens after--) for quick ad-hoc runs.
Profiling actions are intentionally executed serially by default to avoid multiple target instances contaminating perf counters. Parsing can be parallelized with PERF_AGENT_PARSE_WORKERS=<n>.
For local development:
.venv/bin/python -m pytestsrc/perf_agent/: package sourceconfigs/: tool, event, rule, safety, and prompt configurationexamples/: sample workloads and C++ demo programstests/: regression teststool_docs/: tool capability notes used by Toolsmithdocs/reports/: design/report notesdocs/reference/: captured profiler event listsruns/: generated analysis artifacts, ignored by git
The older long-form design document is kept at docs/README-Old.md.
The current multi-agent engineering design and refactor target is docs/engineering_design.md.