Performance Testing

aj-geddes/useful-ai-prompts/skills/performance-testing

作者 aj-geddes3f5182cfd739无许可证355 个星标收录于 2026年10月8日更新于 2026年10月8日仓库7个月前更新

Design and execute performance tests to measure response times, throughput, and resource utilization. Use for performance test, load test, JMeter, k6, benchmark, latency testing, and scalability analysis.

AI 生成的概览

设计并执行性能与负载测试,测量延迟、吞吐量和资源占用。

功能
指导性能测试的设计与执行,涵盖响应时间、吞吐量、资源利用率和可扩展性。提供 k6 API 负载测试、Apache JMeter、pytest-benchmark、JMH、数据库查询性能和实时监控的参考资料,并给出带分阶段加压和阈值的 k6 快速入门脚本。还附带一个校验脚本和 API 脚手架模板,并列出使用百分位数、在类生产环境测试等最佳实践。
适用场景
适用于验证响应时间要求、测量 API 吞吐量与延迟、测试数据库查询性能或定位性能瓶颈。也适合优化前后的基准对比、验证缓存效果以及测试并发用户容量。
运行要求
会运行脚本:附带可执行校验脚本和 API 脚手架模板。参考资料假定使用 k6、Apache JMeter、pytest-benchmark、JMH 等工具,测试目标通常需要网络访问被测系统。

Performance Testing

Table of Contents

Overview

Performance testing measures how systems behave under various load conditions, including response times, throughput, resource utilization, and scalability. It helps identify bottlenecks, validate performance requirements, and ensure systems can handle expected loads.

When to Use

  • Validating response time requirements
  • Measuring API throughput and latency
  • Testing database query performance
  • Identifying performance bottlenecks
  • Comparing algorithm efficiency
  • Benchmarking before/after optimizations
  • Validating caching effectiveness
  • Testing concurrent user capacity

Quick Start

Minimal working example:

javascript
// load-test.jsimport http from "k6/http";import { check, sleep } from "k6";import { Rate, Trend } from "k6/metrics";
// Custom metricsconst errorRate = new Rate("errors");const orderDuration = new Trend("order_duration");
// Test configurationexport const options = {  stages: [    { duration: "2m", target: 10 }, // Ramp up to 10 users    { duration: "5m", target: 10 }, // Stay at 10 users    { duration: "2m", target: 50 }, // Ramp up to 50 users    { duration: "5m", target: 50 }, // Stay at 50 users    { duration: "2m", target: 0 }, // Ramp down to 0  ],  thresholds: {    http_req_duration: ["p(95)<500"], // 95% of requests under 500ms    http_req_failed: ["rate<0.01"], // Error rate under 1%    errors: ["rate<0.1"], // Custom error rate under 10%  },};
// ... (see reference guides for full implementation)

Reference Guides

Detailed implementations in the references/ directory:

GuideContents
k6 for API Load Testing [blocked]k6 for API Load Testing
Apache JMeter [blocked]Apache JMeter
pytest-benchmark for Python [blocked]pytest-benchmark for Python
JMH for Java Benchmarking [blocked]JMH for Java Benchmarking
Database Query Performance [blocked]Database Query Performance
Real-Time Monitoring [blocked]Real-Time Monitoring

Best Practices

✅ DO

  • Define clear performance requirements (SLAs)
  • Test with realistic data volumes
  • Monitor resource utilization
  • Test caching effectiveness
  • Use percentiles (P95, P99) over averages
  • Warm up before measuring
  • Run tests in production-like environment
  • Identify and fix N+1 query problems

❌ DON'T

  • Test only with small datasets
  • Ignore memory leaks
  • Test in unrealistic environments
  • Focus only on average response times
  • Skip database indexing analysis
  • Test only happy paths
  • Ignore network latency
  • Compare without statistical significance

来源与署名

来源:aj-geddes/useful-ai-prompts位于skills/performance-testing提交3f5182c

许可证: 无许可证

内容归原作者所有。SourceWeft 从公开仓库中收录这些内容。

举报或申请下架