一键导入
performance-profiler
Performance analysis and optimization workflow. Use when investigating slow operations, profiling code, or optimizing resource usage.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Performance analysis and optimization workflow. Use when investigating slow operations, profiling code, or optimizing resource usage.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Safe, deny-by-default intake workflow for the T3MP3ST offensive-security capability candidate.
Multi-Agent Collaboration Skill
Security audit and vulnerability scanning workflow. Use when reviewing code for security issues, checking configurations, or validating hardening measures.
Context Efficiency Skill
System Dev Skill — NixOS-Dev-Quick-Deploy Harness
Query structured wiki sections in .understand-anything/wiki/ for subsystem overviews, architecture, and function discovery — before reading raw files
| name | performance-profiler |
| description | Performance analysis and optimization workflow. Use when investigating slow operations, profiling code, or optimizing resource usage. |
Provides systematic performance analysis patterns for identifying bottlenecks and optimizing code. Focuses on measurement-driven optimization with clear before/after metrics.
Always measure before optimizing.
# API latency baseline
for i in {1..10}; do
curl -w "%{time_total}\n" -o /dev/null -s http://127.0.0.1:8003/health
done | awk '{sum+=$1} END {print "Avg:", sum/NR, "s"}'
# Service resource baseline
systemctl show <service>.service --property=MemoryCurrent,CPUUsageNSec
| Type | Symptoms | Tools |
|---|---|---|
| CPU-bound | High CPU%, slow computation | top, py-spy, perf |
| Memory-bound | High memory, GC pauses | memory_profiler, tracemalloc |
| I/O-bound | Wait time, blocking calls | strace, iotop, async |
| Network-bound | Latency, connection delays | curl -w, tcpdump |
# CPU profiling
python3 -m cProfile -s cumtime <script.py> | head -30
# Line profiling (install line_profiler)
kernprof -l -v <script.py>
# Memory profiling
python3 -m memory_profiler <script.py>
# Live profiling
py-spy top --pid $(pgrep -f <process>)
py-spy record -o profile.svg --pid $(pgrep -f <process>)
# Process stats
pidstat -p $(pgrep <process>) 1 10
# I/O stats
iotop -p $(pgrep <process>)
# System calls
strace -c -p $(pgrep <process>)
# PostgreSQL slow query log
psql -U ai_user -d aidb -c "SELECT query, calls, mean_time FROM pg_stat_statements ORDER BY mean_time DESC LIMIT 10;"
# Explain analyze
psql -U ai_user -d aidb -c "EXPLAIN ANALYZE <your-query>;"
# Check Redis cache stats
redis-cli info stats | grep -E "keyspace_hits|keyspace_misses"
# Calculate hit rate
redis-cli info stats | awk -F: '/keyspace/ {print $1, $2}'
# Check connection count
ss -s
psql -U ai_user -d aidb -c "SELECT count(*) FROM pg_stat_activity;"
# Re-run baseline measurement
for i in {1..10}; do
curl -w "%{time_total}\n" -o /dev/null -s http://127.0.0.1:8003/health
done | awk '{sum+=$1} END {print "Avg:", sum/NR, "s"}'
# Compare with baseline
echo "Baseline: X.XXs -> New: Y.YYs = Z% improvement"
# Memory usage by service
systemctl show ai-*.service --property=MemoryCurrent | sort -t= -k2 -h
# CPU usage snapshot
top -b -n 1 | grep -E "ai-|llama|python"
# Service timing
systemd-analyze blame | head -10
# Route search latency
scripts/ai/aq-report --format=json | jq '.route_search_latency_decomposition.overall_p95_ms'
# Semantic cache performance
scripts/ai/aq-report --format=json | jq '.semantic_cache_hit_rate'
# LLM inference latency
curl -sS http://127.0.0.1:8080/health | jq '.stats'
# Simple concurrent requests
seq 10 | xargs -P 10 -I {} curl -s -o /dev/null -w "%{time_total}\n" http://127.0.0.1:8003/health
# With timing summary
ab -n 100 -c 10 http://127.0.0.1:8003/health