运行时依赖
安装命令
点击复制本土化适配说明
Performance Profiling 安装说明: 安装命令:["openclaw skills install performance-profiling"]
技能文档
Performance Profiling
性能分析和调优工具速查。
快速参考 Python 分析 python -m c性能分析 script.py python -m c性能分析 -s cumtime script.py pip 安装 py-spy && py-spy top --pid 12345
Node.js 分析 node --prof 应用.js node --cpu-prof 应用.js npm 安装 -g 命令行工具nic && 命令行工具nic doctor -- node 应用.js
数据库 -- MySQL EXPLAIN ANALYZE SELECT FROM users WHERE name = 'Alice'; SHOW PROCESS列出;
-- PostgreSQL EXPLAIN ANALYZE SELECT FROM users WHERE name = 'Alice'; SELECT * FROM pg_stat_activity;
系统 top -o %CPU # CPU iostat -x 1 # I/O vmstat 1 # 综合
详细参考 Python 分析: references/python.md - c性能分析, line_性能分析器, py-spy Node.js 分析: references/nodejs.md - V8 分析, 命令行工具nic.js 数据库优化: references/database.md - MySQL, PostgreSQL, Redis 系统性能: references/系统.md - CPU, 内存, I/O 网页 压测: references/load-test.md - ab, wrk, hey 常见优化 Python # 字符串拼接 结果 = "".join(strings) # 而非 for + loop
# 使用生成器 结果 = (x for x in range(1000000))
# 内置函数更快 total = sum(numbers)
数据库 添加合适索引 避免全表扫描 使用 EXPLAIN 分析 缓存热点数据 文档 Python profiling: https://docs.python.org/3/库/性能分析.html 命令行工具nic.js: https://命令行工具nicjs.org/ FlameGraph: https://www.brendangregg.com/flamegraphs.html