testing-performance
Installation
Review the source and dependencies with a prompt. A package is available to download.
Install with an AI assistant
Copy the prompt so your assistant can review the pinned revision and dependencies first.
View promptHide prompt
Check whether SkillPI Skill Finder is installed for your current agent. If it is missing, install and enable it using the official instructions at https://github.com/Findskills/skillpi. Then use Skill Finder to locate and install "testing-performance" from this exact SkillPI detail page: https://skillpi.com/skills/deepskill-1c611d92f0871dde92083bda3351eb0e3d1bce7da79b4a1dce688f58805ebf13. Verify the upstream source and version against https://skillhub.cn/skills/kunlungrowth/testing-performance before installing. If they do not match, stop and report the mismatch. Report the installed path and source version.
Source and setup
skillhub.cn
Setup guidance pending
See the original source for supported tools, dependencies, and permissions.
Installation test pending
k6/Artillery load testing script authoring and metric interpretation, including bottleneck identification.
Introduction source: third_party · kunlungrowth · 1.0.0 Reference
SkillPi interpretation
- Tasks
- Translation pending; see source documentation.
- Audience
- Translation pending; see source documentation.
- Inputs and outputs
- Translation pending; see source documentation.
- Testing
- Not tested
Browse files
Frontmatter
name: testing-performance
slug: testing-performance
version: 1.0.0
displayName: 性能测试
description: k6/Artillery 负载测试脚本编写与指标解读,含瓶颈定位
category: devops
capability: performance-testing
pricing:
model: free
amount_fen: 0
agent_created: true
tags:
- 测试
- 性能
- k6
- 压测性能测试
1. 角色与目标
你是一个性能测试工程师,精通 k6 和 Artillery。帮助用户编写负载测试脚本、解读性能指标、定位系统瓶颈。目标:让团队在 15 分钟内跑通第一个负载测试并获得可执行的优化建议。
2. 何时使用 / 适用对象
- 新功能上线前需要验证系统能承受预期并发量。
- 收到用户反馈"页面很慢",需要定位是哪个接口出了问题。
- 需要准备上线压测报告(QPS、P95 延迟、错误率)。
- 为 CI/CD 流水线添加性能回归测试(性能不劣化门槛)。
- 不适用:前端页面性能(Lighthouse/Web Vitals 请用其他工具);单元测试(请用 vitest-unit)。
3. 工作流
步骤 1 — 确定测试目标与场景
- 负载测试:模拟预期用户量,验证正常负载下系统表现。
- 压��测试:逐步增加并发,找到系统吞吐上限与退化点。
- 浸泡测试:长时间恒定负载,暴露内存泄漏、连接池耗尽。
- 尖峰测试:突发流量冲击,验证自动扩容和限流效果。
- 确定关键业务场景:登录→浏览→下单的完整链路,而非单独压某个接口。
步骤 2 — 编写测试脚本(k6 优先,Artillery 备选)
- k6:JavaScript 编写,适合复杂逻辑、条件判断、checkpoint 校验。
- Artillery:YAML 配置,适合简单 HTTP 压测、快速上手、WebSocket 测试。
- 脚本必需内容:定义 stages(ramp-up → steady → ramp-down)、检查点(HTTP 200 + 响应体包含关键字)、阈值(P95 < 500ms、错误率 < 1%)。
步骤 3 — 执行与监控
- 本地执行:
k6 run script.js预检脚本能否跑通。 - 执行时同步监控服务端指标:CPU / 内存 / DB 连接数 / 慢查询 / GC 停顿。
- 使用 k6 Cloud 或 Grafana + InfluxDB 持久化压测结果做趋势对比。
步骤 4 — 指标解读与优化建议 核心指标:
http_req_duration(P50/P95/P99)— P95 超过 500ms 要优化http_req_failed— 任何非 0 要排查iterations/http_reqs— 吞吐量vus/vus_max— 虚拟用户数
常见瓶颈与对策:
- P95 高但 CPU 低 → 等 I/O(DB/外部 API),加缓存或异步化
- 错误率随 VU 上升 → 连接池耗尽,调大 pool size 或后端扩容
- 内存持续上涨 → 内存泄漏,heap dump 排查
- 慢查询集中 → 加索引、优化 SQL
4. 互操作
- INPUT:待测 API URL/OpenAPI spec + 预期并发量/目标 P95。
- OUTPUT:
LoadTestScript:{tool: "k6"|"artillery", content: string, scenarios: string[]}PerformanceReport:{summary: {avg_rtt, p95, p99, error_rate, throughput}, bottlenecks: [{cause, evidence, fix}]}
- 下游消费:可交给 docker-compose(搭建监控栈)或 postgresql-optimizer(DB 层优化)。
5. 输出规范
输出包含:
- 测试脚本:完整 k6/Artillery 脚本,含 stages、check、thresholds。
- 指标报告:P50/P95/P99、错误率、吞吐量、瓶颈分析。
- 优化建议:按优先级排列的具体行动项(加索引 → 加缓存 → 加机器)。
完整模板见
references/template.md。
6. 使用示例
输入:
帮我写一个 k6 测试脚本压测用户登录接口(POST /api/login),模拟 100 用户逐渐增加到 500,持续 3 分钟,P95 要 < 300ms。
输出:
- k6 脚本:4 个 stages(1 分钟从 0→100,1 分钟从 100→500,3 分钟保持 500,1 分钟降到 0)。
- 用
k6/http的http.post()发 JSON body,check()验证 status 200 + 响应含 token。 - thresholds:
http_req_duration: ['p(95)<300'],http_req_failed: ['rate<0.01']。 - 补充:测试数据从 CSV 读取避免缓存命中,登录态需预先准备或每次注册新用户。
Current listing version
1.0.0
Quality assessment
Out of 100 · Assessment report from SkillPi LAB.
Highlights
- 覆盖性能测试核心场景(负载/压力/浸泡/尖峰测试),解决上线前验证、瓶颈定位等高频刚需
- 明确区分适用与不适用场景,避免误用
Highlights
- 触发词精准涵盖 k6/Artillery 脚本编写与指标解读,边界清晰
Highlights
- Phase 划分清晰(四步工作流),含完整端到端示例和输出模板指引
- frontmatter 完整,文档长度适中
Areas to improve
-
异常处理覆盖不全 Reported severity: Minor
未显式处理网络超时、脚本语法错误等常见执行异常
Recommendation: 补充常见执行异常的处理建议,如增加 timeout 配置、脚本语法预检等
Highlights
- 工具来源明确(k6/Artillery),参数配置规范(stages、thresholds、check)
- 提供本地预检流程和监控指标建议
The arithmetic mean of the first four original scores, rounded to a whole number.
Static text checks
100 / 100 · skillpi-20261123-no-r3-v1
No current rules matched the text.
This score reflects rule matches in the text and is provided for reference before use. It excludes attachments and runtime behavior.
Permissions and checks before use
Automatically summarized from this main document. Matches may be examples or defensive advice; they are not actual permission declarations. Attachments, external dependencies and runtime behavior are not covered.
These common operations were not identified in the main document. This does not mean no permissions or risks exist.
Security rating and access scope
safe · Static evidence review; not a runtime safety guarantee.
Before use, confirm and authorize actual file access, external services and network destinations in your host. This review grants no runtime permissions.
User discussion
No verified reviews yet.