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 從公開儲存庫中收錄這些內容。

檢舉或申請下架